Merge branch 'tb/core-eol-fix' into maint
[gitweb.git] / upload-pack.c
index d0bc3ca07ab1b005884c80901ea8dee04452b71a..dc802a07c2225463c2e4ee923b9cf144d57a00cc 100644 (file)
@@ -90,35 +90,32 @@ static void create_pack_file(void)
                "corruption on the remote side.";
        int buffered = -1;
        ssize_t sz;
-       const char *argv[13];
-       int i, arg = 0;
+       int i;
        FILE *pipe_fd;
 
        if (shallow_nr) {
-               argv[arg++] = "--shallow-file";
-               argv[arg++] = "";
+               argv_array_push(&pack_objects.args, "--shallow-file");
+               argv_array_push(&pack_objects.args, "");
        }
-       argv[arg++] = "pack-objects";
-       argv[arg++] = "--revs";
+       argv_array_push(&pack_objects.args, "pack-objects");
+       argv_array_push(&pack_objects.args, "--revs");
        if (use_thin_pack)
-               argv[arg++] = "--thin";
+               argv_array_push(&pack_objects.args, "--thin");
 
-       argv[arg++] = "--stdout";
+       argv_array_push(&pack_objects.args, "--stdout");
        if (shallow_nr)
-               argv[arg++] = "--shallow";
+               argv_array_push(&pack_objects.args, "--shallow");
        if (!no_progress)
-               argv[arg++] = "--progress";
+               argv_array_push(&pack_objects.args, "--progress");
        if (use_ofs_delta)
-               argv[arg++] = "--delta-base-offset";
+               argv_array_push(&pack_objects.args, "--delta-base-offset");
        if (use_include_tag)
-               argv[arg++] = "--include-tag";
-       argv[arg++] = NULL;
+               argv_array_push(&pack_objects.args, "--include-tag");
 
        pack_objects.in = -1;
        pack_objects.out = -1;
        pack_objects.err = -1;
        pack_objects.git_cmd = 1;
-       pack_objects.argv = argv;
 
        if (start_command(&pack_objects))
                die("git upload-pack: unable to fork git-pack-objects");
@@ -130,14 +127,14 @@ static void create_pack_file(void)
 
        for (i = 0; i < want_obj.nr; i++)
                fprintf(pipe_fd, "%s\n",
-                       sha1_to_hex(want_obj.objects[i].item->sha1));
+                       oid_to_hex(&want_obj.objects[i].item->oid));
        fprintf(pipe_fd, "--not\n");
        for (i = 0; i < have_obj.nr; i++)
                fprintf(pipe_fd, "%s\n",
-                       sha1_to_hex(have_obj.objects[i].item->sha1));
+                       oid_to_hex(&have_obj.objects[i].item->oid));
        for (i = 0; i < extra_edge_obj.nr; i++)
                fprintf(pipe_fd, "%s\n",
-                       sha1_to_hex(extra_edge_obj.objects[i].item->sha1));
+                       oid_to_hex(&extra_edge_obj.objects[i].item->oid));
        fprintf(pipe_fd, "\n");
        fflush(pipe_fd);
        fclose(pipe_fd);
@@ -324,7 +321,7 @@ static int reachable(struct commit *want)
                        break;
                }
                if (!commit->object.parsed)
-                       parse_object(commit->object.sha1);
+                       parse_object(commit->object.oid.hash);
                if (commit->object.flags & REACHABLE)
                        continue;
                commit->object.flags |= REACHABLE;
@@ -491,7 +488,7 @@ static void check_non_tip(void)
                        continue;
                if (!is_our_ref(o))
                        continue;
-               memcpy(namebuf + 1, sha1_to_hex(o->sha1), 40);
+               memcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
                if (write_in_full(cmd.in, namebuf, 42) < 0)
                        goto error;
        }
@@ -500,7 +497,7 @@ static void check_non_tip(void)
                o = want_obj.objects[i].item;
                if (is_our_ref(o))
                        continue;
-               memcpy(namebuf, sha1_to_hex(o->sha1), 40);
+               memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
                if (write_in_full(cmd.in, namebuf, 41) < 0)
                        goto error;
        }
@@ -534,7 +531,7 @@ static void check_non_tip(void)
                o = want_obj.objects[i].item;
                if (!is_our_ref(o))
                        die("git upload-pack: not our ref %s",
-                           sha1_to_hex(o->sha1));
+                           oid_to_hex(&o->oid));
        }
 }
 
@@ -646,8 +643,8 @@ static void receive_needs(void)
                        struct object *object = &result->item->object;
                        if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
                                packet_write(1, "shallow %s",
-                                               sha1_to_hex(object->sha1));
-                               register_shallow(object->sha1);
+                                               oid_to_hex(&object->oid));
+                               register_shallow(object->oid.hash);
                                shallow_nr++;
                        }
                        result = result->next;
@@ -658,10 +655,10 @@ static void receive_needs(void)
                        if (object->flags & NOT_SHALLOW) {
                                struct commit_list *parents;
                                packet_write(1, "unshallow %s",
-                                       sha1_to_hex(object->sha1));
+                                       oid_to_hex(&object->oid));
                                object->flags &= ~CLIENT_SHALLOW;
                                /* make sure the real parents are parsed */
-                               unregister_shallow(object->sha1);
+                               unregister_shallow(object->oid.hash);
                                object->parsed = 0;
                                parse_commit_or_die((struct commit *)object);
                                parents = ((struct commit *)object)->parents;
@@ -673,14 +670,14 @@ static void receive_needs(void)
                                add_object_array(object, NULL, &extra_edge_obj);
                        }
                        /* make sure commit traversal conforms to client */
-                       register_shallow(object->sha1);
+                       register_shallow(object->oid.hash);
                }
                packet_flush(1);
        } else
                if (shallows.nr > 0) {
                        int i;
                        for (i = 0; i < shallows.nr; i++)
-                               register_shallow(shallows.objects[i].item->sha1);
+                               register_shallow(shallows.objects[i].item->oid.hash);
                }
 
        shallow_nr += shallows.nr;
@@ -688,11 +685,12 @@ static void receive_needs(void)
 }
 
 /* return non-zero if the ref is hidden, otherwise 0 */
-static int mark_our_ref(const char *refname, const struct object_id *oid)
+static int mark_our_ref(const char *refname, const char *refname_full,
+                       const struct object_id *oid)
 {
        struct object *o = lookup_unknown_object(oid->hash);
 
-       if (ref_is_hidden(refname)) {
+       if (ref_is_hidden(refname, refname_full)) {
                o->flags |= HIDDEN_REF;
                return 1;
        }
@@ -700,10 +698,12 @@ static int mark_our_ref(const char *refname, const struct object_id *oid)
        return 0;
 }
 
-static int check_ref(const char *refname, const struct object_id *oid,
+static int check_ref(const char *refname_full, const struct object_id *oid,
                     int flag, void *cb_data)
 {
-       mark_our_ref(refname, oid);
+       const char *refname = strip_namespace(refname_full);
+
+       mark_our_ref(refname, refname_full, oid);
        return 0;
 }
 
@@ -726,7 +726,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
        const char *refname_nons = strip_namespace(refname);
        struct object_id peeled;
 
-       if (mark_our_ref(refname, oid))
+       if (mark_our_ref(refname_nons, refname, oid))
                return 0;
 
        if (capabilities) {