diff options
Diffstat (limited to 'upload-pack.c')
-rw-r--r-- | upload-pack.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/upload-pack.c b/upload-pack.c index 902144b9d3..e616a5cb03 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -29,6 +29,8 @@ #include "write-or-die.h" #include "json-writer.h" #include "strmap.h" +#include "missing.h" +#include "object-file.h" /* Remember to update object flag allocation in object.h */ #define THEY_HAVE (1u << 11) @@ -94,7 +96,9 @@ struct upload_pack_data { struct packet_writer writer; - const char *pack_objects_hook; + char *pack_objects_hook; + + enum missing_action missing_action; unsigned stateless_rpc : 1; /* v0 only */ unsigned no_done : 1; /* v0 only */ @@ -315,6 +319,9 @@ static void create_pack_file(struct upload_pack_data *pack_data, strvec_push(&pack_objects.args, "--delta-base-offset"); if (pack_data->use_include_tag) strvec_push(&pack_objects.args, "--include-tag"); + if (pack_data->missing_action) + strvec_pushf(&pack_objects.args, "--missing=%s", + missing_action_to_string(pack_data->missing_action)); if (pack_data->filter_options.choice) { const char *spec = expand_list_objects_filter_spec(&pack_data->filter_options); @@ -618,7 +625,8 @@ static void for_each_namespaced_ref_1(each_ref_fn fn, if (allow_hidden_refs(data->allow_uor)) excludes = hidden_refs_to_excludes(&data->hidden_refs); - for_each_namespaced_ref(excludes, fn, data); + refs_for_each_namespaced_ref(get_main_ref_store(the_repository), + excludes, fn, data); } @@ -873,7 +881,8 @@ static void deepen(struct upload_pack_data *data, int depth) * Checking for reachable shallows requires that our refs be * marked with OUR_REF. */ - head_ref_namespaced(check_ref, data); + refs_head_ref_namespaced(get_main_ref_store(the_repository), + check_ref, data); for_each_namespaced_ref_1(check_ref, data); get_reachable_list(data, &reachable_shallows); @@ -1267,7 +1276,7 @@ static void write_v0_ref(struct upload_pack_data *data, packet_fwrite_fmt(stdout, "%s %s\n", oid_to_hex(oid), refname_nons); } capabilities = NULL; - if (!peel_iterated_oid(oid, &peeled)) + if (!peel_iterated_oid(the_repository, oid, &peeled)) packet_fwrite_fmt(stdout, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons); return; } @@ -1288,7 +1297,8 @@ static int find_symref(const char *refname, if ((flag & REF_ISSYMREF) == 0) return 0; - symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag); + symref_target = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), + refname, 0, NULL, &flag); if (!symref_target || (flag & REF_ISSYMREF) == 0) die("'%s' is a symref but it is not?", refname); item = string_list_append(cb_data, strip_namespace(refname)); @@ -1371,6 +1381,16 @@ static int upload_pack_config(const char *var, const char *value, precomposed_unicode = git_config_bool(var, value); } else if (!strcmp("transfer.advertisesid", var)) { data->advertise_sid = git_config_bool(var, value); + } else if (!strcmp("uploadpack.missingaction", var)) { + int res = parse_missing_action_value_for_packing(value); + if (res < 0) + die(_("invalid value for '%s': '%s'"), var, value); + /* Allow fetching only from promisor remotes */ + if (res == MA_ALLOW_PROMISOR) + fetch_if_missing = 1; + if (res == MA_ALLOW_ANY) + fetch_if_missing = 0; + data->missing_action = res; } if (parse_object_filter_config(var, value, ctx->kvi, data) < 0) @@ -1413,13 +1433,15 @@ void upload_pack(const int advertise_refs, const int stateless_rpc, if (data.timeout) data.daemon_mode = 1; - head_ref_namespaced(find_symref, &data.symref); + refs_head_ref_namespaced(get_main_ref_store(the_repository), + find_symref, &data.symref); if (advertise_refs || !data.stateless_rpc) { reset_timeout(data.timeout); if (advertise_refs) data.no_done = 1; - head_ref_namespaced(send_ref, &data); + refs_head_ref_namespaced(get_main_ref_store(the_repository), + send_ref, &data); for_each_namespaced_ref_1(send_ref, &data); if (!data.sent_capabilities) { const char *refname = "capabilities^{}"; @@ -1433,7 +1455,8 @@ void upload_pack(const int advertise_refs, const int stateless_rpc, advertise_shallow_grafts(1); packet_flush(1); } else { - head_ref_namespaced(check_ref, &data); + refs_head_ref_namespaced(get_main_ref_store(the_repository), + check_ref, &data); for_each_namespaced_ref_1(check_ref, &data); } @@ -1511,7 +1534,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line, strbuf_addf(&refname, "%s%s", get_git_namespace(), refname_nons); if (ref_is_hidden(refname_nons, refname.buf, hidden_refs) || - read_ref(refname.buf, &oid)) { + refs_read_ref(get_main_ref_store(the_repository), refname.buf, &oid)) { packet_writer_error(writer, "unknown ref %s", refname_nons); die("unknown ref %s", refname_nons); } |