Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions git-gui/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ git-gui.sh encoding=UTF-8
/po/*.po encoding=UTF-8
/GIT-VERSION-GEN eol=lf
Makefile whitespace=!indent,trail,space
meson.build whitespace=space
2 changes: 1 addition & 1 deletion git-gui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config.mak
Git Gui.app*
git-gui.tcl
GIT-GUI-BUILD-OPTIONS
GIT-VERSION-FILE
GIT-GUI-VARS
git-gui
lib/tclIndex
7 changes: 7 additions & 0 deletions git-gui/GIT-GUI-BUILD-OPTIONS.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GITGUI_GITEXECDIR=@GITGUI_GITEXECDIR@
GITGUI_LIBDIR=@GITGUI_LIBDIR@
GITGUI_RELATIVE=@GITGUI_RELATIVE@
SHELL_PATH=@SHELL_PATH@
TCLTK_PATH=@TCLTK_PATH@
TCL_PATH=@TCL_PATH@
TKEXECUTABLE=@TKEXECUTABLE@
44 changes: 29 additions & 15 deletions git-gui/GIT-VERSION-GEN
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#!/bin/sh

GVF=GIT-VERSION-FILE
DEF_VER=0.21.GITGUI

LF='
'

if test "$#" -ne 2
then
echo >&2 "usage: $0 <SOURCE_DIR> <OUTPUT>"
exit 1
fi

SOURCE_DIR="$1"
OUTPUT="$2"

# Protect us from reading Git version information outside of the Git directory
# in case it is not a repository itself, but embedded in an unrelated
# repository.
GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.."
export GIT_CEILING_DIRECTORIES

tree_search ()
{
head=$1
tree=$2
for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)
for p in $(git -C "$SOURCE_DIR" rev-list --parents --max-count=1 $head 2>/dev/null)
do
test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
test $tree = $(git -C "$SOURCE_DIR" rev-parse $p^{tree} 2>/dev/null) &&
vn=$(git -C "$SOURCE_DIR" describe --abbrev=4 $p 2>/dev/null) &&
case "$vn" in
gitgui-[0-9]*) echo $vn; break;;
esac
Expand All @@ -34,22 +48,22 @@ tree_search ()
# If we are at the toplevel or the merge assumption fails
# try looking for a gitgui-* tag.

if test -f version &&
VN=$(cat version)
if test -f "$SOURCE_DIR"/version &&
VN=$(cat "$SOURCE_DIR"/version)
then
: happy
elif prefix="$(git rev-parse --show-prefix 2>/dev/null)"
elif prefix="$(git -C "$SOURCE_DIR" 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) &&
head=$(git -C "$SOURCE_DIR" rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
tree=$(git -C "$SOURCE_DIR" 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) &&
elif VN=$(git -C "$SOURCE_DIR" describe --abbrev=4 HEAD 2>/dev/null) &&
case "$VN" in
gitgui-[0-9]*) : happy ;;
*) (exit 1) ;;
Expand All @@ -60,21 +74,21 @@ else
VN="$DEF_VER"
fi

dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
dirty=$(git -C "$SOURCE_DIR" diff-index --name-only HEAD 2>/dev/null) || dirty=
case "$dirty" in
'')
;;
*)
VN="$VN-dirty" ;;
esac

if test -r $GVF
if test -r "$OUTPUT"
then
VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF)
VC=$(sed -e 's/^GITGUI_VERSION=//' <"$OUTPUT")
else
VC=unset
fi
test "$VN" = "$VC" || {
echo >&2 "GITGUI_VERSION = $VN"
echo "GITGUI_VERSION = $VN" >$GVF
echo >&2 "GITGUI_VERSION=$VN"
echo "GITGUI_VERSION=$VN" >"$OUTPUT"
}
115 changes: 29 additions & 86 deletions git-gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ all::
#

GIT-VERSION-FILE: FORCE
@$(SHELL_PATH) ./GIT-VERSION-GEN
ifneq ($(MAKECMDGOALS),clean)
-include GIT-VERSION-FILE
endif
@$(SHELL_PATH) ./GIT-VERSION-GEN . $@

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
Expand Down Expand Up @@ -76,7 +73,6 @@ ifndef V
QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
QUIET_MSGFMT0 = $(QUIET)printf ' MSGFMT %12s ' $@ && v=`
QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages*//g'
QUIET_2DEVNULL = 2>/dev/null

