Repository.checkoutBranch does nothing if branch name matches tag name#1250
Open
rcjsuen wants to merge 1 commit intonodegit:masterfrom
Open
Repository.checkoutBranch does nothing if branch name matches tag name#1250rcjsuen wants to merge 1 commit intonodegit:masterfrom
Repository.checkoutBranch does nothing if branch name matches tag name#1250rcjsuen wants to merge 1 commit intonodegit:masterfrom
Conversation
Add a failing test wherein the existence of both a refs/heads/branch branch reference and a refs/tags/branch tag reference will cause the checkout to fail.
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.
According to the Git documentation,
refs/tags/will be searched beforerefs/heads/when looking up references. As a result, trying to usegetReference()incheckoutBranchwill fail as it will return the tag instead of the branch.I have included a failing test case that illustrates this problem.
Solution A:
Prepend
refs/heads/tobranchbefore callinggetReference(branch).Result A:
Any existing NodeGit clients that currently pass in a fully qualified reference name will be broken in the next release.
Solution B:
Prepend
refs/heads/tobranchbefore callinggetReference(branch)if and only ifbranchdoes not already haverefs/heads/as its prefix.Result B:
The API contract becomes a little weird. Some clients may want to pass in
refs/heads/branchto checkoutrefs/heads/refs/heads/branchwhen NodeGit will in fact end up checking outrefs/heads/branch. Of course, with the right documentation this might not be ambiguous at all to anyone using the API and most users of Git probably don't have a branch namedrefs/heads/refs/heads/branchin their repository.