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"