pydriller: Version 2.5 Traversing Commits - git.exc.GitCommandError: Cmd('git') failed due to: exit code(129)

Describe the bug I seem to be getting a new issue with 2.5 traversing from a commit.

Before updating, I was having this issue: https://github.com/ishepard/pydriller/issues/269

ValueError: SHA b'3325702e176042723f591a5c0e5db09f911fc661' could not be resolved, git returned: b'3325702e176042723f591a5c0e5db09f911fc661 missing'

This is the new git rev-list error:

Traceback (most recent call last):
  File "mine_metrics.py", line 25, in <module>
    commits = [commit.hash for commit in repo.traverse_commits()]
  File "mine_metrics.py", line 25, in <listcomp>
    commits = [commit.hash for commit in repo.traverse_commits()]
  File "/home/ubuntu/.local/lib/python3.8/site-packages/pydriller/repository.py", line 236, in traverse_commits
    for job in executor.map(self._iter_commits, git.get_list_commits(rev, **kwargs)):
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 608, in map
    fs = [self.submit(fn, *args) for args in zip(*iterables)]
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 608, in <listcomp>
    fs = [self.submit(fn, *args) for args in zip(*iterables)]
  File "/home/ubuntu/.local/lib/python3.8/site-packages/pydriller/git.py", line 121, in get_list_commits
    for commit in self.repo.iter_commits(rev=rev, **kwargs):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/git/objects/commit.py", line 426, in _iter_from_process_or_stream
    finalize_process(proc_or_stream)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/git/util.py", line 419, in finalize_process
    proc.wait(**kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/git/cmd.py", line 604, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(129)
  cmdline: git rev-list --reverse --ancestry-path=51041cf640a2005611122b883003d4b30d135863 ^51041cf640a2005611122b883003d4b30d135863^ HEAD --
  stderr: 'usage: git rev-list [OPTION] <commit-id>... [ -- paths... ]
  limiting output:
    --max-count=<n>
    --max-age=<epoch>
    --min-age=<epoch>
    --sparse
    --no-merges
    --min-parents=<n>
    --no-min-parents
    --max-parents=<n>
    --no-max-parents
    --remove-empty
    --all
    --branches
    --tags
    --remotes
    --stdin
    --quiet
  ordering output:
    --topo-order
    --date-order
    --reverse
  formatting output:
    --parents
    --children
    --objects | --objects-edge
    --unpacked
    --header | --pretty
    --[no-]object-names
    --abbrev=<n> | --no-abbrev
    --abbrev-commit
    --left-right
    --count
  special purpose:
    --bisect
    --bisect-vars
    --bisect-all
'

To Reproduce If you clone https://github.com/tmhglnd/mercury into mercury

And run the following:

from pydriller.repository import Repository

repo = Repository(path_to_repo='mercury', only_in_branch='master', from_commit='51041cf640a2005611122b883003d4b30d135863')

OS Version: Linux

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (13 by maintainers)

Commits related to this issue

Most upvoted comments

The value of --ancestry-path seems to be redundant so we can simply use

git rev-list --reverse --ancestry-path ^FROM_SHA TO_SHA --

This should make 2.5(.1) backward compatible.

Updated to git 2.40.1 and issue is resolved.

Maybe git version should be checked in the code?

This is the code:

from pydriller.repository import Repository

repo = Repository(path_to_repo='mercury', only_in_branch='master', from_commit='51041cf640a2005611122b883003d4b30d135863')

The commit does exist: https://github.com/tmhglnd/mercury/commit/51041cf640a2005611122b883003d4b30d135863

The error has to do with the git rev-list command here: https://github.com/ishepard/pydriller/blob/master/pydriller/utils/conf.py#L159-L163

When I run:

git rev-list --reverse --ancestry-path=51041cf640a2005611122b883003d4b30d135863 ^51041cf640a2005611122b883003d4b30d135863^ HEAD --

It produces an exit code 129 which means bad arguments.

The previous version ran the following shell command:

git rev-list --reverse ^51041cf640a2005611122b883003d4b30d135863^ HEAD --

The ancestry-path argument is invalid for my version of git (2.25.1).