transport: simplify duplicating a substring in transport_get() using xmemdupz()
[gitweb.git] / list-objects.c
index 3595ee7a22c4d6099ea9b995ffe1c61c60bb77cd..2910becd6c65b66670215aefdf08e1933895aa39 100644 (file)
@@ -208,6 +208,7 @@ void traverse_commit_list(struct rev_info *revs,
                struct object_array_entry *pending = revs->pending.objects + i;
                struct object *obj = pending->item;
                const char *name = pending->name;
+               const char *path = pending->path;
                if (obj->flags & (UNINTERESTING | SEEN))
                        continue;
                if (obj->type == OBJ_TAG) {
@@ -215,24 +216,21 @@ void traverse_commit_list(struct rev_info *revs,
                        show_object(obj, NULL, name, data);
                        continue;
                }
+               if (!path)
+                       path = "";
                if (obj->type == OBJ_TREE) {
                        process_tree(revs, (struct tree *)obj, show_object,
-                                    NULL, &base, name, data);
+                                    NULL, &base, path, data);
                        continue;
                }
                if (obj->type == OBJ_BLOB) {
                        process_blob(revs, (struct blob *)obj, show_object,
-                                    NULL, name, data);
+                                    NULL, path, data);
                        continue;
                }
                die("unknown pending object %s (%s)",
                    sha1_to_hex(obj->sha1), name);
        }
-       if (revs->pending.nr) {
-               free(revs->pending.objects);
-               revs->pending.nr = 0;
-               revs->pending.alloc = 0;
-               revs->pending.objects = NULL;
-       }
+       object_array_clear(&revs->pending);
        strbuf_release(&base);
 }