Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Crash with git 2.30.3 - GitCommandError(remove_password_if_present...) #1432

Answered by Byron
nvuillam asked this question in Q&A
Discussion options

Since git 2.30.3 has been released, all MegaLinter CI jobs are failing because of the following error within gitpython.

File "/tmp/lint/megalinter/utils.py", line 229, in list_updated_files
 changed_files = [item.a_path for item in repo.index.diff(None)]
 File "/usr/local/lib/python3.9/site-packages/git/index/base.py", line [1309](https://github.com/megalinter/megalinter/runs/6028533814?check_suite_focus=true#step:5:1309), in diff
 return super(IndexFile, self).diff(other, paths, create_patch, **kwargs)
 File "/usr/local/lib/python3.9/site-packages/git/diff.py", line 175, in diff
 index = diff_method(self.repo, proc)
 File "/usr/local/lib/python3.9/site-packages/git/diff.py", line 570, in _index_from_raw_format
 handle_process_output(proc, lambda byt: cls._handle_diff_line(byt, repo, index),
 File "/usr/local/lib/python3.9/site-packages/git/cmd.py", line 176, in handle_process_output
 return finalizer(process)
 File "/usr/local/lib/python3.9/site-packages/git/util.py", line 386, in finalize_process
 proc.wait(**kwargs)
 File "/usr/local/lib/python3.9/site-packages/git/cmd.py", line 502, 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 diff --abbrev=40 --full-index -M --raw -z --no-color

The gitpython code called is a simple repo.index.diff(None)

def list_updated_files(repo_home):
 try:
 repo = git.Repo(repo_home)
 except git.InvalidGitRepositoryError:
 try:
 repo = git.Repo(REPO_HOME_DEFAULT)
 except git.InvalidGitRepositoryError:
 logging.warning("Unable to find git repository to list updated files")
 return []
 changed_files = [item.a_path for item in repo.index.diff(None)]
 return changed_files

I've investigated for some time and the delta between working / not working really seems to be from using git 2.30.3 instead of 2.30.2

You can see the error in this CI job for example: https://github.com/megalinter/megalinter/runs/6028533814?check_suite_focus=true

Would you have some tip to bypass such error ?

Many thanks !

Edit: this is probably related to actions/checkout#766

You must be logged in to vote

I turned the issue into a conversation as it's a change (or possibly regression) in git that causes the error, GitPython didn't seem to have changed.

That said, exit code 129 is used specifically in a few places within git but not when diffing. Maybe this code is also used if the process is terminated, which would make me wonder what's terminating it.

There seems to be no error output our standard output, making this hard to debug, but maybe the doc section about debugging can help to obtain more information.

Replies: 1 comment 5 replies

Comment options

I turned the issue into a conversation as it's a change (or possibly regression) in git that causes the error, GitPython didn't seem to have changed.

That said, exit code 129 is used specifically in a few places within git but not when diffing. Maybe this code is also used if the process is terminated, which would make me wonder what's terminating it.

There seems to be no error output our standard output, making this hard to debug, but maybe the doc section about debugging can help to obtain more information.

You must be logged in to vote
5 replies
Comment options

@Byron this is indeed related to a git update, maybe also to Github Actions, as well explained in this topic -> actions/checkout#766

But maybe any gitpython user will be impacted anyway, if gitpython is used in a context like Github Action + Gitpython used in a container step

Maybe it could be enhancing the error message to make it more helping, something like :

  • call git config --global --add safe.directory SOMEDIR to solve the issue
Comment options

That would be interesting to help with for sure, but I wouldn't know how since GitPython seems to have no information about it either. The status code 29 is strangely enough not mentioned in the source, but the source instead seems to try to die with exist code 1, while also providing the desired information. Probably it's squelched because stderr for git-diff is entirely ignored?

Are you suggesting to assume exit code 29 is related to the safe.directory issue?

Comment options

The code 129 is for sure related to the safe.directory issue
I'm still stucked... I try to call git config --global --add safe.directory SOMEDIR outside the container, inside the container.... and it's always the same meaningless error :/

 if status != 0:
 errstr = read_all_from_possibly_closed_stream(p_stderr)
 log.debug('AutoInterrupt wait stderr: %r' % (errstr,))
> raise GitCommandError(remove_password_if_present(self.args), status, errstr)
E git.exc.GitCommandError: Cmd('git') failed due to: exit code(129)
E cmdline: git diff --abbrev=40 --full-index -M --raw -z --no-color
usr/local/lib/python3.9/site-packages/GitPython-3.1.27-py3.9.egg/git/cmd.py:502: GitCommandError

That would really help if in such case, gitpython would tell the exact command to run, and where :/

Comment options

Great, if you have the time to create a PR to check for this exit code, I'd be all for it. Alternatively an issue could be created to incentivize this improvements.
Thanks for your help.

Comment options

I found the solution... I had to add git config --global --add safe.directory MYDIR inside the docker container (entrypoint), with as MYDIR the folder that was mapped to my external volume containing the git repository

This git update made quite a mess on lots of repos, I'm sure the next user of gitpython would love to have the solution displayed in the logs... but unfortunately I already have so much on my plate on the repos I'm working on, I don't have the bandwith to make a PR here :/
Best regards

Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1431 on April 15, 2022 02:02.

AltStyle によって変換されたページ (->オリジナル) /