X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=contrib%2Fworkdir%2Fgit-new-workdir;h=2838546d16073f29b3a87ce9126d92b0f640be5e;hb=b23b27eb5dc950081d4f76ae84f10168c4d149bd;hp=f2a3615bbc44ed4edbee4014683621a91c1a7ab9;hpb=96cbd573d48297d0f8e5b1f509bc4dd7e9604fa7;p=git.git diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir index f2a3615bb..2838546d1 100755 --- a/contrib/workdir/git-new-workdir +++ b/contrib/workdir/git-new-workdir @@ -24,6 +24,23 @@ git_dir=$(cd "$orig_git" 2>/dev/null && git rev-parse --git-dir 2>/dev/null) || die "\"$orig_git\" is not a git repository!" +case "$git_dir" in +.git) + git_dir="$orig_git/.git" + ;; +.) + git_dir=$orig_git + ;; +esac + +# don't link to a configured bare repository +isbare=$(git --git-dir="$git_dir" config --bool --get core.bare) +if test ztrue = z$isbare +then + die "\"$git_dir\" has core.bare set to true," \ + " remove from \"$git_dir/config\" to use $0" +fi + # don't link to a workdir if test -L "$git_dir/config" then @@ -31,6 +48,12 @@ then "a complete repository." fi +# don't recreate a workdir over an existing repository +if test -e "$new_workdir" +then + die "destination directory '$new_workdir' already exists." +fi + # make sure the the links use full paths git_dir=$(cd "$git_dir"; pwd)