git-gui: Prefer version file over git-describe.
Some distributions are using Git for part of their package management system, but unpack Git's own source code for delivery from the .tar.gz. This means that when we walk up the directory tree with git-describe to locate a Git repository, the repository we find is for the distribution and *not* for git-gui. Consequently any tag we might find there is bogus and does not apply to us. In this case the version file should always exist and be readable, as the packager is working from the released .tar.gz sources. So we should always favor the version file over anything git-describe guess for us. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Feb 14, 2007 at 01:55 UTC
26370f73c0e82bd67103e0868f84a44b536ff3fc
1 file changed
+11
-6
GIT-VERSION-GEN
+11
-6
@@ -20,6 +20,11 @@ tree_search ()
20
done
21
}
22
23
+# Always use the tarball version file if found, just
24
+# in case we are somehow contained in a larger git
25
+# repository that doesn't actually track our state.
26
+# (At least one package manager is doing this.)
27
+#
28
# We may be a subproject, so try looking for the merge
29
# commit that supplied this directory content if we are
30
# not at the toplevel. We probably will always be the
@@ -27,10 +32,13 @@ tree_search ()
32
# that fact.
33
#
34
# If we are at the toplevel or the merge assumption fails
30
-# try looking for a gitgui-* tag, or fallback onto the
31
-# distributed version file.
35
+# try looking for a gitgui-* tag.
36
33
-if prefix="$(git rev-parse --show-prefix 2>/dev/null)"
37
+if test -f version &&
38
+ VN=$(cat version)
39
+then
40
+ : happy
41
+elif prefix="$(git rev-parse --show-prefix 2>/dev/null)"
42
test -n "$prefix" &&
43
head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
44
tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
@@ -48,9 +56,6 @@ elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
56
esac
57
then
58
VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
51
-elif test -f version
52
-then
53
- VN=$(cat version) || VN="$DEF_VER"
59
else
60
VN="$DEF_VER"
61
fi