From 9c1d9d0bffb8f1fbc65f0f83453458fa561823b3 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Fri, 28 Sep 2012 13:57:05 -0600 Subject: [PATCH] gitcreate creates subdirs after asking user --- scripts/gitcreate | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/gitcreate b/scripts/gitcreate index cab983e..7a46d1b 100755 --- a/scripts/gitcreate +++ b/scripts/gitcreate @@ -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 -- 2.39.2