Skip to content

Conversation

@rcjsuen
Copy link
Member

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

1 participant