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

Correctly handle detached head for 'latest' on latest Git versions #106

Merged
merged 2 commits into from
Dec 2, 2013
Merged

Correctly handle detached head for 'latest' on latest Git versions #106

merged 2 commits into from
Dec 2, 2013

Conversation

mikegerwitz
Copy link

Newer versions of Git (I'm not sure as of what version) will output the following for git branch -a while in a detached HEAD state:

$ git branch -a
* (detached from 4689c51)                                             
  master                                                              
  remotes/origin/HEAD -> origin/master

The first line is different than what is expected from previous Git version: "(no branch)". This patch uses rev-parse, which should work with most existing Git versions and will hopefully be immune to this problem in the future.

This patch also gets rid of "origin/HEAD", which is not a valid (and does throw an error in newer Git versions); origin/master points to the tip of master on origin, which seems to be what was desired.

@hopperd
Copy link

hopperd commented Dec 2, 2013

Nice Mike, this fixes an that annoying issue that we've been having!

@apenney
Copy link

apenney commented Dec 2, 2013

I'd love to get this merged but unfortunately it's breaking the travis tests. Any chance you can have a quick stab at fixing the unit tests?

@mikegerwitz
Copy link
Author

Sorry about that; I'll take care of it now. Haven't written a line of ruby before, so just need to get a working environment first so that I can run those tests.

@mikegerwitz
Copy link
Author

The tests have been corrected. Please note that I amended the tip of my master branch.

apenney pushed a commit that referenced this pull request Dec 2, 2013
Correctly handle detached head for 'latest' on latest Git versions
@apenney apenney merged commit a96a42e into puppetlabs:master Dec 2, 2013
@apenney
Copy link

apenney commented Dec 2, 2013

Thanks for taking this on so quickly, and for the patch!

@mikegerwitz
Copy link
Author

And thank you for merging that so quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants