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

[PATCH] new-workdir: handle rev-parse --git-dir not always giving full path

From
Julian Phillips <julian@quantumfyre.co.uk>
Date
Jun 19, 2007, 11:44 UTC
Message-ID
<20070619114456.10962.31845.julian@quantumfyre.co.uk>

rev-parse --git-dir outputs a full path - except for the single case of when the path would be $(pwd)/.git, in which case it outputs simply .git. Check for this special case and handle it.

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
---
I tried to use new-workdir yesterday for the first time in a while, and found that it worked provided I gave a path inside the base repo, but not the path of the repo itself.
Turns out to be an oddity in rev-parse --git-dir output.  Since the rev-parse code explicitly does something different, I assume there is a reason for it.
 contrib/workdir/git-new-workdir |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index f2a3615..709b2a3 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -24,6 +24,11 @@ git_dir=$(cd "$orig_git" 2>/dev/null &&
   git rev-parse --git-dir 2>/dev/null) ||
   die "\"$orig_git\" is not a git repository!"
 
+if test "$git_dir" == ".git"
+then
+	git_dir="$orig_git/.git"
+fi
+
 # don't link to a workdir
 if test -L "$git_dir/config"
 then
-- 
1.5.2.2
Message 1 of 1 in “new-workdir: handle rev-parse --git-dir not always giving full path”
  1. new-workdir: handle rev-parse --git-dir not always giving full pathJulian Phillips, Jun 19, 2007

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.