summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xgit-init-remote42
1 files changed, 40 insertions, 2 deletions
diff --git a/git-init-remote b/git-init-remote index a934c1f..043a780 100755 --- a/git-init-remote +++ b/git-init-remote
@@ -3,8 +3,33 @@
3GITREMOTE=git.acdw.net 3GITREMOTE=git.acdw.net
4GITROOT=/git 4GITROOT=/git
5 5
6POSTUPDATEHOOK=/tmp/post-update.hook
7
8init_post_update_hook() {
9 # This post-update hook will update cgit's date display.
10 cat <<\EOF
11#!/bin/sh
12
13# Update "agefile" for cgit
14# The default location is <git-dir>/info/web/last-modified
15agefile="$(git rev-parse --git-dir)/info/web/last-modified"
16mkdir -p "$(dirname "$agefile")"
17
18git for-each-ref > "$agefile" \
19 --sort=-authordate --count=1 \
20 --format='%(authordate:iso8601)'
21
22# Prepare a packed repository for use over dumb transports
23git update-server-info
24EOF
25}
26
27## Setup
28
6git ls-files > /dev/null || exit 1 29git ls-files > /dev/null || exit 1
7 30
31test -f "$POSTUPDATEHOOK" || init_post_update_hook > "$POSTUPDATEHOOK"
32
8# consider --git-dir as well .. however --git-dir would require more massaging 33# consider --git-dir as well .. however --git-dir would require more massaging
9# of the output. 34# of the output.
10local="$(git rev-parse --show-toplevel)" 35local="$(git rev-parse --show-toplevel)"
@@ -23,10 +48,23 @@ echo "ssh \"$GITREMOTE\" ed \"$remote/description\""
23ssh "$GITREMOTE" ed "$remote/description" 48ssh "$GITREMOTE" ed "$remote/description"
24 49
25# Add post-update-hook 50# Add post-update-hook
26echo "scp post-update.hook \"$GITREMOTE:$remote/hooks/post-update\"" 51echo "scp \"$POSTUPDATEHOOK\" \"$GITREMOTE:$remote/hooks/post-update\""
27scp post-update.hook "$GITREMOTE:$remote/hooks/post-update" 52scp "$POSTUPDATEHOOK" "$GITREMOTE:$remote/hooks/post-update"
53echo "ssh \"$GITREMOTE\" chmod +x \"$remote/hooks/post-update\""
54ssh "$GITREMOTE" chmod +x "$remote/hooks/post-update"
28 55
29## Local work 56## Local work
30 57
31echo "git remote add origin \"$GITREMOTE:$remote\"" 58echo "git remote add origin \"$GITREMOTE:$remote\""
32git remote add origin "$GITREMOTE:$remote" 59git remote add origin "$GITREMOTE:$remote"
60
61echo -n "Push to remote?"
62read
63
64case "$REPLY" in
65 y*|Y*|'')
66 echo git push -u origin main
67 git push -u origin main
68 ;;
69 *) ;;
70esac