git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk
@ 2007-09-22  5:04 Shawn O. Pearce
  2007-10-20 11:39 ` Paul Mackerras
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-09-22  5:04 UTC (permalink / raw)
  To: Junio C Hamano, Paul Mackerras; +Cc: git

If TCLTK_PATH points at a pure Win32 Tcl/Tk implementation but you
are running git (and thus gitk) from within Cygwin the value of
$0 is a UNIX style Cygwin path which the native Tcl/Tk is unable
to open and parse.  In such a situation we need to switch to using
the Windows style path by running $0 through cygpath.

This doesn't have a negative impact when using the Cygwin based
Tcl/Tk build as that is still close enough to a native Win32
application that it can read the Windows style path when sourcing
gitk.  On any other platform we don't want gitk to do anything
different so we keep argv0=$0.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---

 Yes, I admit this is an odd patch.  I can certainly carry it in
 my own tree (I already carry some other patches) but I wonder if
 we shouldn't include it as some users may actually try to do this,
 just like I did.  Latest git-gui `master` already has changes to its
 Makefile and shell startup boilerplate to handle this weird case.

 Makefile |    6 +++++-
 gitk     |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0055eef..4fc6eb3 100644
--- a/Makefile
+++ b/Makefile
@@ -386,6 +386,7 @@ EXTLIBS =
 #
 # Platform specific tweaks
 #
+gitk_argv0 := $$0
 
 # We choose to avoid "if .. else if .. else .. endif endif"
 # because maintaining the nesting to match is a pain.  If
@@ -443,6 +444,7 @@ ifeq ($(uname_O),Cygwin)
 	NO_MMAP = YesPlease
 	NO_IPV6 = YesPlease
 	X = .exe
+	gitk_argv0 := `cygpath --windows --absolute "$(gitk_argv0)"`
 endif
 ifeq ($(uname_S),FreeBSD)
 	NEEDS_LIBICONV = YesPlease
@@ -763,7 +765,9 @@ strip: $(PROGRAMS) git$X
 
 gitk-wish: gitk GIT-GUI-VARS
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
+	sed -e '1,30s|^argv0=$$0|argv0=$(gitk_argv0)|' \
+	    -e '1,4s|^exec .* "$$argv0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$argv0"|' \
+	    <gitk >$@+ && \
 	chmod +x $@+ && \
 	mv -f $@+ $@
 
diff --git a/gitk b/gitk
index 300fdce..2366911 100755
--- a/gitk
+++ b/gitk
@@ -1,6 +1,7 @@
 #!/bin/sh
 # Tcl ignores the next line -*- tcl -*- \
-exec wish "$0" -- "$@"
+argv0=$0; \
+exec wish "$argv0" -- "$@"
 
 # Copyright (C) 2005-2006 Paul Mackerras.  All rights reserved.
 # This program is free software; it may be used, copied, modified
-- 
1.5.3.2.1036.gcd14a

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk
  2007-09-22  5:04 [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk Shawn O. Pearce
@ 2007-10-20 11:39 ` Paul Mackerras
  2007-10-20 18:47   ` Mark Levedahl
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2007-10-20 11:39 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

Shawn O. Pearce writes:

>  Yes, I admit this is an odd patch.  I can certainly carry it in
>  my own tree (I already carry some other patches) but I wonder if
>  we shouldn't include it as some users may actually try to do this,
>  just like I did.  Latest git-gui `master` already has changes to its
>  Makefile and shell startup boilerplate to handle this weird case.

Why do you need to change gitk itself?  If you're going to modify it
with sed, why can't you change the $0 on the 3rd line to the installed
path of the gitk script?

Paul.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk
  2007-10-20 11:39 ` Paul Mackerras
@ 2007-10-20 18:47   ` Mark Levedahl
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Levedahl @ 2007-10-20 18:47 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Shawn O. Pearce, Junio C Hamano, git

Paul Mackerras wrote:
> Shawn O. Pearce writes:
>
>   
>>  Yes, I admit this is an odd patch.  I can certainly carry it in
>>  my own tree (I already carry some other patches) but I wonder if
>>  we shouldn't include it as some users may actually try to do this,
>>  just like I did.  Latest git-gui `master` already has changes to its
>>  Makefile and shell startup boilerplate to handle this weird case.
>>     
>
> Why do you need to change gitk itself?  If you're going to modify it
> with sed, why can't you change the $0 on the 3rd line to the installed
> path of the gitk script?
>
>   
While gitk is most likely installed as /usr/bin/gitk in Cygwin's 
filespace, that could resolve to anything in the Windows file system. It 
might be c:\cygwin\usr\bin\gitk, but could also be "d:\Documents and 
Settings\Bill\Programs\cygwin\usr\bin\gitk" depending upon who installed 
it and with what options. Both are seen as /usr/bin/gitk by Cygwin. 
Thus, Shawn is correct in using cygpath to resolve the name.

Also, as Cygwin's tcl/tk package is bound to the port of the insight 
debugger to Cygwin, and that project is stuck for years on 8.4.1, this 
patch (or something like it) may be the only way to allow gitk to access 
a more recent version on Cygwin in the foreseeable future. So, I think 
this is a good idea.

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-20 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-22  5:04 [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk Shawn O. Pearce
2007-10-20 11:39 ` Paul Mackerras
2007-10-20 18:47   ` Mark Levedahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).