Skip to contentSkip to conversation

git-gui: add mingw specific startup wrapper

PATCH In review Steffen Prohaska 3 participants 11 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 git-gui: add mingw specific startup wrapper

In reply to a message not in the archive

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.

---
 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
git-gui/Makefile +14 -0
index c805450..8cf04d0 100644
@@ -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
git-gui/windows/git-gui.sh new file +16 -0
new file mode 100644
index 0000000..98f32c0
@@ -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]
Signature · 1 line
1.5.3.mingw.1.105.gf0c04
#2 lore raw
Quoted 8 lines · Steffen Prohaska

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.

git-gui/Makefile ifeq ($(uname_S),Darwin) · line 132

Quoted 7 lines
git-gui/Makefile +1 -0
@@ -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?

git-gui/Makefile ifdef GITGUI_MACOSXAPP · line 265

Quoted 11 lines
git-gui/Makefile +3 -0
 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.

git-gui/windows/git-gui.sh line 9

Quoted 11 lines
git-gui/windows/git-gui.sh +9 -0
@@ -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.

git-gui/windows/git-gui.sh line 16

Quoted 6 lines
git-gui/windows/git-gui.sh +6 -0
+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?

Signature · 1 line
Shawn.
#3 lore raw
Quoted 15 lines · Shawn O. Pearce

git-gui/Makefile ifeq ($(uname_S),Darwin) · line 132

Quoted 7 lines · Steffen Prohaska
git-gui/Makefile +1 -0
@@ -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 10 lines
Quoted 10 lines
git-gui/Makefile +0 -0
 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

git-gui/Makefile +2 -0
+ifdef GITGUI_WINDOWS_WRAPPER
+	$(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$ 

(libdir_SQ)'

Quoted 8 lines
Quoted 6 lines
git-gui/Makefile +1 -0
+endif
 	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $ 

(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true

git-gui/Makefile +0 -0
 	$(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 8 lines
Quoted 8 lines
git-gui/windows/git-gui.sh +6 -0
@@ -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]
Quoted 8 lines

git-gui/windows/git-gui.sh line 9

Quoted 3 lines
git-gui/windows/git-gui.sh +3 -0
+	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 11 lines

git-gui/windows/git-gui.sh line 16

Quoted 6 lines
git-gui/windows/git-gui.sh +6 -0
+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

#4 lore raw

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

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

---
 git-gui/Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
git-gui/Makefile +3 -0
index 818a0ab..c805450 100644
@@ -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
Signature · 1 line
1.5.3.mingw.1.105.gf0c04
#5 lore raw

PATCH v2 1/1 git-gui: add mingw specific startup wrapper

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.

---
 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
git-gui/Makefile +20 -0
index c805450..2ad8846 100644
@@ -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
git-gui/windows/git-gui.sh new file +16 -0
new file mode 100644
index 0000000..98f32c0
@@ -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]
Signature · 1 line
1.5.3.mingw.1.105.gf0c04
#6 lore raw
Quoted 3 lines · Steffen Prohaska

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.

git-gui/windows/git-gui.sh line 9

Quoted 5 lines
git-gui/windows/git-gui.sh new file +5 -0
+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. ;-)

Signature · 1 line
Shawn.
#7 lore raw
In reply to Steffen Prohaska

Hi,

Quoted 8 lines · Steffen Prohaska

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

#8 lore raw
Quoted 6 lines · Johannes Schindelin
Quoted 4 lines · Steffen Prohaska

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.

Quoted 7 lines
Quoted 4 lines

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.

Quoted 4 lines

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.

Quoted 2 lines

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

#9 lore raw

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

In reply to Steffen Prohaska

Hi,

Quoted 2 lines · Steffen Prohaska

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

#10 lore raw

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

Quoted 6 lines · Johannes Schindelin
Quoted 2 lines · Steffen Prohaska

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

#11 lore raw

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

Hi,

Quoted 11 lines · Steffen Prohaska
Quoted 7 lines · Johannes Schindelin
Quoted 3 lines · Steffen Prohaska

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.

Quoted 1 line

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