[PATCH] git-gui: add mingw specific startup wrapper

Subsystems: the rest

DORMANTno replies

11 messages, 3 authors, 2016-06-15 · open the first message on its own page

[PATCH] git-gui: add mingw specific startup wrapper

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.

The wrapper script also accepts an optional command line
switch '--working-dir <dir>' and changes to <dir> before
launching the actual git-gui. This is required to implement
the "Git Gui Here" Explorer shell extension.

Signed-off-by: Steffen Prohaska <redacted>
---
 git-gui/Makefile           |   14 ++++++++++++++
 git-gui/windows/git-gui.sh |   16 ++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 git-gui/windows/git-gui.sh

diff --git a/git-gui/Makefile b/git-gui/Makefile
index c805450..8cf04d0 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -128,6 +128,7 @@ ifeq ($(uname_S),Darwin)
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_MSGFMT=1
+	GITGUI_WINDOWS_WRAPPER := YesPlease
 endif
 
 ifdef GITGUI_MACOSXAPP
@@ -168,6 +169,13 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
 	mv '$@'+ '$@'
 endif
 
+ifdef GITGUI_WINDOWS_WRAPPER
+GITGUI_MAIN := git-gui.tcl
+
+git-gui: windows/git-gui.sh
+	cp $< $@
+endif
+
 $(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
 	$(QUIET_GEN)rm -f $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -233,6 +241,9 @@ GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 ifdef GITGUI_MACOSXAPP
 all:: git-gui Git\ Gui.app
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+all:: git-gui
+endif
 all:: $(GITGUI_MAIN) lib/tclIndex $(ALL_MSGFILES)
 
 install: all
@@ -246,6 +257,9 @@ ifdef GITGUI_MACOSXAPP
 	$(QUIET)$(INSTALL_A0)'Git Gui.app' $(INSTALL_A1) '$(DESTDIR_SQ)$(libdir_SQ)'
 	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$(libdir_SQ)'
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$(libdir_SQ)'
+endif
 	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
 	$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
 	$(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
diff --git a/git-gui/windows/git-gui.sh b/git-gui/windows/git-gui.sh
new file mode 100644
index 0000000..98f32c0
--- /dev/null
+++ b/git-gui/windows/git-gui.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
+	cd [lindex $argv 1]
+	set argv [lrange $argv 2 end]
+	incr argc -2
+}
+
+set gitguidir [file dirname [info script]]
+regsub -all ";" $gitguidir "\\;" gitguidir
+set env(PATH) "$gitguidir;$env(PATH)"
+unset gitguidir
+
+source [file join [file dirname [info script]] git-gui.tcl]
-- 
1.5.3.mingw.1.105.gf0c04

Re: [PATCH] git-gui: add mingw specific startup wrapper

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:40

Steffen Prohaska [off-list ref] wrote:
The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.

The wrapper script also accepts an optional command line
switch '--working-dir <dir>' and changes to <dir> before
launching the actual git-gui. This is required to implement
the "Git Gui Here" Explorer shell extension.
 
Nice.
quoted hunk
diff --git a/git-gui/Makefile b/git-gui/Makefile
@@ -128,6 +128,7 @@ ifeq ($(uname_S),Darwin)
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_MSGFMT=1
+	GITGUI_WINDOWS_WRAPPER := YesPlease
 endif
I don't have this context in my Makefile so I can't apply this
additional line here.  Can someone package up the patch that
introduces the MINGW case above with a proper commit message,
so I can apply it in front of this patch?
quoted hunk
 install: all
@@ -246,6 +257,9 @@ ifdef GITGUI_MACOSXAPP
 	$(QUIET)$(INSTALL_A0)'Git Gui.app' $(INSTALL_A1) '$(DESTDIR_SQ)$(libdir_SQ)'
 	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$(libdir_SQ)'
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$(libdir_SQ)'
+endif
 	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
 	$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
 	$(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
I think you missed the entry in the uninstall and clean targets.
quoted hunk
diff --git a/git-gui/windows/git-gui.sh b/git-gui/windows/git-gui.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
+	cd [lindex $argv 1]
+	set argv [lrange $argv 2 end]
+	incr argc -2
+}
Maybe we should just support this option directly in git-gui.
Today we also support doing something like this by setting the
GIT_DIR environment variable into a non-bare repository; see the
"# repository setup" block of git-gui.sh.
+set gitguidir [file dirname [info script]]
+regsub -all ";" $gitguidir "\\;" gitguidir
+set env(PATH) "$gitguidir;$env(PATH)"
+unset gitguidir
+
+source [file join [file dirname [info script]] git-gui.tcl]
Hmmph.  The install target was going into libdir but the above
source doesn't seem to read from there, its loading from the same
location as the git-gui wrapper script.  You msys guys probably
don't have $(libdir) == $(gitexecdir), do you?

-- 
Shawn.

Re: [PATCH] git-gui: add mingw specific startup wrapper

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

On Oct 10, 2007, at 8:22 AM, Shawn O. Pearce wrote:
Steffen Prohaska [off-list ref] wrote:
quoted
diff --git a/git-gui/Makefile b/git-gui/Makefile
@@ -128,6 +128,7 @@ ifeq ($(uname_S),Darwin)
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_MSGFMT=1
+	GITGUI_WINDOWS_WRAPPER := YesPlease
 endif
I don't have this context in my Makefile so I can't apply this
additional line here.  Can someone package up the patch that
introduces the MINGW case above with a proper commit message,
so I can apply it in front of this patch?
You need the patch
"git-gui: set NO_MSGFMT to force using pure tcl replacement in msysgit"
that I'll send in a follow-up mail. Apologies for forgetting about that.

quoted
 install: all
@@ -246,6 +257,9 @@ ifdef GITGUI_MACOSXAPP
 	$(QUIET)$(INSTALL_A0)'Git Gui.app' $(INSTALL_A1) '$(DESTDIR_SQ)$ 
(libdir_SQ)'
 	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$ 
(libdir_SQ)'
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$ 
(libdir_SQ)'
+endif
 	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $ 
(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
 	$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
 	$(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $ 
(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
I think you missed the entry in the uninstall and clean targets.
fixed.

quoted
diff --git a/git-gui/windows/git-gui.sh b/git-gui/windows/git-gui.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
+	cd [lindex $argv 1]
+	set argv [lrange $argv 2 end]
+	incr argc -2
+}
Maybe we should just support this option directly in git-gui.
Today we also support doing something like this by setting the
GIT_DIR environment variable into a non-bare repository; see the
"# repository setup" block of git-gui.sh.
would definitely be easier. It is an option that can be useful in  
general.
I'll not take care of this right away.
quoted
+set gitguidir [file dirname [info script]]
+regsub -all ";" $gitguidir "\\;" gitguidir
+set env(PATH) "$gitguidir;$env(PATH)"
+unset gitguidir
+
+source [file join [file dirname [info script]] git-gui.tcl]
Hmmph.  The install target was going into libdir but the above
source doesn't seem to read from there, its loading from the same
location as the git-gui wrapper script.  You msys guys probably
don't have $(libdir) == $(gitexecdir), do you?
Thanks for spotting that. I decided to put git-gui.tcl into
$(gitexecdir) with permissions 644.

A series of two patches will follow.

	Steffen

[PATCH v2] git-gui: set NO_MSGFMT to force using pure tcl replacement in msysgit

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

Shawn's git-gui Makefile supports the pure tcl replacement
for msgfmt if setting NO_MSGFMT. This patch sets the NO_MSGFMT
for msysgit.

Signed-off-by: Steffen Prohaska <redacted>
---
 git-gui/Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/git-gui/Makefile b/git-gui/Makefile
index 818a0ab..c805450 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -126,6 +126,9 @@ ifeq ($(uname_S),Darwin)
 		GITGUI_MACOSXAPP := YesPlease
 	endif
 endif
+ifneq (,$(findstring MINGW,$(uname_S)))
+	NO_MSGFMT=1
+endif
 
 ifdef GITGUI_MACOSXAPP
 GITGUI_MAIN := git-gui.tcl
-- 
1.5.3.mingw.1.105.gf0c04

[PATCH v2] git-gui: add mingw specific startup wrapper

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.

The wrapper script also accepts an optional command line
switch '--working-dir <dir>' and changes to <dir> before
launching the actual git-gui. This is required to implement
the "Git Gui Here" Explorer shell extension.

As a last step the original git-gui script is launched,
which is expected to be located in the same directory
under the name git-gui.tcl.

Signed-off-by: Steffen Prohaska <redacted>
---
 git-gui/Makefile           |   20 ++++++++++++++++++++
 git-gui/windows/git-gui.sh |   16 ++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 git-gui/windows/git-gui.sh
diff --git a/git-gui/Makefile b/git-gui/Makefile
index c805450..2ad8846 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -128,6 +128,7 @@ ifeq ($(uname_S),Darwin)
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_MSGFMT=1
+	GITGUI_WINDOWS_WRAPPER := YesPlease
 endif
 
 ifdef GITGUI_MACOSXAPP
@@ -168,6 +169,13 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
 	mv '$@'+ '$@'
 endif
 
+ifdef GITGUI_WINDOWS_WRAPPER
+GITGUI_MAIN := git-gui.tcl
+
+git-gui: windows/git-gui.sh
+	cp $< $@
+endif
+
 $(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
 	$(QUIET_GEN)rm -f $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -233,12 +241,18 @@ GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 ifdef GITGUI_MACOSXAPP
 all:: git-gui Git\ Gui.app
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+all:: git-gui
+endif
 all:: $(GITGUI_MAIN) lib/tclIndex $(ALL_MSGFILES)
 
 install: all
 	$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
 	$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
+endif
 	$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(INSTALL_D1)
 	$(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
 	$(QUIET)$(INSTALL_R0)lib/git-gui.ico $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
@@ -254,6 +268,9 @@ uninstall:
 	$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
 	$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
+endif
 	$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
 	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
 	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/git-gui.ico $(REMOVE_F1)
@@ -279,6 +296,9 @@ clean::
 ifdef GITGUI_MACOSXAPP
 	$(RM_RF) 'Git Gui.app'* git-gui
 endif
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(RM_RF) git-gui
+endif
 
 .PHONY: all install uninstall dist-version clean
 .PHONY: .FORCE-GIT-VERSION-FILE
diff --git a/git-gui/windows/git-gui.sh b/git-gui/windows/git-gui.sh
new file mode 100644
index 0000000..98f32c0
--- /dev/null
+++ b/git-gui/windows/git-gui.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
+	cd [lindex $argv 1]
+	set argv [lrange $argv 2 end]
+	incr argc -2
+}
+
+set gitguidir [file dirname [info script]]
+regsub -all ";" $gitguidir "\\;" gitguidir
+set env(PATH) "$gitguidir;$env(PATH)"
+unset gitguidir
+
+source [file join [file dirname [info script]] git-gui.tcl]
-- 
1.5.3.mingw.1.105.gf0c04

Re: [PATCH v2] git-gui: add mingw specific startup wrapper

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:40

Steffen Prohaska [off-list ref] wrote:
The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.
Thanks, I have both of these applied now to master and will push
it out shortly, along with the mingw version fix you had sent
me much earlier.
 
+if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
+	cd [lindex $argv 1]
+	set argv [lrange $argv 2 end]
+	incr argc -2
+}
Perhaps someday in the future we'll put this into git-gui.sh so
all platforms can use it.  Today, its Windows only.  ;-)

-- 
Shawn.

Re: [PATCH v2] git-gui: set NO_MSGFMT to force using pure tcl replacement in msysgit

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:40

Hi,

On Wed, 10 Oct 2007, Steffen Prohaska wrote:
Shawn's git-gui Makefile supports the pure tcl replacement for msgfmt if 
setting NO_MSGFMT. This patch sets the NO_MSGFMT for msysgit.
Would it not be cleaner to set this in 4msysgit and export it?

Ciao,
Dscho

Re: [PATCH v2] git-gui: add mingw specific startup wrapper

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:40

Hi,

On Wed, 10 Oct 2007, Steffen Prohaska wrote:
The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.

The wrapper script also accepts an optional command line
switch '--working-dir <dir>' and changes to <dir> before
launching the actual git-gui. This is required to implement
the "Git Gui Here" Explorer shell extension.
It should be mentioned here that the Explorer shell extension you talk 
about is the very simple extension provided by the Inno Installer.

I have a much larger and versatile shell extension in mind: git-cheetah.  
And fixing it is probably trivial; it can both change directory to the 
current directory (sounds wrong, doesn't it?) and extend the PATH 
appropriately before calling git-gui.

Note: the latter is not even necessary once we (correctly) add git to the 
PATH in the installer.

Ciao,
Dscho

Re: [PATCH v2] git-gui: set NO_MSGFMT to force using pure tcl replacement in msysgit

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

On Oct 10, 2007, at 5:52 PM, Johannes Schindelin wrote:
On Wed, 10 Oct 2007, Steffen Prohaska wrote:
quoted
Shawn's git-gui Makefile supports the pure tcl replacement for  
msgfmt if
setting NO_MSGFMT. This patch sets the NO_MSGFMT for msysgit.
Would it not be cleaner to set this in 4msysgit and export it?
What does "set this in 4msysgit" mean?

Would running 'make' in /git/git-gui/ be supported by your solution?

	Steffen

Re: [PATCH v2] git-gui: add mingw specific startup wrapper

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:43:40

On Oct 10, 2007, at 5:56 PM, Johannes Schindelin wrote:
On Wed, 10 Oct 2007, Steffen Prohaska wrote:
quoted
The wrapper adds the directory it is installed in to PATH.
This is required for the git commands implemented in shell.
git-gui fails to launch them if PATH is not modified.

The wrapper script also accepts an optional command line
switch '--working-dir <dir>' and changes to <dir> before
launching the actual git-gui. This is required to implement
the "Git Gui Here" Explorer shell extension.
It should be mentioned here that the Explorer shell extension you talk
about is the very simple extension provided by the Inno Installer.
Yes, but it's already there. And Shawn even finds --working-dir  
interesting
as a general feature.

I have a much larger and versatile shell extension in mind: git- 
cheetah.
And fixing it is probably trivial; it can both change directory to the
current directory (sounds wrong, doesn't it?) and extend the PATH
appropriately before calling git-gui.
I know, but it's not yet there.

Note: the latter is not even necessary once we (correctly) add git  
to the
PATH in the installer.
(wrongly ;) Adding git to the PATH will only become an option. git-gui
should also work if it's not added.

I comment on the PATH question in reply to another mail.

	Steffen

Re: [PATCH v2] git-gui: set NO_MSGFMT to force using pure tcl replacement in msysgit

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:40

Hi,

On Wed, 10 Oct 2007, Steffen Prohaska wrote:
On Oct 10, 2007, at 5:52 PM, Johannes Schindelin wrote:
quoted
On Wed, 10 Oct 2007, Steffen Prohaska wrote:
quoted
Shawn's git-gui Makefile supports the pure tcl replacement for 
msgfmt if setting NO_MSGFMT. This patch sets the NO_MSGFMT for 
msysgit.
Would it not be cleaner to set this in 4msysgit and export it?
What does "set this in 4msysgit" mean?
It means what you probably assumed, that we change the Makefile in /git.
Would running 'make' in /git/git-gui/ be supported by your solution?
No, not really.  Just like "make" in /git/t/ does not pick up on the 
NO_SYMLINKS option.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help