Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix lint and mypy errors
- Remove whitespace from blank lines in docstrings (ruff W293)
- Use !r format specifier for bytes in f-string (mypy str-bytes-safe)
  • Loading branch information
MirrorDNA-Reflection-Protocol committed Dec 8, 2025
commit 6e77e26096ec3a2e8f204e2b1b10a068181537ce
2 changes: 1 addition & 1 deletion git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def decode_path(path: bytes, has_ab_prefix: bool = True) -> Optional[bytes]:
# Support standard (a/b) and mnemonicPrefix (c/w/i/o/h) prefixes
# See git-config diff.mnemonicPrefix documentation
valid_prefixes = (b"a/", b"b/", b"c/", b"w/", b"i/", b"o/", b"h/")
assert any(path.startswith(p) for p in valid_prefixes), f"Unexpected path prefix: {path[:10]}"
assert any(path.startswith(p) for p in valid_prefixes), f"Unexpected path prefix: {path[:10]!r}"
path = path[2:]

return path
Expand Down
8 changes: 4 additions & 4 deletions test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ def test_diff_unsafe_paths(self):

def test_diff_mnemonic_prefix(self):
"""Test that diff parsing works with mnemonicPrefix enabled.

When diff.mnemonicPrefix=true is set in git config, git uses different
prefixes for diff paths:
- c/ for commit
- w/ for worktree
- w/ for worktree
- i/ for index
- o/ for object

This addresses issue #2013 where the regex only matched [ab]/ prefixes.
"""
# Create a diff with mnemonicPrefix-style c/ and w/ prefixes
Expand All @@ -305,7 +305,7 @@ def test_diff_mnemonic_prefix(self):
"""
diff_proc = StringProcessAdapter(diff_mnemonic)
diffs = Diff._index_from_patch_format(self.rorepo, diff_proc)

# Should parse successfully (previously would fail or return empty)
self.assertEqual(len(diffs), 1)
diff = diffs[0]
Expand Down
Loading