From 6e7b66eebd18c11f58a9790b8f071618a1bb5b2c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 29 Jan 2013 14:02:15 -0800 Subject: fetch: fetch objects by their exact SHA-1 object names Teach "git fetch" to accept an exact SHA-1 object name the user may obtain out of band on the LHS of a pathspec, and send it on a "want" message when the server side advertises the allow-tip-sha1-in-want capability. Signed-off-by: Junio C Hamano --- fetch-pack.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'fetch-pack.c') diff --git a/fetch-pack.c b/fetch-pack.c index 915c0b7887..70db646517 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -36,7 +36,7 @@ static int marked; #define MAX_IN_VAIN 256 static struct commit_list *rev_list; -static int non_common_revs, multi_ack, use_sideband; +static int non_common_revs, multi_ack, use_sideband, allow_tip_sha1_in_want; static void rev_list_push(struct commit *commit, int mark) { @@ -563,6 +563,21 @@ static void filter_refs(struct fetch_pack_args *args, } } + /* Append unmatched requests to the list */ + if (allow_tip_sha1_in_want) { + for (i = 0; i < nr_sought; i++) { + ref = sought[i]; + if (ref->matched) + continue; + if (get_sha1_hex(ref->name, ref->old_sha1)) + continue; + + ref->matched = 1; + *newtail = ref; + ref->next = NULL; + newtail = &ref->next; + } + } *refs = newlist; } @@ -803,6 +818,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, fprintf(stderr, "Server supports side-band\n"); use_sideband = 1; } + if (server_supports("allow-tip-sha1-in-want")) { + if (args->verbose) + fprintf(stderr, "Server supports allow-tip-sha1-in-want\n"); + allow_tip_sha1_in_want = 1; + } if (!server_supports("thin-pack")) args->use_thin_pack = 0; if (!server_supports("no-progress")) -- cgit v1.2.3