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

git.base.IndexFile.iter_blobs crashes after executing git update-index --skip-worktree <some_file> - unsupported git index version #1075

Open
@ktns

Description

Hi.

I've encountered AssertionError while calling git.base.IndexFile.iter_blobs after git update-index --skip-worktree <some_file> like below.

%pip install GitPython==3.1.11
Requirement already satisfied: GitPython==3.1.11 in /usr/local/python3.7/lib/python3.7/site-packages (3.1.11)
Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/python3.7/lib/python3.7/site-packages (from GitPython==3.1.11) (4.0.5)
Requirement already satisfied: smmap<4,>=3.0.1 in /usr/local/python3.7/lib/python3.7/site-packages (from gitdb<5,>=4.0.1->GitPython==3.1.11) (3.0.4)
%cd $(mktemp -d) 
%git init . 
Initialized empty Git repository in /tmp/tmp.JXLEk4zfdj/.git/
%touch foo 
%git add foo 
%git update-index --skip-worktree foo
%python3 -c ' 
import git 
with git.Repo(".", search_parent_directories=True) as repo:
 print(*repo.index.iter_blobs())
'
Traceback (most recent call last):
 File "<string>", line 4, in <module>
 File "/usr/local/python3.7/lib/python3.7/site-packages/git/index/base.py", line 441, in iter_blobs
 for entry in self.entries.values():
 File "/usr/local/python3.7/lib/python3.7/site-packages/gitdb/util.py", line 253, in __getattr__
 self._set_cache_(attr)
 File "/usr/local/python3.7/lib/python3.7/site-packages/git/index/base.py", line 128, in _set_cache_
 self._deserialize(stream)
 File "/usr/local/python3.7/lib/python3.7/site-packages/git/index/base.py", line 157, in _deserialize
 self.version, self.entries, self._extension_data, _conten_sha = read_cache(stream)
 File "/usr/local/python3.7/lib/python3.7/site-packages/git/index/fun.py", line 185, in read_cache
 version, num_entries = read_header(stream)
 File "/usr/local/python3.7/lib/python3.7/site-packages/git/index/fun.py", line 165, in read_header
 assert version in (1, 2)
AssertionError

It's not an urgent issue for me because after git update-index --no-skip-worktree it works without any problems, but if you have spare time can you please support git index with skip-worktree?

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 によって変換されたページ (->オリジナル) /