{"thread":{"id":"1437","subject":"[PATCH] send-pack: allow generic sha1 expression on the source side.","startedAt":"2005-08-06T17:24:35Z","lastAt":"2005-08-06T17:24:35Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6882","messageId":"7vek979dws.fsf@assigned-by-dhcp.cox.net","threadId":"1437","inReplyTo":null,"subject":"[PATCH] send-pack: allow generic sha1 expression on the source side.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-06T17:24:35Z","receivedAt":"2005-08-06T17:24:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As promised earlier.  I will shortly push this out with another\nsend-pack fix, initially in the proposed updates branch.\n\n------------\nThis extends the source side semantics to match what Linus\nsuggested.\n\nAn example:\n\n    $ git-send-pack kernel.org:/pub/scm/git/git.git pu^^:master pu\n\n    would allow me to push the current pu into pu, and the\n    commit two commits before it into master, on my public\n    repository.\n\nThe revised rule for updating remote heads is as follows.\n\n $ git-send-pack [--all] <remote> [<ref>...]\n\n - When no <ref> is specified:\n\n   - with '--all', it is the same as specifying the full refs/*\n     path for all local refs;\n\n   - without '--all', it is the same as specifying the full\n     refs/* path for refs that exist on both ends;\n\n - When one or more <ref>s are specified:\n\n   - a single token <ref> (i.e. no colon) must be a pattern that\n     tail-matches refs/* path for an existing local ref.  It is\n     an error for the pattern to match no local ref, or more\n     than one local refs.  The matching ref is pushed to the\n     remote end under the same name.\n\n   - <src>:<dst> can have different cases.  <src> is first tried\n     as the tail-matching pattern for refs/* path.\n\n     - If more than one matches are found, it is an error.\n\n     - If one match is found, <dst> must either match no remote\n       ref and start with \"refs/\", or match exactly one remote\n       ref.  That remote ref is updated with the sha1 value\n       obtained from the <src> sha1.\n\n     - If no match is found, it is given to get_extended_sha1();\n       it is an error if get_extended_sha1() does not find an\n       object name.  If it succeeds, <dst> must either match\n       no remote ref and start with \"refs/\" or match exactly\n       one remote ref.  That remote ref is updated with the sha1\n       value.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n connect.c |   20 ++++++++++++++++++++\n 1 files changed, 20 insertions(+), 0 deletions(-)\n\n15e02b372ddebd2aac829707786462798f91d509\ndiff --git a/connect.c b/connect.c\n--- a/connect.c\n+++ b/connect.c\n@@ -133,6 +133,20 @@ static void link_dst_tail(struct ref *re\n \t**tail = NULL;\n }\n \n+static struct ref *try_explicit_object_name(const char *name)\n+{\n+\tunsigned char sha1[20];\n+\tstruct ref *ref;\n+\tint len;\n+\tif (get_sha1(name, sha1))\n+\t\treturn NULL;\n+\tlen = strlen(name) + 1;\n+\tref = xcalloc(1, sizeof(*ref) + len);\n+\tmemcpy(ref->name, name, len);\n+\tmemcpy(ref->new_sha1, sha1, 20);\n+\treturn ref;\n+}\n+\n static int match_explicit_refs(struct ref *src, struct ref *dst,\n \t\t\t       struct ref ***dst_tail, struct refspec *rs)\n {\n@@ -145,6 +159,12 @@ static int match_explicit_refs(struct re\n \t\tcase 1:\n \t\t\tbreak;\n \t\tcase 0:\n+\t\t\t/* The source could be in the get_sha1() format\n+\t\t\t * not a reference name.\n+\t\t\t */\n+\t\t\tmatched_src = try_explicit_object_name(rs[i].src);\n+\t\t\tif (matched_src)\n+\t\t\t\tbreak;\n \t\t\terrs = 1;\n \t\t\terror(\"src refspec %s does not match any.\");\n \t\t\tbreak;\n"}]}