From: Shawn O. Pearce Date: Fri, 21 Sep 2007 01:25:34 +0000 (-0400) Subject: git-gui: Support native Win32 Tcl/Tk under Cygwin X-Git-Tag: gitgui-0.9.0~65 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2f7c9a7f310dae23989b4acd49514abc58334e5b;p=git.git git-gui: Support native Win32 Tcl/Tk under Cygwin Cygwin has been stuck on the 8.4.1 version of Tcl/Tk for quite some time, even though the main Tcl/Tk distribution is already shipping an 8.4.15. The problem is Tcl/Tk no longer supports Cygwin so apparently building the package for Cygwin is now a non-trivial task. Its actually quite easy to build the native Win32 version of Tcl/Tk by compiling with the -mno-cygwin flag passed to GCC but this means we lose all of the "fancy" Cygwin path translations that the Tcl library was doing for us. This is particularly an issue when we are trying to start git-gui through the git wrapper as the git wrapper is passing off a Cygwin path for $0 and Tcl cannot find the startup script or the library directory. We now use `cygpath -m -a` to convert the UNIX style paths to Windows style paths in our startup script if we are building on Cygwin. Doing so allows either the Cygwin-ized Tcl/Tk 8.4.1 that comes with Cygwin or a manually built 8.4.15 that is running the pure Win32 implementation to read our script. Signed-off-by: Shawn O. Pearce --- diff --git a/Makefile b/Makefile index 8c87d836d..6236dd6ad 100644 --- a/Makefile +++ b/Makefile @@ -92,27 +92,35 @@ 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))) +exedir = $(dir $(gitexecdir))share/git-gui/lib -exedir = $(dir $(gitexecdir))share/git-gui/lib -exedir_SQ = $(subst ','\'',$(exedir)) +GITGUI_SCRIPT := $$0 +GITGUI_RELATIVE := + +ifeq ($(exedir),$(gg_libdir)) + GITGUI_RELATIVE := 1 +endif + +ifeq ($(uname_O),Cygwin) + GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"` + ifeq ($(GITGUI_RELATIVE),) + gg_libdir := $(shell cygpath --windows --absolute "$(gg_libdir)") + endif +endif $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh $(QUIET_GEN)rm -f $@ $@+ && \ - GITGUI_RELATIVE= && \ - if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \ - if test "$(uname_O)" = Cygwin; \ - then GITGUI_RELATIVE= ; \ - else GITGUI_RELATIVE=1; \ - fi; \ - fi && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ - -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \ + -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_SQ)|' \ + -e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \ + -e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-gui.sh b/git-gui.sh index db1507cde..5a465e1c7 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -6,7 +6,8 @@ echo 'git-gui version @@GITGUI_VERSION@@'; \ exit; \ fi; \ - exec wish "$0" -- "$@" + argv0=$0; \ + exec wish "$argv0" -- "$@" set appvers {@@GITGUI_VERSION@@} set copyright { @@ -740,7 +741,7 @@ if {[catch { exit 1 } if {![file isdirectory $_gitdir] && [is_Cygwin]} { - catch {set _gitdir [exec cygpath --unix $_gitdir]} + catch {set _gitdir [exec cygpath --windows $_gitdir]} } if {![file isdirectory $_gitdir]} { catch {wm withdraw .}