pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/GitoxideLabs/gitoxide/pull/2610

="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-eab9c5888b163e42.css" /> fix: reject deleted prior checkout branches by Byron · Pull Request #2610 · GitoxideLabs/gitoxide · GitHub
Skip to content

fix: reject deleted prior checkout branches#2610

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-rev-parse
May 26, 2026
Merged

fix: reject deleted prior checkout branches#2610
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-rev-parse

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented May 18, 2026

Copy link
Copy Markdown
Member

Tasks

  • refackiew

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.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

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.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Sebastian Thiel (Byron) marked this pull request as ready for review May 26, 2026 04:45
Copilot AI review requested due to automatic review settings May 26, 2026 04:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes gix::Repository::rev_parse_single("@{-1}") to match Git’s behavior when the previous checkout target was a branch that has since been deleted: instead of resolving via the stale object id recorded in HEAD’s reflog, it now fails unless the prior checkout name itself is a full object id.

Changes:

  • Update prior-checkout (@{-N}) resolution to error on deleted branch names instead of falling back to the reflog’s recorded object id.
  • Preserve Git-compatible behavior for prior checkout names that are full object ids by accepting them even if they don’t correspond to an existing ref.
  • Add fixtures + tests covering both the deleted-branch failure case and the “branch named like full object id” acceptance case.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
gix/src/revision/spec/parse/delegate/revision.rs Adjusts @{-N} handling to re-resolve the previous checkout name and reject deleted branches, only allowing fallback for full object ids.
gix/tests/gix/revision/spec/from_bytes/reflog.rs Adds regression tests for deleted prior-checkout branches and the full-object-id-name exception.
gix/tests/fixtures/make_rev_spec_parse_repos.sh Adds new fixture repos to exercise the deleted-branch and full-object-id-name prior-checkout scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Byron Sebastian Thiel (Byron) merged commit a4be01b into main May 26, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gix::Repository::rev_parse_single doesn't agree with git for specs of the form @{-n}

3 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy