Preliminary support for index format v3 by blahgeek · Pull Request #2081 · gitpython-developers/GitPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions git/index/fun.py
15 changes: 14 additions & 1 deletion git/index/typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
CE_VALID = 0x8000
CE_STAGESHIFT = 12

CE_EXT_SKIP_WORKTREE = 0x4000
CE_EXT_INTENT_TO_ADD = 0x2000

# } END invariants


Expand Down Expand Up @@ -87,6 +90,8 @@ class BaseIndexEntryHelper(NamedTuple):
uid: int = 0
gid: int = 0
size: int = 0
# version 3 extended flags, only when (flags & CE_EXTENDED) is set
extended_flags: int = 0


class BaseIndexEntry(BaseIndexEntryHelper):
Expand All @@ -102,7 +107,7 @@ def __new__(
cls,
inp_tuple: Union[
Tuple[int, bytes, int, PathLike],
Tuple[int, bytes, int, PathLike, bytes, bytes, int, int, int, int, int],
Tuple[int, bytes, int, PathLike, bytes, bytes, int, int, int, int, int, int],
],
) -> "BaseIndexEntry":
"""Override ``__new__`` to allow construction from a tuple for backwards
Expand Down Expand Up @@ -134,6 +139,14 @@ def stage(self) -> int:
"""
return (self.flags & CE_STAGEMASK) >> CE_STAGESHIFT

@property
def skip_worktree(self) -> bool:
return (self.extended_flags & CE_EXT_SKIP_WORKTREE) > 0

@property
def intent_to_add(self) -> bool:
return (self.extended_flags & CE_EXT_INTENT_TO_ADD) > 0

@classmethod
def from_blob(cls, blob: Blob, stage: int = 0) -> "BaseIndexEntry":
""":return: Fully equipped BaseIndexEntry at the given stage"""
Expand Down
Binary file added test/fixtures/index_extended_flags
Binary file not shown.
42 changes: 42 additions & 0 deletions test/test_index.py
Loading