]> oss.titaniummirror.com Git - repo_shell.git/commitdiff
gitcreate: Differentiate repopath and repodir
authorR. Steve McKown <rsmckown@gmail.com>
Sat, 21 Jun 2014 01:34:15 +0000 (19:34 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Sat, 21 Jun 2014 01:34:15 +0000 (19:34 -0600)
* repopath is the repository path provided by the user.  Use $repopath
  instead of $1 for a clearer script.
* repodir is the dirname of the repopath

scripts/gitcreate

index c19839f35844137716b9f6f1d0274468f41cf7c8..3c7cd36a447b7bee5ab0ef0207e14b88dece1650 100755 (executable)
@@ -24,16 +24,18 @@ if [ $# -ne 1 ]; then
     exit 1
 fi
 
-if [ -e $git_root/$1 ]; then
-    echo "$0: repository $1 already exists" >&2
+repopath=$1
+
+if [ -e $git_root/$repopath ]; then
+    echo "$0: repository $repopath already exists" >&2
     exit 1
 fi
 
 # Do not create subdirectories without asking first
-repopath=$(dirname $1)
-if [ ! -d "$git_root/$repopath" ]; then
+repodir=$(dirname $repopath)
+if [ ! -d "$git_root/$repodir" ]; then
   if [ ! $yes ]; then
-    echo -n "Create git subdir '$repopath' (y/N)? "
+    echo -n "Create git subdir '$repodir' (y/N)? "
     read ans
     ans=$(expr "$ans" : '\(.\).*') # works with dash too
     if [ "$ans" != "y" -a "$ans" != "Y" ];then
@@ -41,16 +43,16 @@ if [ ! -d "$git_root/$repopath" ]; then
       exit 0
     fi
   fi
-  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
+  mkdir -p "$git_root/$repodir" 2>/dev/null
+  if [ ! -d "$git_root/$repodir" ]; then
+    echo "%0: repository not created, git subdir '$repodir' create failed" >&2
     exit 1
   fi
 fi
 
 # Create the respository
 umask 027
-git --git-dir "$git_root/$1" init --bare
+git --git-dir "$git_root/$repopath" init --bare
 [ $? -ne 0 ] && exit 1
 
 [ -f "$gitacls" ] && echo "Check $gitacls for proper access permissions"