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
4 changes: 4 additions & 0 deletions plugins/codex-security/scripts/workbench_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
"GIT_WORK_TREE",
)
EMPTY_GIT_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
EMPTY_GIT_TREES = {
"sha1": EMPTY_GIT_TREE,
"sha256": "6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321",
}


def positive_int(value: str) -> int:
Expand Down
3 changes: 2 additions & 1 deletion plugins/codex-security/scripts/workbench_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
DELIVERED_ACTION_LEASE_SECONDS,
DIFF_TARGET_KINDS,
EMPTY_GIT_TREE,
EMPTY_GIT_TREES,
FINDING_ABSOLUTE_PATH_BYTES,
FINDING_LEVEL_BYTES,
FINDING_LOCATION_PATH_BYTES,
Expand Down Expand Up @@ -337,7 +338,7 @@ def require_diff_target(
None,
)
if parent_line is None:
parent = EMPTY_GIT_TREE
parent = EMPTY_GIT_TREES[git_output(target, "rev-parse", "--show-object-format")]
else:
parent = resolve_git_commit(
target,
Expand Down
14 changes: 14 additions & 0 deletions plugins/codex-security/tests/test_git_inventory_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def test_root_commit_message_does_not_supply_diff_parent(tmp_path: Path, workben
assert diff["baseRevision"] == workbench_api["EMPTY_GIT_TREE"]


def test_sha256_root_commit_uses_the_sha256_empty_tree(tmp_path: Path, workbench_api) -> None:
target = tmp_path / "target"
target.mkdir()
git(target, "init", "-q", "--object-format=sha256")
git(target, "config", "user.email", "fixture@example.com")
git(target, "config", "user.name", "Fixture")
(target / "README.md").write_text("fixture\n")
git(target, "add", "README.md")
git(target, "commit", "-qm", "Initial commit")
diff = workbench_api["require_diff_target"](target, "commit", None, "HEAD", None)
revisions = (diff["baseRevision"], diff["headRevision"])
assert git(target, "diff", "--name-only", *revisions) == b"README.md"


def test_blob_batch_preserves_following_blobs_after_tree_and_commit(tmp_path: Path) -> None:
target = tmp_path / "target"
initialize_git_repository(target)
Expand Down
Loading