diff options
author | Fredrik Medley <fredrik.medley@gmail.com> | 2015-05-21 22:23:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-22 18:25:36 -0700 |
commit | 68ee628932c2196742b77d2961c5e16360734a62 (patch) | |
tree | d291d037badd372d77b6d405c2984858beba4f1e /fetch-pack.c | |
parent | 7199c093ad4a90bd0d9012681b6a148ab8c945e3 (diff) | |
download | git-68ee628932c2196742b77d2961c5e16360734a62.tar.gz |
upload-pack: optionally allow fetching reachable sha1fm/fetch-raw-sha1
With uploadpack.allowReachableSHA1InWant configuration option set on the
server side, "git fetch" can make a request with a "want" line that names
an object that has not been advertised (likely to have been obtained out
of band or from a submodule pointer). Only objects reachable from the
branch tips, i.e. the union of advertised branches and branches hidden by
transfer.hideRefs, will be processed. Note that there is an associated
cost of having to walk back the history to check the reachability.
This feature can be used when obtaining the content of a certain commit,
for which the sha1 is known, without the need of cloning the whole
repository, especially if a shallow fetch is used. Useful cases are e.g.
repositories containing large files in the history, fetching only the
needed data for a submodule checkout, when sharing a sha1 without telling
which exact branch it belongs to and in Gerrit, if you think in terms of
commits instead of change numbers. (The Gerrit case has already been
solved through allowTipSHA1InWant as every Gerrit change has a ref.)
Signed-off-by: Fredrik Medley <fredrik.medley@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index ff5bd5c48b..ff8a13b8c4 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -46,6 +46,8 @@ static struct prio_queue rev_list = { compare_commits_by_commit_date }; static int non_common_revs, multi_ack, use_sideband; /* Allow specifying sha1 if it is a ref tip. */ #define ALLOW_TIP_SHA1 01 +/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */ +#define ALLOW_REACHABLE_SHA1 02 static unsigned int allow_unadvertised_object_request; static void rev_list_push(struct commit *commit, int mark) @@ -545,7 +547,8 @@ static void filter_refs(struct fetch_pack_args *args, } /* Append unmatched requests to the list */ - if ((allow_unadvertised_object_request & ALLOW_TIP_SHA1)) { + if ((allow_unadvertised_object_request & + (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1))) { for (i = 0; i < nr_sought; i++) { unsigned char sha1[20]; @@ -826,6 +829,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, fprintf(stderr, "Server supports allow-tip-sha1-in-want\n"); allow_unadvertised_object_request |= ALLOW_TIP_SHA1; } + if (server_supports("allow-reachable-sha1-in-want")) { + if (args->verbose) + fprintf(stderr, "Server supports allow-reachable-sha1-in-want\n"); + allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1; + } if (!server_supports("thin-pack")) args->use_thin_pack = 0; if (!server_supports("no-progress")) |