Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

make checkoutBranch works with branches that lives outside of refs/heads#891

Merged
johnhaley81 merged 3 commits intonodegit:masternodegit/nodegit:masterfrom
AsoSunag:masterAsoSunag/nodegit:masterCopy head branch name to clipboard
Feb 29, 2016
Merged

make checkoutBranch works with branches that lives outside of refs/heads#891
johnhaley81 merged 3 commits intonodegit:masternodegit/nodegit:masterfrom
AsoSunag:masterAsoSunag/nodegit:masterCopy head branch name to clipboard

Conversation

@AsoSunag
Copy link
Contributor

@AsoSunag AsoSunag commented Feb 3, 2016

And avoid trying to call a method on a boolean when isBranch() is false.

@johnhaley81
Copy link
Collaborator

So I could be wrong but I'm pretty sure that anything that exists outside of refs/heads is, according to git, not a branch. So this function is doing what it is supposed to be doing. I definitely see the use case for this though.

Let's abstract this out to checkoutRef and then make another method that's called checkoutBranch that has the old functionality. Maybe have checkoutBranch confirm that the ref is indeed a branch before calling checkoutRef and then rejecting if it isn't.

@AsoSunag
Copy link
Contributor Author

AsoSunag commented Feb 4, 2016

Hello,

Yes you're right, I did that for remotes. It is good idea to have a checkoutRef and a checkoutBranch. The only thing that is bothering me with that is that when using checkoutRef with a non branch reference we will still use getBranchCommit. So we could keep one method checkoutBranch checking if it is a branch or a remote or we can have two methods.

What do you think is the best?

@johnhaley81
Copy link
Collaborator

Repository#getBranchCommit just calls Repository#getReferenceCommit so we can replace that call with Repository#getReferenceCommit

@AsoSunag
Copy link
Contributor Author

AsoSunag commented Feb 5, 2016

ah ok I'll do that then.

@johnhaley81
Copy link
Collaborator

LGTM Thanks @AsoSunag

johnhaley81 added a commit that referenced this pull request Feb 29, 2016
make checkoutBranch works with branches that lives outside of refs/heads
@johnhaley81 johnhaley81 merged commit 4a8cf95 into nodegit:master Feb 29, 2016
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.