diff options
author | m0viefreak <m0viefreak.cm@googlemail.com> | 2013-07-20 18:32:48 +0400 |
---|---|---|
committer | m0viefreak <m0viefreak.cm@googlemail.com> | 2013-07-20 18:54:09 +0400 |
commit | 56dcac1a4a57b582d16c3478d7d51c39a8daa49b (patch) | |
tree | 43ce06f4220c61a7ef1799848e84b4bd0e1a5c37 /version.sh | |
parent | 558269dabdf30092e1ada2c2dd3c56358de7b707 (diff) |
version.sh: fix for when master branch does not exist
This can happen when the repo is cloned with --branch.
In this case, don't try to find the merge-base and don't
append it to the version string.
Diffstat (limited to 'version.sh')
-rw-r--r-- | version.sh | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/version.sh b/version.sh index 1527b1969..1b4702780 100644 --- a/version.sh +++ b/version.sh @@ -36,13 +36,16 @@ else # which commit from master it is based on and what its hash is. This assumes we # won't ever branch from a changeset from before the move to git if [[ "$branch" != "master" ]]; then - # Get where the branch is based on master - base=$(git merge-base master HEAD) - base_ver=$(git rev-list --count $svnhash..$base) - base_ver=$((base_ver+svnrev)) - version_info="#define MPCHC_BRANCH _T(\"$branch\")"$'\n' - ver_full=" ($branch) (master@${base_ver:0:7})" + if git show-ref --verify --quiet refs/heads/master; then + # Get where the branch is based on master + base=$(git merge-base master HEAD) + base_ver=$(git rev-list --count $svnhash..$base) + base_ver=$((base_ver+svnrev)) + ver_full=" ($branch) (master@${base_ver:0:7})" + else + ver_full=" ($branch)" + fi fi # Count how many changesets we have since the last svn changeset @@ -70,7 +73,7 @@ if [[ "$branch" ]] && ! git diff-index --quiet HEAD; then else echo "Revision: $ver" fi -if [[ "$branch" ]] && [[ "$branch" != "master" ]]; then +if [[ -n "$base" ]]; then echo "Mergebase: master@${base_ver} (${base:0:7})" fi |