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

repo.index.add() method attempts to chmod files which it should not #2021

Open
@jrollins

Description

The behavior of the repo.index.add() method behaves differently than the CLI equivalent git add:

0$ git add *
0$ python3 -c 'import git; git.Repo.init().git.add("*")'
0$ python3 -c 'import git; git.Repo.init().index.add("*")'
Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/git/index/base.py", line 885, in add
 entries_added.extend(self._entries_for_paths(paths, path_rewriter, fprogress, entries))
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/git/util.py", line 176, in wrapper
 return func(self, *args, **kwargs)
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/git/index/util.py", line 111, in set_git_working_dir
 return func(self, *args, **kwargs)
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/git/index/base.py", line 745, in _entries_for_paths
 entries_added.append(self._store_path(filepath, fprogress))
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/git/index/base.py", line 698, in _store_path
 istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
 File "/opt/conda/base/envs/cds/lib/python3.10/site-packages/gitdb/db/loose.py", line 233, in store
 chmod(obj_path, self.new_objects_mode)
PermissionError: [Errno 1] Operation not permitted: '/path/to/repo/.git/objects/02/60b9d2b53981a5ddbe20f3f0aae350b2806d22'
1$ 

I don't see any reason that the python-native methods should be doing anything different than what the CLI does.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

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