From 663e7cf81d970d8320147d4d58dce37aaebfb09b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 15:37:50 -0500 Subject: [PATCH 1/6] git-gui: Allow gitexecdir, INSTALL to be set by the caller. When used as a subproject within git.git our Makefile must honor the gitexecdir which git.git's Makefile is passing down to us, ensuring that we install our executables into the libexec chosen by the end-user or packager. Signed-off-by: Shawn O. Pearce --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8fade69127..f1668bbd18 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,16 @@ ifndef SHELL_PATH SHELL_PATH = /bin/sh endif -gitexecdir := $(shell git --exec-path) -INSTALL = install +ifndef gitexecdir + gitexecdir := $(shell git --exec-path) +endif + +ifndef INSTALL + INSTALL = install +endif DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) - SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh From 7e81d4eead48c189d52406379150b09fd4096987 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 16:12:04 -0500 Subject: [PATCH 2/6] git-gui: Rename GIT_VERSION to GITGUI_VERSION. Now that the decision has been made to treat git-gui as a subproject, rather than merging it directly into git, we should use a different substitution for our version value to avoid any possible confusion. Signed-off-by: Shawn O. Pearce --- GIT-VERSION-GEN | 6 +++--- Makefile | 4 ++-- git-gui.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 79f1c527ff..79558f39cf 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -34,13 +34,13 @@ esac if test -r $GVF then - VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) + VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF) else VC=unset fi test "$VN" = "$VC" || { - echo >&2 "GIT_VERSION = $VN" - echo "GIT_VERSION = $VN" >$GVF + echo >&2 "GITGUI_VERSION = $VN" + echo "GITGUI_VERSION = $VN" >$GVF } diff --git a/Makefile b/Makefile index f1668bbd18..71ae7edb48 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh rm -f $@ $@+ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ - -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ + -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \ $@.sh >$@+ chmod +x $@+ mv $@+ $@ @@ -35,7 +35,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh $(GITGUI_BUILT_INS): git-gui rm -f $@ && ln git-gui $@ -# These can record GIT_VERSION +# These can record GITGUI_VERSION $(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE all:: $(ALL_PROGRAMS) diff --git a/git-gui.sh b/git-gui.sh index ea16be43ac..f5010dd47a 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2,7 +2,7 @@ # Tcl ignores the next line -*- tcl -*- \ exec wish "$0" -- "$@" -set appvers {@@GIT_VERSION@@} +set appvers {@@GITGUI_VERSION@@} set copyright { Copyright © 2006, 2007 Shawn Pearce, Paul Mackerras. From 5d643cd3cebf5eab44d99c5c7e54a1dbef28cba6 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 16:14:44 -0500 Subject: [PATCH 3/6] git-gui: Generate a version file on demand. Because git-gui is being shipped as a subproject of the main Git project and will often have a different lifecycle than the main Git project, we should ship our own version number in the release tarball rather than relying on the main Git version file. Git's master Makefile will invoke our own with the target dist-version, asking us to save off our GITGUI_VERSION value into our own version file, so that our GIT-VERSION-GEN script can recover it at build time. Signed-off-by: Shawn O. Pearce --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 71ae7edb48..fd82d9d16d 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,12 @@ install: all $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)' $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;) +dist-version: + @mkdir -p $(TARDIR) + @echo $(GITGUI_VERSION) > $(TARDIR)/version + clean:: rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE -.PHONY: all install clean +.PHONY: all install dist-version clean .PHONY: .FORCE-GIT-VERSION-FILE From 6a6459bc8f1aa9e83b5b46f7c40454891bf5e92a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 16:38:29 -0500 Subject: [PATCH 4/6] git-gui: Handle gitgui tags in version gen. I've decided to use gitgui-0.5 as the format for tags in the git-gui repository. The prefix of gitgui was chosen here to make its namespace different from the namespace used by git itself, allowing developers to pull both tag namespaces into the same repository. Signed-off-by: Shawn O. Pearce --- GIT-VERSION-GEN | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 79558f39cf..d3087489c5 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v0.5.GIT +DEF_VER=0.5.GIT LF=' ' @@ -11,10 +11,10 @@ LF=' if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; - v[0-9]*) : happy ;; + gitgui-[0-9]*) : happy ;; esac then - VN=$(echo "$VN" | sed -e 's/-/./g'); + VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g'); elif test -f version then VN=$(cat version) || VN="$DEF_VER" @@ -22,8 +22,6 @@ else VN="$DEF_VER" fi -VN=$(expr "$VN" : v*'\(.*\)') - dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty= case "$dirty" in '') From 07d082bf5b4bc353648ffd207fe2fbd9e57e4386 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 17:05:10 -0500 Subject: [PATCH 5/6] git-gui: Guess our version accurately as a subproject. When we are included as a subproject, such as how git.git carries us, we want to retain our own version number and not the version number assigned by git.git's own tags. Consequently we need to locate the correct tag which applies to our tree content and its commit lineage. Signed-off-by: Shawn O. Pearce --- GIT-VERSION-GEN | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index d3087489c5..9fc80a656c 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -6,12 +6,45 @@ DEF_VER=0.5.GIT LF=' ' -# First try git-describe, then see if there is a version file -# (included in release tarballs), then default -if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && +tree_search () +{ + head=$1 + tree=$2 + for p in $(git rev-list --parents --max-count=1 $head 2>/devnull) + do + test $tree = $(git rev-parse $p^{tree} 2>/dev/null) && + vn=$(git describe --abbrev=4 $p 2>/dev/null) && + case "$vn" in + gitgui-[0-9]*) echo $vn; break;; + esac + done +} + +# We may be a subproject, so try looking for the merge +# commit that supplied this directory content if we are +# not at the toplevel. We probably will always be the +# second parent in the commit, but we shouldn't rely on +# that fact. +# +# If we are at the toplevel or the merge assumption fails +# try looking for a gitgui-* tag, or fallback onto the +# distributed version file. + +if prefix="$(git rev-parse --show-prefix 2>/dev/null)" + test -n "$prefix" && + head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) && + tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) && + VN=$(tree_search $head $tree) + case "$VN" in + gitgui-[0-9]*) : happy ;; + *) (exit 1) ;; + esac +then + VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g'); +elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && case "$VN" in - *$LF*) (exit 1) ;; gitgui-[0-9]*) : happy ;; + *) (exit 1) ;; esac then VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g'); From fdf6cfc4266d1e88e74c09e9166fa0b5c9ad29cb Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 12 Feb 2007 17:45:21 -0500 Subject: [PATCH 6/6] git-gui: Change base version to 0.6. This is the start of the 0.6 series of git-gui. I'm calling it 0.6 (rather than any other value) as I already had a private tag on one system based on 0.5, and that tag is quite a bit behind this version. Signed-off-by: Shawn O. Pearce --- GIT-VERSION-GEN | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 9fc80a656c..8fac8cb410 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=0.5.GIT +DEF_VER=0.6.GITGUI LF=' '