help_unknown_ref(): duplicate collected refnames
[gitweb.git] / upload-pack.c
index 0c1feccaabac10fcb26828e0265f5aa053952253..d098ef598289d16956309cb73d4518a92c1206af 100644 (file)
@@ -43,7 +43,6 @@
 
 static timestamp_t oldest_have;
 
-static int deepen_relative;
 static int multi_ack;
 static int no_done;
 static int use_thin_pack, use_ofs_delta, use_include_tag;
@@ -142,14 +141,17 @@ static void create_pack_file(const struct object_array *have_obj,
        if (use_include_tag)
                argv_array_push(&pack_objects.args, "--include-tag");
        if (filter_options.filter_spec) {
+               struct strbuf expanded_filter_spec = STRBUF_INIT;
+               expand_list_objects_filter_spec(&filter_options,
+                                               &expanded_filter_spec);
                if (pack_objects.use_shell) {
                        struct strbuf buf = STRBUF_INIT;
-                       sq_quote_buf(&buf, filter_options.filter_spec);
+                       sq_quote_buf(&buf, expanded_filter_spec.buf);
                        argv_array_pushf(&pack_objects.args, "--filter=%s", buf.buf);
                        strbuf_release(&buf);
                } else {
                        argv_array_pushf(&pack_objects.args, "--filter=%s",
-                                        filter_options.filter_spec);
+                                        expanded_filter_spec.buf);
                }
        }
 
@@ -666,6 +668,8 @@ static void send_unshallow(struct packet_writer *writer,
        }
 }
 
+static int check_ref(const char *refname_full, const struct object_id *oid,
+                    int flag, void *cb_data);
 static void deepen(struct packet_writer *writer, int depth, int deepen_relative,
                   struct object_array *shallows, struct object_array *want_obj)
 {
@@ -680,6 +684,13 @@ static void deepen(struct packet_writer *writer, int depth, int deepen_relative,
                struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
                struct commit_list *result;
 
+               /*
+                * Checking for reachable shallows requires that our refs be
+                * marked with OUR_REF.
+                */
+               head_ref_namespaced(check_ref, NULL);
+               for_each_namespaced_ref(check_ref, NULL);
+
                get_reachable_list(shallows, &reachable_shallows);
                result = get_shallow_commits(&reachable_shallows,
                                             depth + 1,
@@ -718,6 +729,7 @@ static int send_shallow_list(struct packet_writer *writer,
                             int depth, int deepen_rev_list,
                             timestamp_t deepen_since,
                             struct string_list *deepen_not,
+                            int deepen_relative,
                             struct object_array *shallows,
                             struct object_array *want_obj)
 {
@@ -840,6 +852,7 @@ static void receive_needs(struct packet_reader *reader, struct object_array *wan
        int has_non_tip = 0;
        timestamp_t deepen_since = 0;
        int deepen_rev_list = 0;
+       int deepen_relative = 0;
        struct packet_writer writer;
 
        shallow_nr = 0;
@@ -932,7 +945,8 @@ static void receive_needs(struct packet_reader *reader, struct object_array *wan
                return;
 
        if (send_shallow_list(&writer, depth, deepen_rev_list, deepen_since,
-                             &deepen_not, &shallows, want_obj))
+                             &deepen_not, deepen_relative, &shallows,
+                             want_obj))
                packet_flush(1);
        object_array_clear(&shallows);
 }
@@ -1421,6 +1435,7 @@ static void send_shallow_info(struct upload_pack_data *data,
        if (!send_shallow_list(&data->writer, data->depth,
                               data->deepen_rev_list,
                               data->deepen_since, &data->deepen_not,
+                              data->deepen_relative,
                               &data->shallows, want_obj) &&
            is_repository_shallow(the_repository))
                deepen(&data->writer, INFINITE_DEPTH, data->deepen_relative,