]> oss.titaniummirror.com Git - repo_shell.git/commitdiff
gitcreate creates subdirs after asking user
authorR. Steve McKown <rsmckown@gmail.com>
Fri, 28 Sep 2012 19:57:05 +0000 (13:57 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Fri, 28 Sep 2012 19:57:05 +0000 (13:57 -0600)
scripts/gitcreate

index cab983e43988601e24017180b53bdcfde2d0d3d6..7a46d1b0ab6e0b62652339e9ba4fc6da27e46dea 100755 (executable)
@@ -22,6 +22,24 @@ if [ -e $git_root/$1 ]; then
     exit 1
 fi
 
+# Do not create subdirectories without asking first
+repopath=$(dirname $1)
+if [ ! -d "$git_root/$repopath" ]; then
+  echo -n "Create git subdir '$repopath' (y/N)? "
+  read ans
+  if [ "$ans" = "y" -o "$ans" = "Y" -o "$ans" = "yes" -o "$ans" = "Yes" \
+      -o "$ans" = "YES" ];then
+    mkdir -p "$git_root/$repopath" 2>/dev/null
+    if [ ! -d "$git_root/$repopath" ]; then
+      echo "%0: repository not created, git subdir '$repopath' create failed" >&2
+      exit 1
+    fi
+  else
+    echo "repository creation aborted at user request"
+    exit 0
+  fi
+fi
+
 # Create the respository
 umask 027
 git --git-dir "$git_root/$1" init --bare