]> git.phdru.name Git - git-scripts.git/commitdiff
Get local directory name from origin
authorOleg Broytman <phd@phdru.name>
Tue, 12 May 2020 10:49:31 +0000 (13:49 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 12 May 2020 10:49:31 +0000 (13:49 +0300)
clone
fork

diff --git a/clone b/clone
index fa51e9fa4fb532371a055197d72e1d5b4554efa7..5d1118d62b305add331d5642f0a8d8f86ebfa6c2 100755 (executable)
--- a/clone
+++ b/clone
@@ -1,12 +1,13 @@
 #! /bin/sh
 
-if [ -z "$1" ]; then
-   echo "Usage: $0 origin" >&2
+if [ -z "$1" -o -n "$3" ]; then
+   echo "Usage: $0 origin [local]" >&2
    exit 1
 fi
 
 origin="$1"
-local_repo="`basename \"$origin\" .git`"
+local_repo="$2"
+test -z "$local_repo" && local_repo="`basename \"$origin\" .git`"
 
 if [ -d "$local_repo"/.git ]; then
    cd "$local_repo"
diff --git a/fork b/fork
index 2a537b483b87c5d4d0079fcf465918531fdbaa01..51883568272ae6cd3ff03149663e0dacf0217c6f 100755 (executable)
--- a/fork
+++ b/fork
@@ -1,13 +1,14 @@
 #! /bin/sh
 
-if [ -z "$2" ]; then
-   echo "Usage: $0 upstream origin" >&2
+if [ -z "$2" -o -n "$4" ]; then
+   echo "Usage: $0 upstream origin [local]" >&2
    exit 1
 fi
 
 upstream="$1"
 origin="$2"
-local_repo="`basename \"$origin\" .git`"
+local_repo="$3"
+test -z "$local_repo" && local_repo="`basename \"$origin\" .git`"
 
 if [ -d "$local_repo"/.git ]; then
    cd "$local_repo"