Skip to content

Commit 4e817d1

Browse files
committed
git-gui: Don't require $DISPLAY just to get --version
Junio asked that we don't force the user to have a valid X11 server configured in $DISPLAY just to obtain the output of `git gui version`. This makes sense, the user may be an automated tool that is running without an X server available to it, such as a build script or other sort of package management system. Or it might just be a user working in a non-GUI environment and wondering "what version of git-gui do I have installed?". Tcl has a lot of warts, but one of its better ones is that a comment can be continued to the next line by escaping the LF that would have ended the comment using a backslash-LF sequence. In the past we have used this trick to escape away the 'exec wish' that is actually a Bourne shell script and keep Tcl from executing it. I'm using that feature here to comment out the Bourne shell script and hide it from the Tcl engine. Except now our Bourne shell script is a few lines long and checks to see if it should print the version, or not. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent fb626dc commit 4e817d1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
6868
fi; \
6969
fi && \
7070
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
71-
-e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
71+
-e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
7272
-e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
7373
-e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
7474
-e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \

git-gui.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
# Tcl ignores the next line -*- tcl -*- \
3-
exec wish "$0" -- "$@"
3+
if test "z$*" = zversion \
4+
|| test "z$*" = z--version; \
5+
then \
6+
echo 'git-gui version @@GITGUI_VERSION@@'; \
7+
exit; \
8+
fi; \
9+
exec wish "$0" -- "$@"
410

511
set appvers {@@GITGUI_VERSION@@}
612
set copyright {
@@ -271,11 +277,6 @@ proc tk_optionMenu {w varName args} {
271277
##
272278
## version check
273279

274-
if {{--version} eq $argv || {version} eq $argv} {
275-
puts "git-gui version $appvers"
276-
exit
277-
}
278-
279280
set req_maj 1
280281
set req_min 5
281282

0 commit comments

Comments
 (0)