git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv3 (resend) 3/3] git-gui: work from the .git dir

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Dec 6, 2009, 08:06 UTC
Message-ID
<1260086801-4331-4-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1260086801-4331-1-git-send-email-giuseppe.bilotta@gmail.com>

When git-gui is run from a .git dir, _gitdir would be set to "." by rev-parse, something that confuses the worktree detection.

Fix by expanding the value of _gitdir to pwd in this special case.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-gui/git-gui.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 99ca4c0..0497e38 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1102,6 +1102,8 @@ if {[catch {
 		set _prefix {}
 		}]
 	&& [catch {
+		# beware that from the .git dir this sets _gitdir to .
+		# and _prefix to the empty string
 		set _gitdir [git rev-parse --git-dir]
 		set _prefix [git rev-parse --show-prefix]
 	} err]} {
@@ -1110,6 +1112,14 @@ if {[catch {
 	choose_repository::pick
 	set picked 1
 }
+
+# we expand the _gitdir when it's just a single dot (i.e. when we're being
+# run from the .git dir itself) lest the routines to find the worktree
+# get confused
+if {$_gitdir eq "."} {
+	set _gitdir [pwd]
+}
+
 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
 	catch {set _gitdir [exec cygpath --windows $_gitdir]}
 }
-- 
1.6.5.4
Previous: Giuseppe Bilotta
Message 4 of 4 in “[PATCHv3 (resend) 0/3] git-gui: more robust handling of fancy repos”
  1. Giuseppe BilottaDec 6, 2009
  2. 1/3 git-gui: handle non-standard worktree locationsGiuseppe Bilotta, Dec 6, 2009
  3. 2/3 git-gui: handle bare repos correctlyGiuseppe Bilotta, Dec 6, 2009
  4. 3/3 git-gui: work from the .git dirGiuseppe Bilotta, Dec 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.