summaryrefslogtreecommitdiff
path: root/localgit-remote-init-push
diff options
context:
space:
mode:
Diffstat (limited to 'localgit-remote-init-push')
-rwxr-xr-xlocalgit-remote-init-push17
1 files changed, 10 insertions, 7 deletions
diff --git a/localgit-remote-init-push b/localgit-remote-init-push
index 1f5717a..c1740ed 100755
--- a/localgit-remote-init-push
+++ b/localgit-remote-init-push
@@ -6,22 +6,23 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG PROJECT [GIT_HOST [SSH_CONN [GIT_REMOTE]]]
+Usage: $PRG PROJECT [GIT_REPO [SSH_CONN [GIT_REMOTE]]]
Initialize remote git, push local git, and set as default remote.
PROJECT basename or relative path for remote git project
- GIT_HOST hostname for public git access
+ GIT_REPO hostname for public git access
default: "source." + current domainname
SSH_CONN hostname for ssh, optionally with user + "@" prepended
- default: GIT_HOST
+ default: GIT_REPO
GIT_REMOTE name for local repository set
default: "origin"
-Full remote path becomes SSH_USER@SSH_HOST:/srv/git/GIT_HOST/PROJECT.git
+Full remote path becomes SSH_USER@SSH_HOST:BASEPATH/PROJECT.git
+where BASEPATH is resolved as "/srv/git/" + GIT_REPO
When local repository set is "origin" it is marked as default remote.
@@ -49,12 +50,14 @@ while true; do
done
PROJECT=${1-$(showhelp; exit1 "project name missing")}
-GIT_HOST=${2:-source.$(dnsdomainname --domain)}
+GIT_REPO=${2:-source.$(dnsdomainname --domain)}
+GIT_HOST=$GIT_REPO
+BASEPATH=/srv/git/"$GIT_REPO"
SSH_CONN=${3:-$GIT_HOST}
GIT_REMOTE=${4:-origin}
[ origin != "$GIT_ORIGIN" ] || ORIGIN_IS_DEFAULT=yes
-ssh "$SSH_CONN" git init --bare --shared /srv/git/"$GIT_HOST"/"$PROJECT".git
-git remote add "$GIT_REMOTE" "$SSH_CONN":/srv/git/"$GIT_HOST"/"$PROJECT".git
+ssh "$SSH_CONN" git init --bare --shared "$BASEPATH"/"$PROJECT".git
+git remote add "$GIT_REMOTE" "$SSH_CONN":"$BASEPATH"/"$PROJECT".git
git push ${ORIGIN_IS_DEFAULT:+--set-upstream "$GIT_REMOTE"} master