path: root/upload-pack.c
diff options
authorLinus Torvalds <>2009-04-11 00:27:58 (GMT)
committerJunio C Hamano <>2009-04-13 00:28:31 (GMT)
commit8d2dfc49b199c7da6faefd7993630f24bd37fee0 (patch)
treef1e54aab7902cde544d1ac8ea41401fdea431184 /upload-pack.c
parent213152688c85a0e4d591abc1c10b7c279ffefb99 (diff)
process_{tree,blob}: show objects without buffering
Here's a less trivial thing, and slightly more dubious one. I was looking at that "struct object_array objects", and wondering why we do that. I have honestly totally forgotten. Why not just call the "show()" function as we encounter the objects? Rather than add the objects to the object_array, and then at the very end going through the array and doing a 'show' on all, just do things more incrementally. Now, there are possible downsides to this: - the "buffer using object_array" _can_ in theory result in at least better I-cache usage (two tight loops rather than one more spread out one). I don't think this is a real issue, but in theory.. - this _does_ change the order of the objects printed. Instead of doing a "process_tree(revs, commit->tree, &objects, NULL, "");" in the loop over the commits (which puts all the root trees _first_ in the object list, this patch just adds them to the list of pending objects, and then we'll traverse them in that order (and thus show each root tree object together with the objects we discover under it) I _think_ the new ordering actually makes more sense, but the object ordering is actually a subtle thing when it comes to packing efficiency, so any change in order is going to have implications for packing. Good or bad, I dunno. - There may be some reason why we did it that odd way with the object array, that I have simply forgotten. Anyway, now that we don't buffer up the objects before showing them that may actually result in lower memory usage during that whole traverse_commit_list() phase. This is seriously not very deeply tested. It makes sense to me, it seems to pass all the tests, it looks ok, but... Does anybody remember why we did that "object_array" thing? It used to be an "object_list" a long long time ago, but got changed into the array due to better memory usage patterns (those linked lists of obejcts are horrible from a memory allocation standpoint). But I wonder why we didn't do this back then. Maybe there's a reason for it. Or maybe there _used_ to be a reason, and no longer is. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'upload-pack.c')
1 files changed, 6 insertions, 6 deletions
diff --git a/upload-pack.c b/upload-pack.c
index e5adbc0..bdbd67b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -78,20 +78,20 @@ static void show_commit(struct commit *commit)
commit->buffer = NULL;
-static void show_object(struct object_array_entry *p)
+static void show_object(struct object *obj, const char *name)
/* An object with name "foo\n0000000..." can be used to
* confuse downstream git-pack-objects very badly.
- const char *ep = strchr(p->name, '\n');
+ const char *ep = strchr(name, '\n');
if (ep) {
- fprintf(pack_pipe, "%s %.*s\n", sha1_to_hex(p->item->sha1),
- (int) (ep - p->name),
- p->name);
+ fprintf(pack_pipe, "%s %.*s\n", sha1_to_hex(obj->sha1),
+ (int) (ep - name),
+ name);
fprintf(pack_pipe, "%s %s\n",
- sha1_to_hex(p->item->sha1), p->name);
+ sha1_to_hex(obj->sha1), name);
static void show_edge(struct commit *commit)