{"thread":{"id":"1822","subject":"[PATCH] Use objects/info/alternates in rsync transport.","startedAt":"2005-09-16T07:42:43Z","lastAt":"2005-09-16T07:42:43Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"8664","messageId":"7vslw5qwzw.fsf@assigned-by-dhcp.cox.net","threadId":"1822","inReplyTo":null,"subject":"[PATCH] Use objects/info/alternates in rsync transport.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-16T07:42:43Z","receivedAt":"2005-09-16T07:42:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"For local operations and downloading and uploading via git aware protocols,\nuse of $GIT_OBJECT_DIRECTORY/info/alternates is recommended on the server\nside for big projects that are derived from another one (like Linux kernel).\nHowever, dumb protocols and rsync transport needs to resolve this on the\nclient end, which we did not bother doing until this week.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * Hopefully this will be in 0.99.7 to allow downloaders deal\n   with kernel.org subsystem maintainer trees that borrow from\n   the Linus tree.\n\n * I noticed that \"rsync\" used -z, but most of the stuff we ship\n   are already compressed -- I wonder if this was done for a\n   reason or just inertia from somebody's finger?\n\n git-fetch.sh        |   23 +++++++++++++++++++++--\n git-parse-remote.sh |   22 ++++++++++++++++++++++\n 2 files changed, 43 insertions(+), 2 deletions(-)\n\n85dccff8f47f76a739f0263b0d03ab5b1b5bf127\ndiff --git a/git-fetch.sh b/git-fetch.sh\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -183,12 +183,31 @@ do\n \t;;\n     rsync://*)\n \tTMP_HEAD=\"$GIT_DIR/TMP_HEAD\"\n-\trsync -L \"$remote/$remote_name\" \"$TMP_HEAD\" || exit 1\n+\trsync -L -q \"$remote/$remote_name\" \"$TMP_HEAD\" || exit 1\n \thead=$(git-rev-parse TMP_HEAD)\n \trm -f \"$TMP_HEAD\"\n \ttest \"$rsync_slurped_objects\" || {\n-\t    rsync -avz --ignore-existing \"$remote/objects/\" \\\n+\t    rsync -a --ignore-existing --progress \\\n+\t\t--exclude info \"$remote/objects/\" \\\n \t\t\"$GIT_OBJECT_DIRECTORY/\" || exit\n+\n+\t    # Look at objects/info/alternates for rsync -- http will\n+\t    # support it natively and git native ones will do it on the remote\n+\t    # end.  Not having that file is not a crime.\n+\t    rsync -q \"$remote/objects/info/alternates\" \"$GIT_DIR/TMP_ALT\" ||\n+\t\t    rm -f \"$GIT_DIR/TMP_ALT\"\n+\t    if test -f \"$GIT_DIR/TMP_ALT\"\n+\t    then\n+\t\tresolve_alternates \"$remote\" <\"$GIT_DIR/TMP_ALT\" |\n+\t\twhile read alt\n+\t\tdo\n+\t\t    case \"$alt\" in 'bad alternate: '*) die \"$alt\";; esac\n+\t\t    rsync -a --ignore-existing \\\n+\t\t\t--exclude info \"$alt\" \\\n+\t\t\t\"$GIT_OBJECT_DIRECTORY/\" || exit\n+\t\tdone\n+\t\trm -f \"$GIT_DIR/TMP_ALT\"\n+\t    fi\n \t    rsync_slurped_objects=t\n \t}\n \t;;\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -153,3 +153,25 @@ get_remote_refs_for_fetch () {\n \t    ;;\n \tesac\n }\n+\n+resolve_alternates () {\n+\t# original URL (xxx.git)\n+\ttop_=`expr \"$1\" : '\\([^:]*:/*[^/]*\\)/'`\n+\twhile read path\n+\tdo\n+\t\tcase \"$path\" in\n+\t\t#* | '')\n+\t\t\tcontinue ;;\n+\t\t/*)\n+\t\t\techo \"$top_$path/\" ;;\n+\t\t../*)\n+\t\t\t# relative -- ugly but seems to work.\n+\t\t\techo \"$1/objects/$path/\" ;;\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# exit code may not be caught by the reader.\n+\t\t\techo \"bad alternate: $path\"\n+\t\t\texit 1 ;;\n+\t\tesac\n+\tdone\n+}\n"}]}