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

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

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Aug 16, 2009, 23:58 UTC
Message-ID
<1250467128-29839-4-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1250467128-29839-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 38b11c1..fbad6fd 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1100,6 +1100,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]} {
@@ -1108,6 +1110,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.4.177.g695987
Previous: Giuseppe BilottaNext: Bert Wesarg
Message 4 of 9 in “[PATCHv3 0/3] git-gui: more robust handling of fancy repos”
  1. Giuseppe BilottaAug 16, 2009
  2. 1/3 git-gui: handle non-standard worktree locationsGiuseppe Bilotta, Aug 16, 2009
  3. 2/3 git-gui: handle bare repos correctlyGiuseppe Bilotta, Aug 16, 2009
  4. 3/3 git-gui: work from the .git dirGiuseppe Bilotta, Aug 16, 2009
  5. Bert WesargOct 27, 2009
  6. Giuseppe BilottaDec 6, 2009
  7. Bert WesargDec 6, 2009
  8. Giuseppe BilottaDec 6, 2009
  9. Shawn O. PearceDec 5, 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.