summaryrefslogtreecommitdiff
path: root/contrib/workdir/git-new-workdir
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/workdir/git-new-workdir')
-rwxr-xr-xcontrib/workdir/git-new-workdir26
1 files changed, 22 insertions, 4 deletions
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 3ff6bd166a..993cacf324 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -22,11 +22,23 @@ branch=$3
# want to make sure that what is pointed to has a .git directory ...
git_dir=$(cd "$orig_git" 2>/dev/null &&
git rev-parse --git-dir 2>/dev/null) ||
- die "\"$orig_git\" is not a git repository!"
+ die "Not a git repository: \"$orig_git\""
-if test "$git_dir" = ".git"
-then
+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
@@ -36,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)
@@ -45,7 +63,7 @@ mkdir -p "$new_workdir/.git" || die "unable to create \"$new_workdir\"!"
# create the links to the original repo. explictly exclude index, HEAD and
# logs/HEAD from the list since they are purely related to the current working
# directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache
+for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
do
case $x in
*/*)