INSTALL_D0 = dir=
INSTALL_D1 = && echo ' ' DEST $$dir && $(INSTALL) -d -m 755 "$$dir"
Expand Down Expand Up @@ -114,7 +110,8 @@ ifeq ($(uname_S),Darwin)
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
endif
endif
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
TKEXECUTABLE = $(TKFRAMEWORK)/Contents/MacOS/$(shell basename "$(TKFRAMEWORK)" .app)
TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE))
endif

ifeq ($(findstring $(firstword -$(MAKEFLAGS)),s),s)
Expand All @@ -128,21 +125,17 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
TCLTK_PATH_SED = $(subst ','\'',$(subst \,\\,$(TCLTK_PATH)))

gg_libdir ?= $(sharedir)/git-gui/lib
libdir_SQ = $(subst ','\'',$(gg_libdir))
libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir_sed_in)))
exedir = $(dir $(gitexecdir))share/git-gui/lib

GITGUI_SCRIPT := $$0
GITGUI_RELATIVE :=
GITGUI_MACOSXAPP :=

ifeq ($(exedir),$(gg_libdir))
GITGUI_RELATIVE := 1
endif
gg_libdir_sed_in := $(gg_libdir)
ifeq ($(uname_S),Darwin)
ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
GITGUI_MACOSXAPP := YesPlease
Expand All @@ -159,41 +152,15 @@ endif
ifdef GITGUI_MACOSXAPP
GITGUI_MAIN := git-gui.tcl

git-gui: GIT-VERSION-FILE GIT-GUI-VARS
$(QUIET_GEN)rm -f $@ $@+ && \
echo '#!$(SHELL_PATH_SQ)' >$@+ && \
echo 'if test "z$$*" = zversion ||' >>$@+ && \
echo ' test "z$$*" = z--version' >>$@+ && \
echo then >>$@+ && \
echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
echo else >>$@+ && \
echo ' libdir="$${GIT_GUI_LIB_DIR:-$(libdir_SQ)}"' >>$@+ && \
echo ' 'exec \"'$$libdir/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\" \
'"$$0" "$$@"' >>$@+ && \
echo fi >>$@+ && \
chmod +x $@+ && \
mv $@+ $@

Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
git-gui: generate-macos-wrapper.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
$(QUIET_GEN)$(SHELL_PATH) generate-macos-wrapper.sh "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE

Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
macosx/Info.plist \
macosx/git-gui.icns \
macosx/AppMain.tcl \
$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
$(QUIET_GEN)rm -rf '$@' '$@'+ && \
mkdir -p '$@'+/Contents/MacOS && \
mkdir -p '$@'+/Contents/Resources/Scripts && \
cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
'$@'+/Contents/MacOS && \
cp macosx/git-gui.icns '$@'+/Contents/Resources && \
sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
macosx/Info.plist \
>'$@'+/Contents/Info.plist && \
sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
-e 's|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
macosx/AppMain.tcl \
>'$@'+/Contents/Resources/Scripts/AppMain.tcl && \
mv '$@'+ '$@'
$(TKEXECUTABLE)
$(QUIET_GEN)$(SHELL_PATH) generate-macos-app.sh . "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
endif

ifdef GITGUI_WINDOWS_WRAPPER
Expand All @@ -203,18 +170,8 @@ git-gui: windows/git-gui.sh
cp $< $@
endif

$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
-e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
-e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
-e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
-e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
git-gui.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@
$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
$(QUIET_GEN)$(SHELL_PATH) generate-git-gui.sh "$<" "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE

