Skip to content

Commit 67c7575

Browse files
author
Junio C Hamano
committed
Merge branch 'master' of git://repo.or.cz/git-gui
* 'master' of git://repo.or.cz/git-gui: git-gui: Change base version to 0.6. git-gui: Guess our version accurately as a subproject. git-gui: Handle gitgui tags in version gen. git-gui: Generate a version file on demand. git-gui: Rename GIT_VERSION to GITGUI_VERSION. git-gui: Allow gitexecdir, INSTALL to be set by the caller.
2 parents d63ea11 + fdf6cfc commit 67c7575

File tree

3 files changed

+58
-19
lines changed

3 files changed

+58
-19
lines changed

git-gui/GIT-VERSION-GEN

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=v0.5.GIT
4+
DEF_VER=0.6.GITGUI
55

66
LF='
77
'
88

9-
# First try git-describe, then see if there is a version file
10-
# (included in release tarballs), then default
11-
if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
9+
tree_search ()
10+
{
11+
head=$1
12+
tree=$2
13+
for p in $(git rev-list --parents --max-count=1 $head 2>/devnull)
14+
do
15+
test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
16+
vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
17+
case "$vn" in
18+
gitgui-[0-9]*) echo $vn; break;;
19+
esac
20+
done
21+
}
22+
23+
# We may be a subproject, so try looking for the merge
24+
# commit that supplied this directory content if we are
25+
# not at the toplevel. We probably will always be the
26+
# second parent in the commit, but we shouldn't rely on
27+
# that fact.
28+
#
29+
# 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.
32+
33+
if prefix="$(git rev-parse --show-prefix 2>/dev/null)"
34+
test -n "$prefix" &&
35+
head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
36+
tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
37+
VN=$(tree_search $head $tree)
1238
case "$VN" in
13-
*$LF*) (exit 1) ;;
14-
v[0-9]*) : happy ;;
39+
gitgui-[0-9]*) : happy ;;
40+
*) (exit 1) ;;
1541
esac
1642
then
17-
VN=$(echo "$VN" | sed -e 's/-/./g');
43+
VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
44+
elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
45+
case "$VN" in
46+
gitgui-[0-9]*) : happy ;;
47+
*) (exit 1) ;;
48+
esac
49+
then
50+
VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
1851
elif test -f version
1952
then
2053
VN=$(cat version) || VN="$DEF_VER"
2154
else
2255
VN="$DEF_VER"
2356
fi
2457

25-
VN=$(expr "$VN" : v*'\(.*\)')
26-
2758
dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
2859
case "$dirty" in
2960
'')
@@ -34,13 +65,13 @@ esac
3465

3566
if test -r $GVF
3667
then
37-
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
68+
VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF)
3869
else
3970
VC=unset
4071
fi
4172
test "$VN" = "$VC" || {
42-
echo >&2 "GIT_VERSION = $VN"
43-
echo "GIT_VERSION = $VN" >$GVF
73+
echo >&2 "GITGUI_VERSION = $VN"
74+
echo "GITGUI_VERSION = $VN" >$GVF
4475
}
4576

4677

git-gui/Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,30 @@ ifndef SHELL_PATH
1212
SHELL_PATH = /bin/sh
1313
endif
1414

15-
gitexecdir := $(shell git --exec-path)
16-
INSTALL = install
15+
ifndef gitexecdir
16+
gitexecdir := $(shell git --exec-path)
17+
endif
18+
19+
ifndef INSTALL
20+
INSTALL = install
21+
endif
1722

1823
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1924
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
20-
2125
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
2226

2327
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
2428
rm -f $@ $@+
2529
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
26-
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
30+
-e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
2731
$@.sh >$@+
2832
chmod +x $@+
2933
mv $@+ $@
3034

3135
$(GITGUI_BUILT_INS): git-gui
3236
rm -f $@ && ln git-gui $@
3337

34-
# These can record GIT_VERSION
38+
# These can record GITGUI_VERSION
3539
$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE
3640

3741
all:: $(ALL_PROGRAMS)
@@ -41,8 +45,12 @@ install: all
4145
$(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
4246
$(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
4347

48+
dist-version:
49+
@mkdir -p $(TARDIR)
50+
@echo $(GITGUI_VERSION) > $(TARDIR)/version
51+
4452
clean::
4553
rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE
4654

47-
.PHONY: all install clean
55+
.PHONY: all install dist-version clean
4856
.PHONY: .FORCE-GIT-VERSION-FILE

git-gui/git-gui.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Tcl ignores the next line -*- tcl -*- \
33
exec wish "$0" -- "$@"
44

5-
set appvers {@@GIT_VERSION@@}
5+
set appvers {@@GITGUI_VERSION@@}
66
set copyright {
77
Copyright © 2006, 2007 Shawn Pearce, Paul Mackerras.
88

0 commit comments

Comments
 (0)