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

[PATCH] Fix new-workdir (again) to work on bare repositories

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 22, 2007, 01:50 UTC
Message-ID
<20070822015012.GA11085@spearce.org>

My day-job workflow involves using multiple workdirs attached to a bunch of bare repositories. Such repositories are stored inside of a directory called "foo.git", which means `git rev-parse --git-dir` will return "." and not ".git". Under such conditions new-workdir was getting confused about where the Git repository it was supplied is actually located.

If we get "." for the result of --git-dir query it means we should use the user supplied path as-is, and not attempt to perform any magic on it, as the path is directly to the repository.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/workdir/git-new-workdir |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 3ff6bd1..119cff9 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -24,10 +24,14 @@ 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
+case "$git_dir" in
+.git)
 	git_dir="$orig_git/.git"
-fi
+	;;
+.)
+	git_dir=$orig_git
+	;;
+esac
 
 # don't link to a workdir
 if test -L "$git_dir/config"
-- 
1.5.3.rc6
Next: Junio C Hamano
Message 1 of 6 in “Fix new-workdir (again) to work on bare repositories”
  1. Fix new-workdir (again) to work on bare repositoriesShawn O. Pearce, Aug 22, 2007
  2. Junio C HamanoAug 22, 2007
  3. Shawn O. PearceAug 22, 2007
  4. Junio C HamanoAug 22, 2007
  5. Shawn O. PearceAug 22, 2007
  6. Junio C HamanoAug 22, 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.