XGETTEXT ?= xgettext
ifdef NO_MSGFMT
Expand All @@ -239,35 +196,21 @@ update-po:: $(PO_TEMPLATE)
$(ALL_MSGFILES): %.msg : %.po
$(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< $(QUIET_MSGFMT1)

lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
$(QUIET_INDEX)if echo \
$(foreach p,$(PRELOAD_FILES),source $p\;) \
auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
else \
echo >&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
rm -f $@ ; \
echo '# Autogenerated by git-gui Makefile' >$@ && \
echo >>$@ && \
$(foreach p,$(PRELOAD_FILES) $(sort $(ALL_LIBFILES)),echo '$(subst lib/,,$p)' >>$@ &&) \
echo >>$@ ; \
fi

TRACK_VARS = \
$(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
$(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
$(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
$(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
$(subst ','\'',gg_libdir='$(libdir_SQ)') \
GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
#end TRACK_VARS

GIT-GUI-VARS: FORCE
@VARS='$(TRACK_VARS)'; \
if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
echo >&2 " * new locations or Tcl/Tk interpreter"; \
echo >$@ "$$VARS"; \
fi
lib/tclIndex: $(ALL_LIBFILES) generate-tclindex.sh GIT-GUI-BUILD-OPTIONS
$(QUIET_INDEX)$(SHELL_PATH) generate-tclindex.sh . ./GIT-GUI-BUILD-OPTIONS $(ALL_LIBFILES)

GIT-GUI-BUILD-OPTIONS: FORCE
@sed \
-e 's|@GITGUI_GITEXECDIR@|$(gitexecdir_SQ)|' \
-e 's|@GITGUI_LIBDIR@|$(libdir_SQ)|' \
-e 's|@GITGUI_RELATIVE@|$(GITGUI_RELATIVE)|' \
-e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-e 's|@TCLTK_PATH@|$(TCLTK_PATH_SQ)|' \
-e 's|@TCL_PATH@|$(TCL_PATH_SQ)|' \
-e 's|@TKEXECUTABLE@|$(TKEXECUTABLE_SQ)|' \
$@.in >$@+
@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi

ifdef GITGUI_MACOSXAPP
all:: git-gui Git\ Gui.app
Expand Down Expand Up @@ -317,13 +260,13 @@ endif
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
$(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)

dist-version:
dist-version: GIT-VERSION-FILE
@mkdir -p $(TARDIR)
@echo $(GITGUI_VERSION) > $(TARDIR)/version
@sed 's|^GITGUI_VERSION=||' <GIT-VERSION-FILE >$(TARDIR)/version

clean::
$(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE)
$(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS
$(RM_RF) GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
ifdef GITGUI_MACOSXAPP
$(RM_RF) 'Git Gui.app'* git-gui
endif
Expand Down
29 changes: 29 additions & 0 deletions git-gui/generate-git-gui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

set -e

if test "$#" -ne 4
then
echo >&2 "usage: $0 <INPUT> <OUTPUT> <BUILD_OPTIONS> <VERSION_FILE>"
exit 1
fi

INPUT="$1"
OUTPUT="$2"
BUILD_OPTIONS="$3"
VERSION_FILE="$4"

. "${BUILD_OPTIONS}"
. "${VERSION_FILE}"

rm -f "$OUTPUT" "$OUTPUT+"
sed \
-e "1s|#!.*/sh|#!$SHELL_PATH|" \
-e "s|@@SHELL_PATH@@|$SHELL_PATH|" \
-e "1,30s|^ exec wish | exec '$TCLTK_PATH' |" \
-e "s|@@GITGUI_VERSION@@|$GITGUI_VERSION|g" \
-e "s|@@GITGUI_RELATIVE@@|$GITGUI_RELATIVE|" \
-e "${GITGUI_RELATIVE}s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
"$INPUT" >"$OUTPUT"+
chmod +x "$OUTPUT"+
mv "$OUTPUT"+ "$OUTPUT"
30 changes: 30 additions & 0 deletions git-gui/generate-macos-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -e

SOURCE_DIR="$1"
OUTPUT="$2"
BUILD_OPTIONS="$3"
VERSION_FILE="$4"

. "$BUILD_OPTIONS"
. "$VERSION_FILE"

rm -rf "$OUTPUT" "$OUTPUT+"

mkdir -p "$OUTPUT+/Contents/MacOS"
mkdir -p "$OUTPUT+/Contents/Resources/Scripts"

cp "$TKEXECUTABLE" "$OUTPUT+/Contents/MacOS"
cp "$SOURCE_DIR/macosx/git-gui.icns" "$OUTPUT+/Contents/Resources"
sed \
-e "s/@@GITGUI_VERSION@@/$GITGUI_VERSION/g" \
-e "s/@@GITGUI_TKEXECUTABLE@@/$(basename "$TKEXECUTABLE")/g" \
"$SOURCE_DIR/macosx/Info.plist" \
>"$OUTPUT+/Contents/Info.plist"
sed \
-e "s|@@gitexecdir@@|$GITGUI_GITEXECDIR|" \
-e "s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
"$SOURCE_DIR/macosx/AppMain.tcl" \
>"$OUTPUT+/Contents/Resources/Scripts/AppMain.tcl"
mv "$OUTPUT+" "$OUTPUT"
Loading