# [PATCH] git-gui: Use PWD if it exists on Mac OS X.

3 messages from 2012-03-09 to 2012-03-10. Participants: Marcus Karlsson, Junio C Hamano, Pat Thoyts.
Thread: https://gitlist.dev/t/29903

## Marcus Karlsson, 2012-03-09 23:17

Subject: [PATCH] git-gui: Use PWD if it exists on Mac OS X.
Message-ID: <1331335042-25509-1-git-send-email-mk@acc.umu.se>
URL: https://gitlist.dev/e/1331335042-25509-1-git-send-email-mk%40acc.umu.se

```
The current working directory is set to / when git-gui is invoked
using the Git Gui.app bundle on Mac OS X. This means that if it is
launched from a directory which contains a repository then git-gui
won't automatically find it unless the repository happens to be
located in /.

The PWD environment variable is however preserved if the bundle is
invoked using open(1). If git-gui would check for PWD then a user
could for example type open -a 'Git Gui' on a command line in order to
launch the program and it would automatically find the repository.

Teach git-gui to use the PWD environment variable on Mac OS X.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>
---
 git-gui/macosx/AppMain.tcl |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/git-gui/macosx/AppMain.tcl b/git-gui/macosx/AppMain.tcl
index ddbe633..738bdd0 100644
--- a/git-gui/macosx/AppMain.tcl
+++ b/git-gui/macosx/AppMain.tcl
@@ -12,7 +12,9 @@ if {[file tail [lindex $argv 0]] eq {gitk}} {
 } else {
 	set argv0 [file join $gitexecdir [file tail [lindex $argv 0]]]
 	set AppMain_source [file join $gitguilib git-gui.tcl]
-	if {[pwd] eq {/}} {
+	if {[info exists env(PWD)]} {
+		cd $env(PWD)
+	} elseif {[pwd] eq {/}} {
 		cd $env(HOME)
 	}
 }
-- 
1.7.10.rc0.17.g36a9f

```

## Junio C Hamano, 2012-03-09 23:37

Subject: Re: [PATCH] git-gui: Use PWD if it exists on Mac OS X.
Message-ID: <7vty1x2vod.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vty1x2vod.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1331335042-25509-1-git-send-email-mk@acc.umu.se>

```
Thanks, Marcus.

Just forwarding to the current maintainer; please note that my
sign-off does not mean anything more than what D-C-O says it means;
I rarely if ever use git-gui myself and do not have a Macintosh.

-- >8 --
From: Marcus Karlsson <mk@acc.umu.se>
Subject: [PATCH] git-gui: Use PWD if it exists on Mac OS X
Date: Sat, 10 Mar 2012 00:17:22 +0100

The current working directory is set to / when git-gui is invoked
using the Git Gui.app bundle on Mac OS X. This means that if it is
launched from a directory which contains a repository then git-gui
won't automatically find it unless the repository happens to be
located in /.

The PWD environment variable is however preserved if the bundle is
invoked using open(1). If git-gui would check for PWD then a user
could for example type open -a 'Git Gui' on a command line in order to
launch the program and it would automatically find the repository.

Teach git-gui to use the PWD environment variable on Mac OS X.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-gui/macosx/AppMain.tcl |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/git-gui/macosx/AppMain.tcl b/git-gui/macosx/AppMain.tcl
index ddbe633..738bdd0 100644
--- a/git-gui/macosx/AppMain.tcl
+++ b/git-gui/macosx/AppMain.tcl
@@ -12,7 +12,9 @@ if {[file tail [lindex $argv 0]] eq {gitk}} {
 } else {
 	set argv0 [file join $gitexecdir [file tail [lindex $argv 0]]]
 	set AppMain_source [file join $gitguilib git-gui.tcl]
-	if {[pwd] eq {/}} {
+	if {[info exists env(PWD)]} {
+		cd $env(PWD)
+	} elseif {[pwd] eq {/}} {
 		cd $env(HOME)
 	}
 }
-- 
1.7.10.rc0.17.g36a9f

```

## Pat Thoyts, 2012-03-10 23:18

Subject: Re: [PATCH] git-gui: Use PWD if it exists on Mac OS X.
Message-ID: <877gys11uv.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/877gys11uv.fsf%40fox.patthoyts.tk
In-Reply-To: <7vty1x2vod.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

>Thanks, Marcus.
>
>Just forwarding to the current maintainer; please note that my
>sign-off does not mean anything more than what D-C-O says it means;
>I rarely if ever use git-gui myself and do not have a Macintosh.

Thanks for this. I also don't have a Mac but this looks sensible
so applied.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```
