git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Use objects/info/alternates in rsync transport.
@ 2005-09-16  7:42 Junio C Hamano
  0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2005-09-16  7:42 UTC (permalink / raw
  To: git

For local operations and downloading and uploading via git aware protocols,
use of $GIT_OBJECT_DIRECTORY/info/alternates is recommended on the server
side for big projects that are derived from another one (like Linux kernel).
However, dumb protocols and rsync transport needs to resolve this on the
client end, which we did not bother doing until this week.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * Hopefully this will be in 0.99.7 to allow downloaders deal
   with kernel.org subsystem maintainer trees that borrow from
   the Linus tree.

 * I noticed that "rsync" used -z, but most of the stuff we ship
   are already compressed -- I wonder if this was done for a
   reason or just inertia from somebody's finger?

 git-fetch.sh        |   23 +++++++++++++++++++++--
 git-parse-remote.sh |   22 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 2 deletions(-)

85dccff8f47f76a739f0263b0d03ab5b1b5bf127
diff --git a/git-fetch.sh b/git-fetch.sh
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -183,12 +183,31 @@ do
 	;;
     rsync://*)
 	TMP_HEAD="$GIT_DIR/TMP_HEAD"
-	rsync -L "$remote/$remote_name" "$TMP_HEAD" || exit 1
+	rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
 	head=$(git-rev-parse TMP_HEAD)
 	rm -f "$TMP_HEAD"
 	test "$rsync_slurped_objects" || {
-	    rsync -avz --ignore-existing "$remote/objects/" \
+	    rsync -a --ignore-existing --progress \
+		--exclude info "$remote/objects/" \
 		"$GIT_OBJECT_DIRECTORY/" || exit
+
+	    # Look at objects/info/alternates for rsync -- http will
+	    # support it natively and git native ones will do it on the remote
+	    # end.  Not having that file is not a crime.
+	    rsync -q "$remote/objects/info/alternates" "$GIT_DIR/TMP_ALT" ||
+		    rm -f "$GIT_DIR/TMP_ALT"
+	    if test -f "$GIT_DIR/TMP_ALT"
+	    then
+		resolve_alternates "$remote" <"$GIT_DIR/TMP_ALT" |
+		while read alt
+		do
+		    case "$alt" in 'bad alternate: '*) die "$alt";; esac
+		    rsync -a --ignore-existing \
+			--exclude info "$alt" \
+			"$GIT_OBJECT_DIRECTORY/" || exit
+		done
+		rm -f "$GIT_DIR/TMP_ALT"
+	    fi
 	    rsync_slurped_objects=t
 	}
 	;;
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -153,3 +153,25 @@ get_remote_refs_for_fetch () {
 	    ;;
 	esac
 }
+
+resolve_alternates () {
+	# original URL (xxx.git)
+	top_=`expr "$1" : '\([^:]*:/*[^/]*\)/'`
+	while read path
+	do
+		case "$path" in
+		#* | '')
+			continue ;;
+		/*)
+			echo "$top_$path/" ;;
+		../*)
+			# relative -- ugly but seems to work.
+			echo "$1/objects/$path/" ;;
+			;;
+		*)
+			# exit code may not be caught by the reader.
+			echo "bad alternate: $path"
+			exit 1 ;;
+		esac
+	done
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-16  7:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-16  7:42 [PATCH] Use objects/info/alternates in rsync transport Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).