From df00293a7cd6e3fb11d0c1bf2fbf1c3ad485824c Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Wed, 31 Dec 2014 17:01:28 +0000 Subject: [PATCH] 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 [...] -- [...]' Traceback (most recent call last): File "./git-arr", line 457, in 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 --- git-arr | 2 +- git.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/git-arr b/git-arr index 418f883..b9c9d46 100755 --- a/git-arr +++ b/git-arr @@ -380,7 +380,7 @@ def generate(output, skip_index = False): # To avoid regenerating files that have not changed, we will # 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. branch_mtime = r.commit(bn).committer_date.epoch diff --git a/git.py b/git.py index 8aa9eb1..bddca70 100644 --- a/git.py +++ b/git.py @@ -253,6 +253,7 @@ class Repo: cmd.max_count = limit cmd.arg(ref) + cmd.arg('--') for l in cmd.run(): yield l.rstrip('\n') @@ -273,6 +274,7 @@ class Repo: cmd.header = None cmd.arg(ref) + cmd.arg('--') info_buffer = '' count = 0