# [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust

10 messages from 2009-03-29 to 2009-03-31. Participants: Markus Heidelberg, Johannes Schindelin, Shawn O. Pearce, Giuseppe Bilotta.
Thread: https://gitlist.dev/t/18622

## Markus Heidelberg, 2009-03-29 22:30

Subject: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <200903300030.03733.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200903300030.03733.markus.heidelberg%40web.de

```
Starting git-gui via Windows Explorer shell extension caused problems
when not started from the project directory, but from a directory within
the project: starting the Explorer from the git-gui menu "Explore
Working Copy" didn't work then.

Starting git-gui via Explorer shell extension from the .git directory
didn't work at all.

To make these things possible, "cd .." until we see .git/

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
---
 windows/git-gui.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/windows/git-gui.sh b/windows/git-gui.sh
index 53c3a94..16c4a2a 100644
--- a/windows/git-gui.sh
+++ b/windows/git-gui.sh
@@ -4,6 +4,9 @@ exec wish "$0" -- "$@"
 
 if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
 	cd [lindex $argv 1]
+	while { ![file isdirectory .git] } {
+		cd ..
+	}
 	set argv [lrange $argv 2 end]
 	incr argc -2
 }
-- 
1.6.2.1.409.gad7bf.dirty

```

## Johannes Schindelin, 2009-03-30 00:43

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <alpine.DEB.1.00.0903300243050.6454@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0903300243050.6454%40intel-tinevez-2-302
In-Reply-To: <200903300030.03733.markus.heidelberg@web.de>

```
Hi,

On Mon, 30 Mar 2009, Markus Heidelberg wrote:

> Starting git-gui via Windows Explorer shell extension caused problems 
> when not started from the project directory, but from a directory within 
> the project: starting the Explorer from the git-gui menu "Explore 
> Working Copy" didn't work then.
> 
> Starting git-gui via Explorer shell extension from the .git directory 
> didn't work at all.
> 
> To make these things possible, "cd .." until we see .git/

How does this interact with GIT_WORK_TREE?  And with bare repositories?

Ciao,
Dscho

```

## Markus Heidelberg, 2009-03-30 06:51

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <200903300851.43164.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200903300851.43164.markus.heidelberg%40web.de
In-Reply-To: <alpine.DEB.1.00.0903300243050.6454@intel-tinevez-2-302>

```
Johannes Schindelin, 30.03.2009:
> Hi,
> 
> On Mon, 30 Mar 2009, Markus Heidelberg wrote:
> 
> > Starting git-gui via Windows Explorer shell extension caused problems 
> > when not started from the project directory, but from a directory within 
> > the project: starting the Explorer from the git-gui menu "Explore 
> > Working Copy" didn't work then.
> > 
> > Starting git-gui via Explorer shell extension from the .git directory 
> > didn't work at all.
> > 
> > To make these things possible, "cd .." until we see .git/
> 
> How does this interact with GIT_WORK_TREE?

Not sure. What's the use case for a globally set GIT_WORK_TREE, how is
it used?

> And with bare repositories?

Git-gui doesn't seem to work with bare repositories, I get
"Cannot use funny .git directory: ."
when started on the command line.

But I just noticed, that it will obviously "cd .." forever, if no .git/
was found. Somehow the root directory has to be catched.

Markus

```

## Johannes Schindelin, 2009-03-30 08:03

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <alpine.DEB.1.00.0903301001090.7534@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0903301001090.7534%40intel-tinevez-2-302
In-Reply-To: <200903300851.43164.markus.heidelberg@web.de>

```
Hi,

On Mon, 30 Mar 2009, Markus Heidelberg wrote:

> Johannes Schindelin, 30.03.2009:
> 
> > On Mon, 30 Mar 2009, Markus Heidelberg wrote:
> > 
> > > Starting git-gui via Windows Explorer shell extension caused 
> > > problems when not started from the project directory, but from a 
> > > directory within the project: starting the Explorer from the git-gui 
> > > menu "Explore Working Copy" didn't work then.
> > > 
> > > Starting git-gui via Explorer shell extension from the .git 
> > > directory didn't work at all.
> > > 
> > > To make these things possible, "cd .." until we see .git/
> > 
> > How does this interact with GIT_WORK_TREE?
> 
> Not sure. What's the use case for a globally set GIT_WORK_TREE, how is 
> it used?

You can call git gui with a non-global GIT_WORK_TREE by something like 
this, even on Windows (which your patch does not special case, anyway):

	$ GIT_WORK_TREE=/bla/blub git gui

> > And with bare repositories?
> 
> Git-gui doesn't seem to work with bare repositories, I get
> "Cannot use funny .git directory: ."
> when started on the command line.

Oh?  I thought there was some discussion recently that was explicitely 
about git gui with bare repositories.  But I have to time-share my brain 
these days, so my memory might well show some bit flips.

Ciao,
Dscho

```

