fix: reject deleted prior checkout branches#2610
Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
Draft
fix: reject deleted prior checkout branches#2610Sebastian Thiel (Byron) wants to merge 1 commit into
Sebastian Thiel (Byron) wants to merge 1 commit into
Conversation
Repository::rev_parse_single("@{-1}") could return the previous object id from HEAD's reflog after the prior checkout branch had been deleted. Git treats @{-N} as the previous checkout name and reparses that name, so a deleted branch no longer names a single revision.
The regression adds deleted prior-checkout fixtures and asserts that @{-1} follows the Git baseline failure for deleted branch names while still accepting previous checkout names that are full object ids.
The fix keeps resolving existing prior checkout references as before, but only falls back to a direct object id when the reflog name itself is a full object id for the repository hash kind.
Git baseline: Git 2.50.1 rejects the deleted branch scenario with `git rev-parse --verify @{-1}` reporting "Needed a single revision" and exiting 128. The reference implementation in object-name.c expands @{-N} to the previous checkout text before normal revision lookup.
Validation:
- GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes::reflog::nth_prior_checkout_to_deleted_branch_fails_like_git --features revision
- GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes::reflog --features revision
- cargo test -p gix --test gix revision::spec::from_bytes::reflog --features revision
- GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes --features revision
- cargo test -p gix --test gix revision::spec::from_bytes --features revision
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Summary
Fixes #2609.
Repository::rev_parse_single("@{-1}")now rejects a deleted prior checkout branch instead of resolving it through the stale object id stored in the HEAD reflog.The change keeps Git-compatible full-object-id behavior for previous checkout names that are themselves complete object ids.
Git Baseline
Git 2.50.1 rejects the deleted branch scenario with
git rev-parse --verify @{-1}reporting "Needed a single revision" and exiting 128.The Git reference implementation in
object-name.cexpands@{-N}to the previous checkout text before normal revision lookup.Validation
GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes::reflog::nth_prior_checkout_to_deleted_branch_fails_like_git --features revisionGIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes::reflog --features revisioncargo test -p gix --test gix revision::spec::from_bytes::reflog --features revisionGIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix revision::spec::from_bytes --features revisioncargo test -p gix --test gix revision::spec::from_bytes --features revision