Git development
 help / color / mirror / Atom feed
From: Matthias Urlichs <smurf@smurf.noris.de>
To: git@vger.kernel.org
Subject: [PATCH] Add "git push"
Date: Thu, 21 Apr 2005 22:43:33 +1000 (EST)	[thread overview]
Message-ID: <20050421124333.AB2CE7F887@smurf.noris.de> (raw)

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

Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>

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
+

             reply	other threads:[~2005-04-21 12:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21 12:43 Matthias Urlichs [this message]
2005-04-21 20:41 ` [PATCH] Add "git push" Petr Baudis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050421124333.AB2CE7F887@smurf.noris.de \
    --to=smurf@smurf.noris.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox