prefix_filename: drop length parameter
[gitweb.git] / builtin / receive-pack.c
index c23b0cce8607e8361a603cc23803eed6562b85cd..83492af05f2bfd8ca1ec796b7ae8dccc84f0f31b 100644 (file)
@@ -268,6 +268,8 @@ static int show_ref_cb(const char *path_full, const struct object_id *oid,
                if (oidset_insert(seen, oid))
                        return 0;
                path = ".have";
+       } else {
+               oidset_insert(seen, oid);
        }
        show_ref(path, oid->hash);
        return 0;
@@ -289,9 +291,9 @@ static void write_head_info(void)
 {
        static struct oidset seen = OIDSET_INIT;
 
+       for_each_ref(show_ref_cb, &seen);
        for_each_alternate_ref(show_one_alternate_ref, &seen);
        oidset_clear(&seen);
-       for_each_ref(show_ref_cb, &seen);
        if (!sent_capabilities)
                show_ref("capabilities^{}", null_sha1);
 
@@ -1415,7 +1417,7 @@ static void execute_commands(struct command *commands,
 {
        struct check_connected_options opt = CHECK_CONNECTED_INIT;
        struct command *cmd;
-       unsigned char sha1[20];
+       struct object_id oid;
        struct iterate_data data;
        struct async muxer;
        int err_fd = 0;
@@ -1472,7 +1474,7 @@ static void execute_commands(struct command *commands,
        check_aliased_updates(commands);
 
        free(head_name_to_free);
-       head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL);
+       head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL);
 
        if (use_atomic)
                execute_commands_atomic(commands, si);
@@ -1665,8 +1667,11 @@ static const char *unpack(int err_fd, struct shallow_info *si)
        }
 
        tmp_objdir = tmp_objdir_create();
-       if (!tmp_objdir)
+       if (!tmp_objdir) {
+               if (err_fd > 0)
+                       close(err_fd);
                return "unable to create temporary object directory";
+       }
        child.env = tmp_objdir_env(tmp_objdir);
 
        /*