X Tutup
The Wayback Machine - https://web.archive.org/web/20200916181625/https://github.com/nodegit/nodegit/pull/1250
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`Repository.checkoutBranch` does nothing if branch name matches tag name #1250

Open
wants to merge 1 commit into
base: master
from

Conversation

@rcjsuen
Copy link
Member

rcjsuen commented Mar 11, 2017

According to the Git documentation, refs/tags/ will be searched before refs/heads/ when looking up references. As a result, trying to use getReference() in checkoutBranch will 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/ to branch before calling getReference(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/ to branch before calling getReference(branch) if and only if branch does not already have refs/heads/ as its prefix.

Result B:
The API contract becomes a little weird. Some clients may want to pass in refs/heads/branch to checkout refs/heads/refs/heads/branch when NodeGit will in fact end up checking out refs/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 named refs/heads/refs/heads/branch in their repository.

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.
@implausible implausible force-pushed the nodegit:master branch from c345989 to c67b436 Aug 26, 2019
@implausible implausible force-pushed the nodegit:master branch from 2b7db46 to 69b010a Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.
X Tutup