{"thread":{"id":"8651","subject":"[PATCH] new-workdir: handle rev-parse --git-dir not always giving full path","startedAt":"2007-06-19T11:44:43Z","lastAt":"2007-06-19T11:44:43Z","messageCount":1,"participants":["Julian Phillips"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45344","messageId":"20070619114456.10962.31845.julian@quantumfyre.co.uk","threadId":"8651","inReplyTo":null,"subject":"[PATCH] new-workdir: handle rev-parse --git-dir not always giving full path","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2007-06-19T11:44:43Z","receivedAt":"2007-06-19T11:44:43Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"rev-parse --git-dir outputs a full path - except for the single case\nof when the path would be $(pwd)/.git, in which case it outputs simply\n.git.  Check for this special case and handle it.\n\nSigned-off-by: Julian Phillips <julian@quantumfyre.co.uk>\n---\n\nI 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.\n\nTurns 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.\n\n contrib/workdir/git-new-workdir |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir\nindex f2a3615..709b2a3 100755\n--- a/contrib/workdir/git-new-workdir\n+++ b/contrib/workdir/git-new-workdir\n@@ -24,6 +24,11 @@ git_dir=$(cd \"$orig_git\" 2>/dev/null &&\n   git rev-parse --git-dir 2>/dev/null) ||\n   die \"\\\"$orig_git\\\" is not a git repository!\"\n \n+if test \"$git_dir\" == \".git\"\n+then\n+\tgit_dir=\"$orig_git/.git\"\n+fi\n+\n # don't link to a workdir\n if test -L \"$git_dir/config\"\n then\n-- \n1.5.2.2\n"}]}