git: Add '--' to "git rev-list" runs to avoid ambiguous arguments

If there is a branch and a file with the same name, git-arr will fail to
generate, as git will complain when running git rev-list.

For example, if there is both a file and a branch called "hooks" in the
repository, git-arr would fail as follows:

=== git-arr running: ['git', '--git-dir=/some/repo', 'rev-list', '--max-count=1', '--header', u'hooks'])
fatal: ambiguous argument 'hooks': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Traceback (most recent call last):
  File "./git-arr", line 457, in <module>
    main()
  File "./git-arr", line 452, in main
    skip_index = len(opts.only) > 0)
  File "./git-arr", line 388, in generate
    branch_mtime = r.commit(bn).committer_date.epoch
AttributeError: 'NoneType' object has no attribute 'committer_date'

To fix that, this patch appends a "--" as the last argument to rev-list, which
indicates that it has completed the revision list, which disambiguates the
argument.

While at it, a minor typo in a comment is also fixed.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
This commit is contained in:
Alberto Bertogli 2014-12-31 17:01:28 +00:00
parent 7898b2becd
commit df00293a7c
2 changed files with 3 additions and 1 deletions

@ -380,7 +380,7 @@ def generate(output, skip_index = False):
# To avoid regenerating files that have not changed, we will # To avoid regenerating files that have not changed, we will
# instruct write_to() to set their mtime to the branch's committer # instruct write_to() to set their mtime to the branch's committer
# date, and then compare against it to decide wether or not to # date, and then compare against it to decide whether or not to
# write. # write.
branch_mtime = r.commit(bn).committer_date.epoch branch_mtime = r.commit(bn).committer_date.epoch

2
git.py

@ -253,6 +253,7 @@ class Repo:
cmd.max_count = limit cmd.max_count = limit
cmd.arg(ref) cmd.arg(ref)
cmd.arg('--')
for l in cmd.run(): for l in cmd.run():
yield l.rstrip('\n') yield l.rstrip('\n')
@ -273,6 +274,7 @@ class Repo:
cmd.header = None cmd.header = None
cmd.arg(ref) cmd.arg(ref)
cmd.arg('--')
info_buffer = '' info_buffer = ''
count = 0 count = 0