Skip to content

incorrect index mode for files which have a mode not in (0644, 0755) #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tmzullinger opened this issue May 24, 2021 · 2 comments
Closed

Comments

@tmzullinger
Copy link
Contributor

A recent bug report in Fedora revealed an issue where GitPython creates incorrect index modes for a file added which had mode 0700. This is similar to issue #430 which was addressed in commit bebc4f5 (Use correct mode for executable files, 2016-05-19).

I'll push a fix for this momentarily. This area could certainly use some tests. The previous commit did not add any tests for me to copy and extend. I'm happy to try to add some tests, but I'm not sure that I have enough time to bring myself up to speed. Any help would be more appreciated if we want tests to go along with this change.

A very simple example of the issue is:

$ git init -q /tmp/git-test; cd /tmp/git-test ; touch foo ; chmod 700 foo
$ python -c 'import git; repo = git.Repo(); repo.index.add(["foo"])'
$ git ls-files -s
100744 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0   foo
tmzullinger added a commit to tmzullinger/GitPython that referenced this issue May 24, 2021
The fix for gitpython-developers#430 in bebc4f5 (Use correct mode for executable files,
2016-05-19) is incomplete.  It fails (in most cases) when files have
modes which are not exactly 0644 or 0755.

As git only cares about executable or or not in this case, ensure the
mode we set for the index is either 100644 or 100755.  Do this similarly
to how upstream git does it in cache.h¹.

Fixes gitpython-developers#1253

¹ https://github.com/git/git/blob/v2.31.1/cache.h#L247
tmzullinger added a commit to tmzullinger/GitPython that referenced this issue May 24, 2021
The fix for gitpython-developers#430 in bebc4f5 (Use correct mode for executable files,
2016-05-19) is incomplete.  It fails (in most cases) when files have
modes which are not exactly 0644 or 0755.

As git only cares about executable or or not in this case, ensure the
mode we set for the index is either 100644 or 100755.  Do this similarly
to how upstream git does it in cache.h¹.

Fixes gitpython-developers#1253

¹ https://github.com/git/git/blob/v2.31.1/cache.h#L247
@Byron
Copy link
Member

Byron commented May 25, 2021

Thanks a lot for the report, and sorry for the hassle!

I will continue my reply in the PR.

@Byron Byron added this to the v3.1.18 - Bugfixes milestone May 25, 2021
@tmzullinger
Copy link
Contributor Author

No hassle at all. Thank you for all your work on GitPython! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants