From 36d0931a96f647f9bf50d86a2955690a1ba6b87f Mon Sep 17 00:00:00 2001 From: nia-sg-bot Date: Fri, 9 Oct 2026 21:02:13 +0530 Subject: [PATCH 1/2] test(git): cover staged SHA-256 blob provenance --- tests/test_git_snapshot.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test_git_snapshot.py b/tests/test_git_snapshot.py index 71c7c4e..6a4a398 100644 --- a/tests/test_git_snapshot.py +++ b/tests/test_git_snapshot.py @@ -208,6 +208,40 @@ def test_sha256_repository_preserves_full_immutable_blob_identities(tmp_path): ] +def test_sha256_staged_snapshot_preserves_full_blob_identities(tmp_path): + """Staged SHA-256 changes retain complete immutable endpoint identities.""" + repo = make_sha256_repo(tmp_path) + write(repo, "modified.bin", b"\x00before\xff\n") + write(repo, "deleted.txt", b"remove me\n") + commit_all(repo, "base") + + old_modified = oid(repo, "HEAD:modified.bin") + old_deleted = oid(repo, "HEAD:deleted.txt") + write(repo, "modified.bin", b"\x00after\xff\n") + os.unlink(repo / "deleted.txt") + write(repo, "added.bin", b"\x1f\x8bnew archive") + git(repo, "add", "-A") + + result = resolve_staged(str(repo)) + entries = {entry.new_path or entry.old_path: entry for entry in result.entries} + + assert result.warnings == () + assert set(entries) == {"added.bin", "deleted.txt", "modified.bin"} + assert (entries["modified.bin"].old_oid, entries["modified.bin"].new_oid) == ( + old_modified, index_oid(repo, "modified.bin"), + ) + assert (entries["deleted.txt"].old_oid, entries["deleted.txt"].new_oid) == ( + old_deleted, None, + ) + assert (entries["added.bin"].old_oid, entries["added.bin"].new_oid) == ( + None, index_oid(repo, "added.bin"), + ) + for entry in entries.values(): + for object_id in (entry.old_oid, entry.new_oid): + if object_id is not None: + assert len(object_id) == 64 + + def test_unstaged_hash_matches_git_add_clean_filter_semantics(tmp_path): repo = make_repo(tmp_path) write(repo, ".gitattributes", b"filtered.txt text eol=lf\n") From 8d051867607ef3df2ade5918757688095520d1f7 Mon Sep 17 00:00:00 2001 From: nia-sg-bot Date: Sat, 10 Oct 2026 01:32:06 +0530 Subject: [PATCH 2/2] test(git): distinguish staged and worktree blobs --- tests/test_git_snapshot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_git_snapshot.py b/tests/test_git_snapshot.py index 6a4a398..475279a 100644 --- a/tests/test_git_snapshot.py +++ b/tests/test_git_snapshot.py @@ -221,6 +221,8 @@ def test_sha256_staged_snapshot_preserves_full_blob_identities(tmp_path): os.unlink(repo / "deleted.txt") write(repo, "added.bin", b"\x1f\x8bnew archive") git(repo, "add", "-A") + staged_modified = index_oid(repo, "modified.bin") + write(repo, "modified.bin", b"\x00worktree-only\xff\n") result = resolve_staged(str(repo)) entries = {entry.new_path or entry.old_path: entry for entry in result.entries} @@ -228,7 +230,7 @@ def test_sha256_staged_snapshot_preserves_full_blob_identities(tmp_path): assert result.warnings == () assert set(entries) == {"added.bin", "deleted.txt", "modified.bin"} assert (entries["modified.bin"].old_oid, entries["modified.bin"].new_oid) == ( - old_modified, index_oid(repo, "modified.bin"), + old_modified, staged_modified, ) assert (entries["deleted.txt"].old_oid, entries["deleted.txt"].new_oid) == ( old_deleted, None,