{"thread":{"id":"9974","subject":"[PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk","startedAt":"2007-09-22T05:04:47Z","lastAt":"2007-10-20T18:47:33Z","messageCount":3,"participants":["Shawn O. Pearce","Paul Mackerras","Mark Levedahl"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53786","messageId":"20070922050446.GA28467@spearce.org","threadId":"9974","inReplyTo":null,"subject":"[PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk","fromName":"Shawn O. Pearce","fromEmail":"shawn.o.pearce@bankofamerica.com","sentAt":"2007-09-22T05:04:47Z","receivedAt":"2007-09-22T05:04:47Z","isPatch":true,"sender":{"key":"shawn.o.pearce@bankofamerica.com","avatar":null},"body":"If TCLTK_PATH points at a pure Win32 Tcl/Tk implementation but you\nare running git (and thus gitk) from within Cygwin the value of\n$0 is a UNIX style Cygwin path which the native Tcl/Tk is unable\nto open and parse.  In such a situation we need to switch to using\nthe Windows style path by running $0 through cygpath.\n\nThis doesn't have a negative impact when using the Cygwin based\nTcl/Tk build as that is still close enough to a native Win32\napplication that it can read the Windows style path when sourcing\ngitk.  On any other platform we don't want gitk to do anything\ndifferent so we keep argv0=$0.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n Yes, I admit this is an odd patch.  I can certainly carry it in\n my own tree (I already carry some other patches) but I wonder if\n we shouldn't include it as some users may actually try to do this,\n just like I did.  Latest git-gui `master` already has changes to its\n Makefile and shell startup boilerplate to handle this weird case.\n\n Makefile |    6 +++++-\n gitk     |    3 ++-\n 2 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 0055eef..4fc6eb3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -386,6 +386,7 @@ EXTLIBS =\n #\n # Platform specific tweaks\n #\n+gitk_argv0 := $$0\n \n # We choose to avoid \"if .. else if .. else .. endif endif\"\n # because maintaining the nesting to match is a pain.  If\n@@ -443,6 +444,7 @@ ifeq ($(uname_O),Cygwin)\n \tNO_MMAP = YesPlease\n \tNO_IPV6 = YesPlease\n \tX = .exe\n+\tgitk_argv0 := `cygpath --windows --absolute \"$(gitk_argv0)\"`\n endif\n ifeq ($(uname_S),FreeBSD)\n \tNEEDS_LIBICONV = YesPlease\n@@ -763,7 +765,9 @@ strip: $(PROGRAMS) git$X\n \n gitk-wish: gitk GIT-GUI-VARS\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n-\tsed -e '1,3s|^exec .* \"$$0\"|exec $(subst |,'\\|',$(TCLTK_PATH_SQ)) \"$$0\"|' <gitk >$@+ && \\\n+\tsed -e '1,30s|^argv0=$$0|argv0=$(gitk_argv0)|' \\\n+\t    -e '1,4s|^exec .* \"$$argv0\"|exec $(subst |,'\\|',$(TCLTK_PATH_SQ)) \"$$argv0\"|' \\\n+\t    <gitk >$@+ && \\\n \tchmod +x $@+ && \\\n \tmv -f $@+ $@\n \ndiff --git a/gitk b/gitk\nindex 300fdce..2366911 100755\n--- a/gitk\n+++ b/gitk\n@@ -1,6 +1,7 @@\n #!/bin/sh\n # Tcl ignores the next line -*- tcl -*- \\\n-exec wish \"$0\" -- \"$@\"\n+argv0=$0; \\\n+exec wish \"$argv0\" -- \"$@\"\n \n # Copyright (C) 2005-2006 Paul Mackerras.  All rights reserved.\n # This program is free software; it may be used, copied, modified\n-- \n1.5.3.2.1036.gcd14a\n"},{"id":"56693","messageId":"18201.59649.800748.780690@cargo.ozlabs.ibm.com","threadId":"9974","inReplyTo":"20070922050446.GA28467@spearce.org","subject":"Re: [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-10-20T11:39:45Z","receivedAt":"2007-10-20T11:39:45Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Shawn O. Pearce writes:\n\n>  Yes, I admit this is an odd patch.  I can certainly carry it in\n>  my own tree (I already carry some other patches) but I wonder if\n>  we shouldn't include it as some users may actually try to do this,\n>  just like I did.  Latest git-gui `master` already has changes to its\n>  Makefile and shell startup boilerplate to handle this weird case.\n\nWhy do you need to change gitk itself?  If you're going to modify it\nwith sed, why can't you change the $0 on the 3rd line to the installed\npath of the gitk script?\n\nPaul.\n"},{"id":"56718","messageId":"471A4D45.1040107@gmail.com","threadId":"9974","inReplyTo":"18201.59649.800748.780690@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] Allow gitk to start on Cygwin with native Win32 Tcl/Tk","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2007-10-20T18:47:33Z","receivedAt":"2007-10-20T18:47:33Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Paul Mackerras wrote:\n> Shawn O. Pearce writes:\n>\n>   \n>>  Yes, I admit this is an odd patch.  I can certainly carry it in\n>>  my own tree (I already carry some other patches) but I wonder if\n>>  we shouldn't include it as some users may actually try to do this,\n>>  just like I did.  Latest git-gui `master` already has changes to its\n>>  Makefile and shell startup boilerplate to handle this weird case.\n>>     \n>\n> Why do you need to change gitk itself?  If you're going to modify it\n> with sed, why can't you change the $0 on the 3rd line to the installed\n> path of the gitk script?\n>\n>   \nWhile gitk is most likely installed as /usr/bin/gitk in Cygwin's \nfilespace, that could resolve to anything in the Windows file system. It \nmight be c:\\cygwin\\usr\\bin\\gitk, but could also be \"d:\\Documents and \nSettings\\Bill\\Programs\\cygwin\\usr\\bin\\gitk\" depending upon who installed \nit and with what options. Both are seen as /usr/bin/gitk by Cygwin. \nThus, Shawn is correct in using cygpath to resolve the name.\n\nAlso, as Cygwin's tcl/tk package is bound to the port of the insight \ndebugger to Cygwin, and that project is stuck for years on 8.4.1, this \npatch (or something like it) may be the only way to allow gitk to access \na more recent version on Cygwin in the foreseeable future. So, I think \nthis is a good idea.\n\nMark\n"}]}