genehack/Git-Wrapper — Issue #7: No way to get only one log entry
Author: barefootcoder
Created: 2012-02-02 03:49:06+00:00
State: open

It's a very minor thing, but I can't simulate `git log -n1` with `Git::Wrapper`. That is, if I do this:

my ($last_log) = $git->log({ max_count => 1 });

I get:

fatal: Option '--max-count' requires a value

I see what's going on here--your code sees a value of "1", decides it's a boolean switch, and buiilds the command line appropriately. But I'm not sure how to fix it. I even tried:

my ($last_log) = $git->log({ max_count => 1.0 });

thinking that would squeak me by the `eq '1'` test, but that didn't work either. Happily, the workaround is simple enough:

my ($last_log) = $git->log({ max_count => 2 });

which works fine. Technically, it's wasteful, since we're retrieving a log that we're just throwing away, but I sincerely doubt that's ever going to make any measurable performance difference.

Anyway, if you have a suggestion on how to fix it, I'd be glad to patch it, but I don't really see a clean way around it ATM. Maybe just give up and do a doco patch warning people this could be a problem ... ?