diff --git a/Makefile b/Makefile index 8c87d836d83..6236dd6ad39 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 db1507cdece..5a465e1c7dd 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 .}