## Shawn O. Pearce, 2009-03-30 14:14

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <20090330141417.GV23521@spearce.org>
URL: https://gitlist.dev/e/20090330141417.GV23521%40spearce.org
In-Reply-To: <alpine.DEB.1.00.0903301001090.7534@intel-tinevez-2-302>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Mon, 30 Mar 2009, Markus Heidelberg wrote:
> > Johannes Schindelin, 30.03.2009:
> > > And with bare repositories?
> > 
> > Git-gui doesn't seem to work with bare repositories, I get
> > "Cannot use funny .git directory: ."
> > when started on the command line.
> 
> Oh?  I thought there was some discussion recently that was explicitely 
> about git gui with bare repositories.  But I have to time-share my brain 
> these days, so my memory might well show some bit flips.

At best, you can get blame to run on a bare repository, but that's
it.  Most of the git-gui UI is designed for viewing the status of
the working tree, or manipulating the index and/or files in that
working tree.  There are fairly good reasons why it doesn't work
on a bare repository.

Of course, fetch/push would be fine a bare repository, but I consider
that use case to be not worth the cost it would be in code to make
it possible.  We'd have to if out huge blocks of git-gui code,
maybe 80%+ of git-gui.sh, and that script is already hairy enough
(3477 lines).

-- 
Shawn.

```

## Shawn O. Pearce, 2009-03-30 14:15

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <20090330141510.GW23521@spearce.org>
URL: https://gitlist.dev/e/20090330141510.GW23521%40spearce.org
In-Reply-To: <200903300851.43164.markus.heidelberg@web.de>

```
Markus Heidelberg <markus.heidelberg@web.de> wrote:
> 
> But I just noticed, that it will obviously "cd .." forever, if no .git/
> was found. Somehow the root directory has to be catched.

Yup.  I'm dropping this patch for now because of this issue, but
I'll look at it again if its addressed in another version.  :-)

-- 
Shawn.

```

## Markus Heidelberg, 2009-03-30 20:20

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <200903302220.44564.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200903302220.44564.markus.heidelberg%40web.de
In-Reply-To: <alpine.DEB.1.00.0903301001090.7534@intel-tinevez-2-302>

```

Johannes Schindelin, 30.03.2009:
> Hi,
> 
> On Mon, 30 Mar 2009, Markus Heidelberg wrote:
> 
> > Johannes Schindelin, 30.03.2009:
> > 
> > > On Mon, 30 Mar 2009, Markus Heidelberg wrote:
> > > 
> > > > Starting git-gui via Windows Explorer shell extension caused 
> > > > problems when not started from the project directory, but from a 
> > > > directory within the project: starting the Explorer from the git-gui 
> > > > menu "Explore Working Copy" didn't work then.
> > > > 
> > > > Starting git-gui via Explorer shell extension from the .git 
> > > > directory didn't work at all.
> > > > 
> > > > To make these things possible, "cd .." until we see .git/
> > > 
> > > How does this interact with GIT_WORK_TREE?
> > 
> > Not sure. What's the use case for a globally set GIT_WORK_TREE, how is 
> > it used?
> 
> You can call git gui with a non-global GIT_WORK_TREE by something like 
> this, even on Windows (which your patch does not special case, anyway):
> 
> 	$ GIT_WORK_TREE=/bla/blub git gui

The patch only affected git-gui started via Explorer, i.e. invoked with
--working-dir. But it's right that core.worktree can be set in the
repository.
However, git-gui currently doesn't support the gitdir outside of the
working directory, but it may not be wise to build up on this!?

Hmm, more complicated than I initially thought.

Markus

