Repository navigation
Report branch and tag names unprefixed when a branch and tag share a name [patch] - #181
Merged
Merged
Conversation
…name [patch] %(refname:short) keeps part of the prefix whenever the shortest name is ambiguous, so a branch and a tag both called v1 came back as heads/v1 and tags/v1, and a local branch called origin/main turned the remote-tracking branch and every upstream into remotes/origin/main. None of those names can be passed back to git. Read names with :lstrip=2 instead, which always strips exactly refs/heads/, refs/remotes/ or refs/tags/. Fixes #137 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W83XxSnDX5Fu4sVPDKjXem
|
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.



Fixes #137
What changed
When the shortest name would be ambiguous,
%(refname:short)and%(upstream:short)keep part of the ref prefix. This caused two problems:v1came back asheads/v1andtags/v1.origin/maincaused the remote-tracking branch, and every branch'sUpstream, to come back asremotes/origin/main.git rejects names with that leftover prefix when they are passed back to it.
ForEachRefFormatandForEachTagFormatnow read names with:lstrip=2, which always strips exactlyrefs/heads/,refs/remotes/orrefs/tags/. The parsers are unchanged apart from a comment. Local and remote branches are still told apart by the full refname in field 0, andrefs/remotes/<remote>/HEADis still skipped.Tests
Two new integration tests in
GitRoundTripTestsrun against real git:BranchAndTagSharingANameAreBothReportedByThatNameAsync: a branch and a tag both namedv1are reported asv1, and deleting each by its reported name succeeds.LocalBranchNamedLikeARemoteBranchLeavesTheRemoteNameAndUpstreamIntactAsync: with a localorigin/mainnext torefs/remotes/origin/main, the remote branch is namedorigin/mainandmain's upstream isorigin/main.GitBranchListBuilderTestsnow expects the new format string.Checked with git 2.43:
🤖 Generated with Claude Code
https://claude.ai/code/session_01W83XxSnDX5Fu4sVPDKjXem
Generated by Claude Code