gpm icon indicating copy to clipboard operation
gpm copied to clipboard

git: You are not currently on a branch

Open xh3b4sd opened this issue 8 years ago • 3 comments

I found gpm and wanted to give it a try. It looks like it does not support pinning dependencies based on commits. I have this in my Godeps file.

github.com/alicebob/miniredis               bb985e34f0942b1d770bf96e87f830cf38804abe

This is what I get.

# cd /path/to/workspace/src/github.com/alicebob/miniredis; git pull --ff-only
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

package github.com/alicebob/miniredis: exit status 1

Is this intended? Can we make it work?

xh3b4sd avatar Nov 08 '16 01:11 xh3b4sd

That's weird! Definitely not intended.

Interesting: I just tested it on my local environment with gpm 1.4.0 and the same Godeps file as you, on first run I had no warnings, and on second run I have the same warning you are getting.

sample

Behind the scenes gpm uses go get, coupled with the -u flag to fetch any updates that have been pushed to the repository between last time you updated it and now. When the dependency is in a detached head state we get warnings from git.

This isn't necessarily a problem: as long as the following line is present it means the commit you requested is in the local history and has been set.

>> Setting github.com/alicebob/miniredis to version bb985e34f0942b1d770bf96e87f830cf38804abe

Although... I do agree its ugly. 😅

Would it be worthwhile to add code to solve this warning? I'll think of a way around it, off the top of my head I can think about storing the default branch and checking it out before the update, or simply suggest deleting the directory and fetching it again. I could also simply delete it automatically, but I'm not big on deleting things without explicit user conscent.

What do you think?

pote avatar Nov 08 '16 12:11 pote

Thanks for coming back. I think it is a good idea to checkout the default branch, do the go get magic, and checkout the desired revision. I am not a massive fan of storing information about the default branch. Git for instance does that somehow. See http://stackoverflow.com/questions/18726037/what-determines-default-branch-after-git-clone. Not sure about svn, mercurial etc..

xh3b4sd avatar Nov 08 '16 13:11 xh3b4sd

Let's not go the delete route. What @xh3b4sd suggested in his last comment looks good.

myusuf3 avatar Nov 08 '16 18:11 myusuf3