Revert "Replace zero-length array decls with []."
[gitweb.git] / pull.c
diff --git a/pull.c b/pull.c
index 950d9f47bd03516ec9e25bfc6742f8582a4197ab..ff550441e92339bd5c6fa70d8891ab208410a03e 100644 (file)
--- a/pull.c
+++ b/pull.c
@@ -98,12 +98,39 @@ static int process_tag(struct tag *tag)
 static struct object_list *process_queue = NULL;
 static struct object_list **process_queue_end = &process_queue;
 
-static int process(unsigned char *sha1, const char *type)
+static int process_object(struct object *obj)
 {
-       struct object *obj;
-       if (has_sha1_file(sha1))
+       if (obj->type == commit_type) {
+               if (process_commit((struct commit *)obj))
+                       return -1;
+               return 0;
+       }
+       if (obj->type == tree_type) {
+               if (process_tree((struct tree *)obj))
+                       return -1;
+               return 0;
+       }
+       if (obj->type == blob_type) {
+               return 0;
+       }
+       if (obj->type == tag_type) {
+               if (process_tag((struct tag *)obj))
+                       return -1;
                return 0;
-       obj = lookup_object_type(sha1, type);
+       }
+       return error("Unable to determine requirements "
+                    "of type %s for %s",
+                    obj->type, sha1_to_hex(obj->sha1));
+}
+
+static int process(unsigned char *sha1, const char *type)
+{
+       struct object *obj = lookup_object_type(sha1, type);
+       if (has_sha1_file(sha1)) {
+               parse_object(sha1);
+               /* We already have it, so we should scan it now. */
+               return process_object(obj);
+       }
        if (object_list_contains(process_queue, obj))
                return 0;
        object_list_insert(obj, process_queue_end);
@@ -129,32 +156,13 @@ static int loop(void)
 
                //fprintf(stderr, "fetch %s\n", sha1_to_hex(obj->sha1));
                
-               if (make_sure_we_have_it(obj->type ?: "object", 
+               if (make_sure_we_have_it(obj->type ? obj->type : "object", 
                                         obj->sha1))
                        return -1;
                if (!obj->type)
                        parse_object(obj->sha1);
-               if (obj->type == commit_type) {
-                       if (process_commit((struct commit *)obj))
-                               return -1;
-                       continue;
-               }
-               if (obj->type == tree_type) {
-                       if (process_tree((struct tree *)obj))
-                               return -1;
-                       continue;
-               }
-               if (obj->type == blob_type) {
-                       continue;
-               }
-               if (obj->type == tag_type) {
-                       if (process_tag((struct tag *)obj))
-                               return -1;
-                       continue;
-               }
-               return error("Unable to determine requirements "
-                            "of type %s for %s",
-                            obj->type, sha1_to_hex(obj->sha1));
+               if (process_object(obj))
+                       return -1;
        }
        return 0;
 }