-
-
Notifications
You must be signed in to change notification settings - Fork 950
Closed as not planned
Description
I've been hitting an issue where:
repo = git.Repo('path/to/repo')
for commit in repo.iter_commits():
if len(commit.parents) == 0:
previous_commit = None
else:
previous_commit = commit.parents[0].tree
for file in commit.stats.files:
status = repo.git.diff('--name-status', previous_commit, file)
keeps blowing up with an exception along the lines of:
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git diff --name-status fea6f08304c7e01f3dae87947901eee1fcba55eb example.txt
stderr: 'fatal: ambiguous argument 'example.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]''
I've had to work around it with a raw command that includes the --
argument like:
status = repo.git.diff('--name-status', previous_commit.hexsha, '--', file)
This seems related to #1061. Looking at
Line 268 in ee987da
args.append("--") |
it seems there the code is attempting to add the
--
argument before the pathspec, but it's not working. I'm not sure if this is me doing something wrong or a genuine bug, but either way I think I either the documentation or the code needs updating to address this issue.Metadata
Metadata
Assignees
Labels
No labels