Subject: Re: git-gui not working in a non-default Cygwin installation.

From: "Shawn O. Pearce" <[email-masked]>
Date: Fri, 22 Feb 2008 01:46:42 -0500

"Shawn O. Pearce" <[email-masked]> wrote:
> Jurko Gospodneti <[email-masked]> wrote:
> > 
> >   One of these is that it seems that with the latest git release the 
> > git-gui script changed and started hardcoding some absolute paths in it 
> > during its build (git-gui/Makefile replaces @@GITGUI_SCRIPT@@ with a 
> > hardcoded path). However, this causes the prebuilt Cygwin package to not 
> > work in case Cygwin is not installed in its default location at 
> > C:\Cygwin (e.g. D:\Cygwin or C:\Program Files\Cygwin).
...
> I'll have to figure out on Cygwin if the $TCL_PATH I'm using is
> able to resolve Cygwin absolute paths or not, and then build the
> script accordingly.  Fun.
> 
> I'll try to work up a Makefile patch in the next few days and get
> it into a gitgui-0.9.3 maint release, which will probably roll up
> into git 1.5.4.3.

So it took me longer than "next few days" but there is now a
two patch series in my maint branch that resolves this issue.
If git-gui is built with a Tcl/Tk that understands Cygwin path
translations it keeps the library path in POSIX format, but if it
builds with a Tcl/Tk that is a native Win32 binary then it uses
cygpath to translate the path.

Although now that I think about it the relative path case should
be able to be enabled again in the native Win32 codepath, as we
only ran into problems with it on Cygwin.

Anyway, it will be in gitgui-0.9.3, which I expect will be bundled
into git 1.5.4.3, which Junio has stated may be next week.

--8<--
diff --git a/Makefile b/Makefile
index 081d755..01e0a46 100644
--- a/Makefile
+++ b/Makefile
@@ -92,8 +92,12 @@ ifndef V
 	REMOVE_F1 = && echo '   ' REMOVE `basename "$$dst"` && $(RM_RF) "$$dst"
 endif
 
-TCL_PATH   ?= tclsh
 TCLTK_PATH ?= wish
+ifeq (./,$(dir $(TCLTK_PATH)))
+	TCL_PATH ?= $(subst wish,tclsh,$(TCLTK_PATH))
+else
+	TCL_PATH ?= $(dir $(TCLTK_PATH))$(notdir $(subst wish,tclsh,$(TCLTK_PATH)))
+endif
 
 ifeq ($(uname_S),Darwin)
 	TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
@@ -127,7 +131,17 @@ GITGUI_MACOSXAPP :=
 
 ifeq ($(uname_O),Cygwin)
 	GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
-	gg_libdir_sed_in := $(shell cygpath --windows --absolute "$(gg_libdir)")
+
+	# Is this a Cygwin Tcl/Tk binary?  If so it knows how to do
+	# POSIX path translation just like cygpath does and we must
+	# keep libdir in POSIX format so Cygwin packages of git-gui
+	# work no matter where the user installs them.
+	#
+	ifeq ($(shell echo 'puts [file normalize /]' | '$(TCL_PATH_SQ)'),$(shell cygpath --mixed --absolute /))
+		gg_libdir_sed_in := $(gg_libdir)
+	else
+		gg_libdir_sed_in := $(shell cygpath --windows --absolute "$(gg_libdir)")
+	endif
 else
 	ifeq ($(exedir),$(gg_libdir))
 		GITGUI_RELATIVE := 1

-- 
Shawn.