Vince
Vince

Reputation: 1527

Git::Repository wont run git log

I've tried running git log --since 2013-09-17 via Git::Repository-run, but it's not working. It states that

git: 'log --since=2013-09-17' is not a git command. See 'git --help'.

However when I run the command on the console, it works pretty well. Here's my code:

 41 my $repo = Git::Repository->new(
 42         git_dir => $git_path,
 43 );
 44 my $log_cmd = 'log'.($from ? " --since=$from" : '').($to ? " --until=$to" : '');
 48 my @commits = $repo->run($log_cmd);

Also note that log without any since/until-params is running just fine.

Does any of you guys have an idea what I'm doing wrong here?

Upvotes: 0

Views: 191

Answers (1)

Slaven Rezic
Slaven Rezic

Reputation: 4581

Use a parameter list as arguments to run() here, similar like you would use the list form of perl's system() or exec() builtins:

my @log_cmd = ('log', ($from ? "--since=$from" : ()), ($to ? "--until=$to" : ()));
my @commits = $repo->run(@log_cmd);

Upvotes: 2

Related Questions