This patch adds the ability to "git push", as the obvious converse of
"git pull".

Signed-Off-By: Matthias Urlichs <[EMAIL PROTECTED]>

Index: git
===================================================================
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/git  (mode:100755 
sha1:557122dfb05580e4af2c55767f3d6f92b9110edd)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/git  (mode:100644 
sha1:c32ee037c4dd68f8fa6723cb115644d46810bc89)
@@ -42,6 +42,7 @@
        merge           [-c] [-b BASE_ID] FROM_ID
        patch           [COMMIT_ID]
        pull            [RNAME]
+       push            [RNAME]
        rm              FILE...
        seek            [COMMIT_ID]
        status
@@ -86,6 +87,7 @@
 "lsremote")   gitlsremote.sh "$@";;
 "merge")      gitmerge.sh "$@";;
 "pull")       gitpull.sh "$@";;
+"push")       gitpush.sh "$@";;
 "patch")      gitpatch.sh "$@";;
 "rm")         gitrm.sh "$@";;
 "seek")       gitseek.sh "$@";;
--- /dev/null  (tree:42a073eb6b5bb397a3e8768a032463a7fa02e6b9)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/gitpush.sh  (mode:100644 
sha1:0a658141991c602ca327edb9ab982d7660d7c665)
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Pushes changes from the local GIT repository to "remote".
+# Copyright (c) Matthias Urlichs, 2005
+#
+# Takes the remote's name.
+
+name=$1
+
+die () {
+       echo gitpush.sh: $@ >&2
+       exit 1
+}
+
+
+[ "$name" ] || name=$(cat .git/tracking 2>/dev/null)
+[ "$name" ] || die "where to push to?"
+uri=$(grep $(echo -e "^$name\t" | sed 's/\./\\./g') .git/remotes | cut -f 2)
+[ "$uri" ] || die "unknown remote"
+
+
+tracking=
+[ -s .git/tracking ] && tracking=$(cat .git/tracking)
+
+orig_head=
+if [ "$tracking" = "$name" ]; then
+       [ -s .git/HEAD.tracked ] && orig_head=$(cat .git/HEAD.tracked)
+else
+       [ -s ".git/heads/$name" ] && orig_head=$(cat ".git/heads/$name")
+fi
+
+rsync $RSYNC_FLAGS -Lr "$uri/HEAD" ".git/HEAD_$name"
+$id=$(cat ".git/HEAD_$name")
+rm .git/HEAD_$name
+
+if [ -z "$id" ] ; then
+       echo "The remote system doesn't have a HEAD file: Doing an initial 
upload." >&2
+       echo "." >&2
+elif [ "$(cat-file -t "$id")" != "commit" ]; then
+       echo "The remote system has stuff we don't have: pull first!" >&2
+       echo "  Commit ID: $id" >&2
+       exit 1
+fi
+
+# We already saw the MOTD, thank you very much.
+rsync $RSYNC_FLAGS --ignore-existing --whole-file \
+       -v -r ".git/objects" "$uri" | grep -v '^MOTD:'
+
+# FIXME: Warn about conflicting tag names?
+rsync $RSYNC_FLAGS --ignore-existing \
+       -v -r ".git/tags" "$uri" 2>/dev/null | grep -v '^MOTD:'
+
+# Finally, update the remote HEAD
+rsync $RSYNC_FLAGS -Lr ".git/HEAD" "$uri/HEAD" \
+       2>/dev/null | grep -v '^MOTD:'
+
+echo "Now up to date."
+exit
+
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to