aboutsummaryrefslogtreecommitdiffstats
path: root/upload-pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 6d6e0f9f98..4f26f6afc7 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
@@ -9,7 +10,7 @@
#include "pkt-line.h"
#include "sideband.h"
#include "repository.h"
-#include "object-store-ll.h"
+#include "odb.h"
#include "oid-array.h"
#include "object.h"
#include "commit.h"
@@ -31,6 +32,7 @@
#include "write-or-die.h"
#include "json-writer.h"
#include "strmap.h"
+#include "promisor-remote.h"
/* Remember to update object flag allocation in object.h */
#define THEY_HAVE (1u << 11)
@@ -166,6 +168,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
object_array_clear(&data->extra_edge_obj);
list_objects_filter_release(&data->filter_options);
string_list_clear(&data->allowed_filters, 0);
+ string_list_clear(&data->uri_protocols, 0);
free((char *)data->pack_objects_hook);
}
@@ -317,6 +320,8 @@ 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 (repo_has_accepted_promisor_remote(the_repository))
+ strvec_push(&pack_objects.args, "--missing=allow-promisor");
if (pack_data->filter_options.choice) {
const char *spec =
expand_list_objects_filter_spec(&pack_data->filter_options);
@@ -504,8 +509,7 @@ static int got_oid(struct upload_pack_data *data,
{
if (get_oid_hex(hex, oid))
die("git upload-pack: expected SHA1 object, got '%s'", hex);
- if (!repo_has_object_file_with_flags(the_repository, oid,
- OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+ if (!odb_has_object(the_repository->objects, oid, 0))
return -1;
return do_got_oid(data, oid);
}
@@ -660,8 +664,8 @@ static int do_reachable_revlist(struct child_process *cmd,
cmd_in = xfdopen(cmd->in, "w");
- for (i = get_max_object_index(); 0 < i; ) {
- o = get_indexed_object(--i);
+ for (i = get_max_object_index(the_repository); 0 < i; ) {
+ o = get_indexed_object(the_repository, --i);
if (!o)
continue;
if (reachable && o->type == OBJ_COMMIT)
@@ -729,8 +733,8 @@ static int get_reachable_list(struct upload_pack_data *data,
o->flags &= ~TMP_MARK;
}
}
- for (i = get_max_object_index(); 0 < i; i--) {
- o = get_indexed_object(i - 1);
+ for (i = get_max_object_index(the_repository); 0 < i; i--) {
+ o = get_indexed_object(the_repository, i - 1);
if (o && o->type == OBJ_COMMIT &&
(o->flags & TMP_MARK)) {
add_object_array(o, NULL, reachable);
@@ -1025,10 +1029,14 @@ static int process_deepen_not(const char *line, struct oidset *deepen_not, int *
{
const char *arg;
if (skip_prefix(line, "deepen-not ", &arg)) {
+ int cnt;
char *ref = NULL;
struct object_id oid;
- if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
+ cnt = expand_ref(the_repository, arg, strlen(arg), &oid, &ref);
+ if (cnt > 1)
die("git upload-pack: ambiguous deepen-not: %s", line);
+ if (cnt < 1)
+ die("git upload-pack: deepen-not is not a ref: %s", line);
oidset_insert(deepen_not, &oid);
free(ref);
*deepen_rev_list = 1;
@@ -1440,7 +1448,7 @@ void upload_pack(const int advertise_refs, const int stateless_rpc,
for_each_namespaced_ref_1(send_ref, &data);
if (!data.sent_capabilities) {
const char *refname = "capabilities^{}";
- write_v0_ref(&data, refname, refname, null_oid());
+ write_v0_ref(&data, refname, refname, null_oid(the_hash_algo));
}
/*
* fflush stdout before calling advertise_shallow_grafts because send_ref
@@ -1548,7 +1556,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
}
if (!o)
- o = parse_object_or_die(&oid, refname_nons);
+ o = parse_object_or_die(the_repository, &oid, refname_nons);
if (!(o->flags & WANTED)) {
o->flags |= WANTED;
@@ -1772,27 +1780,27 @@ static void send_shallow_info(struct upload_pack_data *data)
packet_delim(1);
}
-enum fetch_state {
- FETCH_PROCESS_ARGS = 0,
- FETCH_SEND_ACKS,
- FETCH_SEND_PACK,
- FETCH_DONE,
+enum upload_state {
+ UPLOAD_PROCESS_ARGS = 0,
+ UPLOAD_SEND_ACKS,
+ UPLOAD_SEND_PACK,
+ UPLOAD_DONE,
};
int upload_pack_v2(struct repository *r, struct packet_reader *request)
{
- enum fetch_state state = FETCH_PROCESS_ARGS;
+ enum upload_state state = UPLOAD_PROCESS_ARGS;
struct upload_pack_data data;
- clear_object_flags(ALL_FLAGS);
+ clear_object_flags(the_repository, ALL_FLAGS);
upload_pack_data_init(&data);
data.use_sideband = LARGE_PACKET_MAX;
get_upload_pack_config(r, &data);
- while (state != FETCH_DONE) {
+ while (state != UPLOAD_DONE) {
switch (state) {
- case FETCH_PROCESS_ARGS:
+ case UPLOAD_PROCESS_ARGS:
process_args(request, &data);
if (!data.want_obj.nr && !data.wait_for_done) {
@@ -1803,27 +1811,27 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
* to just send 'have's without 'want's); guess
* they didn't want anything.
*/
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
} else if (data.seen_haves) {
/*
* Request had 'have' lines, so lets ACK them.
*/
- state = FETCH_SEND_ACKS;
+ state = UPLOAD_SEND_ACKS;
} else {
/*
* Request had 'want's but no 'have's so we can
* immediately go to construct and send a pack.
*/
- state = FETCH_SEND_PACK;
+ state = UPLOAD_SEND_PACK;
}
break;
- case FETCH_SEND_ACKS:
+ case UPLOAD_SEND_ACKS:
if (process_haves_and_send_acks(&data))
- state = FETCH_SEND_PACK;
+ state = UPLOAD_SEND_PACK;
else
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
break;
- case FETCH_SEND_PACK:
+ case UPLOAD_SEND_PACK:
send_wanted_ref_info(&data);
send_shallow_info(&data);
@@ -1833,9 +1841,9 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
packet_writer_write(&data.writer, "packfile\n");
create_pack_file(&data, NULL);
}
- state = FETCH_DONE;
+ state = UPLOAD_DONE;
break;
- case FETCH_DONE:
+ case UPLOAD_DONE:
continue;
}
}