Skip to content

Commit

Permalink
Fix annoying "fatal: bad revision '^master'" git error
Browse files Browse the repository at this point in the history
On some buildbots and friends, we don't have remotes as you normally think of them.  Provide a fallback for $origin in that case.
  • Loading branch information
staticfloat committed Aug 27, 2014
1 parent 743af1a commit a4f4ce7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/version_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if [ "$#" = "1" -a "$1" = "NO_GIT" ]; then
fi
# Collect temporary variables
origin=$(git config -l 2>/dev/null | grep 'remote\.\w*\.url.*JuliaLang/julia.git' | sed -n 's/remote\.\([a-zA-Z]*\)\..*/\1\//p')
if [ -z "$origin" ]; then
origin="origin/"
fi
last_tag=$(git describe --tags --abbrev=0)
git_time=$(git log -1 --pretty=format:%ct)

Expand Down

6 comments on commit a4f4ce7

@ivarne
Copy link
Member

@ivarne ivarne commented on a4f4ce7 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contiuation of discussion in #8731 (comment)
cc: @staticfloat @tkelman

The intention when I wrote this, was that $origin should be empty when I couldn't find a reasonable remote. If the search for remote turns up empty, I assumed that origin/master would be just as invalid as master, and that there were some slim chance that the user would have a reasonable master branch that we could use as a reference.

@staticfloat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, then we need to alter line 62. It fails when it is passed just ^master. Apparently, ^origin/master is valid, but ^master isn't?

@ivarne
Copy link
Member

@ivarne ivarne commented on a4f4ce7 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^master is valid for me, so there seems to be something strange with your checkout, which makes it hard for me to debug. Do you clone without creating a local master branch?

@staticfloat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. It works on my local machine as well. That's strange. I wonder if this was because Travis was using an old version of git at one point in time. The error didn't break anything except the fork distance calculation, so I'm willing to revert this and see if I can track down further what circumstances cause it to arise, if you like.

@ivarne
Copy link
Member

@ivarne ivarne commented on a4f4ce7 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we add more code to handle more conditions, we have two options when the config parsing to find the official remote fails:

  • Fail when there isn't a local master branch (my approach)
  • Fail when there isn't a valid origin remote (your approach)

Both seems equally reasonable, and travis has a preference, so that's probably the best option.

@tkelman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One case in which I've seen funny git errors on buildbots is due to shallow cloning, if you're working in a branch and you accumulate a whole bunch of small commits so the shallow clone doesn't contain anything that's present upstream. But I doubt that was the same failure case that led to @staticfloat making this change.

Please sign in to comment.