@matheusbsbs / matheus-bagliano / commits / e301bfeea1
Fork 0

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

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Aug 21, 2007 at 21:50 UTC e301bfeea19e284344868840793c58d2e7529c74
1 file changed +7 -3
contrib/workdir/git-new-workdir
+7 -3
@@ -24,10 +24,14 @@ git_dir=$(cd "$orig_git" 2>/dev/null &&
24 git rev-parse --git-dir 2>/dev/null) ||
25 die "\"$orig_git\" is not a git repository!"
26
27 -if test "$git_dir" = ".git"
28 -then
27 +case "$git_dir" in
28 +.git)
29 git_dir="$orig_git/.git"
30 -fi
30 + ;;
31 +.)
32 + git_dir=$orig_git
33 + ;;
34 +esac
35
36 # don't link to a workdir
37 if test -L "$git_dir/config"