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

1 messages from 2007-06-19 to 2007-06-19. Participants: Julian Phillips.
Thread: https://gitlist.dev/t/8651

## Julian Phillips, 2007-06-19 11:44

Subject: [PATCH] new-workdir: handle rev-parse --git-dir not always giving full path
Message-ID: <20070619114456.10962.31845.julian@quantumfyre.co.uk>
URL: https://gitlist.dev/e/20070619114456.10962.31845.julian%40quantumfyre.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

```
