threads / patch / 18622

patchgit-gui: make "Git GUI Here" Explorer extension more robust

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

## tl;dr

10 messages between Mar 29, 2009 and Mar 31, 2009. Diffs are folded; open one to read it.

replies: 9people: 4as markdown or json

Markus Heidelberg· Mar 29, 2009, 22:30 UTC · lore

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(-)
Show changes to windows/git-gui.sh +3 −0
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· Mar 30, 2009, 00:43 UTC · re: Markus Heidelberg · lore

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

Hi,
On Mon, 30 Mar 2009, Markus Heidelberg wrote:
Show 9 quoted lines
> 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· Mar 30, 2009, 06:51 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin, 30.03.2009:
Show 15 quoted lines
> 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· Mar 30, 2009, 08:03 UTC · re: Markus Heidelberg · lore

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

Hi,
On Mon, 30 Mar 2009, Markus Heidelberg wrote:
Show 18 quoted lines
> 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
Show 5 quoted lines
> > 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· Mar 30, 2009, 14:14 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 11 quoted lines
> 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.
Markus Heidelberg· Mar 30, 2009, 20:20 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin, 30.03.2009:
Show 27 quoted lines
> 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
Shawn O. Pearce· Mar 30, 2009, 14:15 UTC · re: Markus Heidelberg · lore

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

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.
Giuseppe Bilotta· Mar 30, 2009, 22:49 UTC · re: Shawn O. Pearce · lore

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

On Monday 30 March 2009 16:15, Shawn O. Pearce wrote:
Show 7 quoted lines
> 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· Mar 30, 2009, 22:49 UTC · re: Shawn O. Pearce · lore

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

On Monday 30 March 2009 16:15, Shawn O. Pearce wrote:
Show 7 quoted lines
> 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· Mar 31, 2009, 23:59 UTC · re: Giuseppe Bilotta · lore

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

Giuseppe Bilotta, 31.03.2009:
Show 19 quoted lines
> 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

← back to recent threads