```

## Giuseppe Bilotta, 2009-03-30 22:49

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <43168.7221433551$1238455980@news.gmane.org>
URL: https://gitlist.dev/e/43168.7221433551%241238455980%40news.gmane.org
In-Reply-To: <20090330141510.GW23521@spearce.org>

```

On Monday 30 March 2009 16:15, Shawn O. Pearce wrote:

> Markus Heidelberg <markus.heidelberg@web.de> wrote:
>> 
>> But I just noticed, that it will obviously "cd .." forever, if no .git/
>> was found. Somehow the root directory has to be catched.
> 
> Yup.  I'm dropping this patch for now because of this issue, but
> I'll look at it again if its addressed in another version.  :-)

I have a couple of pending patches to fix git gui handling of repositories,
including support for nonstandard repository locations and bare repositories.
You can find them at

http://git.oblomov.eu/git

and specifically

http://git.oblomov.eu/git/patches/b2e4c32e13df1b7f18e7b4a9f746650471a3122e..a63526bf3238cf25d9a5521f7ee35ed1bd11cb16

I got distracted by real-life issue and forgot to resend them. I'll try
to find the time again later on this week. I'm not entirely sure these
solve Markus' problem though.

-- 
Giuseppe "Oblomov" Bilotta

```

## Giuseppe Bilotta, 2009-03-30 22:49

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <499F039601E4A981@joe.mail.tiscali.sys>
URL: https://gitlist.dev/e/499F039601E4A981%40joe.mail.tiscali.sys
In-Reply-To: <20090330141510.GW23521@spearce.org>

```
On Monday 30 March 2009 16:15, Shawn O. Pearce wrote:

> Markus Heidelberg <markus.heidelberg@web.de> wrote:
>> 
>> But I just noticed, that it will obviously "cd .." forever, if no .git/
>> was found. Somehow the root directory has to be catched.
> 
> Yup.  I'm dropping this patch for now because of this issue, but
> I'll look at it again if its addressed in another version.  :-)

I have a couple of pending patches to fix git gui handling of repositories,
including support for nonstandard repository locations and bare repositories.
You can find them at

http://git.oblomov.eu/git

and specifically

http://git.oblomov.eu/git/patches/b2e4c32e13df1b7f18e7b4a9f746650471a3122e..a63526bf3238cf25d9a5521f7ee35ed1bd11cb16

I got distracted by real-life issue and forgot to resend them. I'll try
to find the time again later on this week. I'm not entirely sure these
solve Markus' problem though.

-- 
Giuseppe "Oblomov" Bilotta


```

## Markus Heidelberg, 2009-03-31 23:59

Subject: Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
Message-ID: <200904010159.24764.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200904010159.24764.markus.heidelberg%40web.de
In-Reply-To: <499F039601E4A981@joe.mail.tiscali.sys>

```

Giuseppe Bilotta, 31.03.2009:
> On Monday 30 March 2009 16:15, Shawn O. Pearce wrote:
> 
> > Markus Heidelberg <markus.heidelberg@web.de> wrote:
> >> 
> >> But I just noticed, that it will obviously "cd .." forever, if no .git/
> >> was found. Somehow the root directory has to be catched.
> > 
> > Yup.  I'm dropping this patch for now because of this issue, but
> > I'll look at it again if its addressed in another version.  :-)
> 
> I have a couple of pending patches to fix git gui handling of repositories,
> including support for nonstandard repository locations and bare repositories.
> You can find them at
> 
> http://git.oblomov.eu/git
> 
> and specifically
> 
> http://git.oblomov.eu/git/patches/b2e4c32e13df1b7f18e7b4a9f746650471a3122e..a63526bf3238cf25d9a5521f7ee35ed1bd11cb16

I just tried these two patches on Windows (Uhh, Qemu is too slow for
this, I have to setup something else).

> I got distracted by real-life issue and forgot to resend them. I'll try
> to find the time again later on this week. I'm not entirely sure these
> solve Markus' problem though.

Starting git-gui via Explorer "Git GUI Here" is now possible from the
.git/ directory with your patches, but it doesn't show the working tree
status. Also "Explore Working Copy" wants to open the .git directory
then instead of the project directory (I say "want" because of the issue
I just sent a patch out). It seems to be as non-functional as if you run
"git status" inside of .git/

Markus

```
