log: do not free parents when walking reflog
authorJeff King <peff@peff.net>
Fri, 7 Jul 2017 09:07:34 +0000 (05:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Jul 2017 17:00:48 +0000 (10:00 -0700)
When we're doing a reflog walk (instead of walking the
actual parent pointers), we may see commits multiple times.
For this reason, we hold on to the commit buffer for each
commit rather than freeing it after we've showed the commit.

We should do the same for the parent list. Right now this is
just a minor optimization. But once we refactor how reflog
walks are performed, keeping the parents will avoid
confusing us the second time we see the commit.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
index cf303b2c06d24778d70b65427db1e23b5dfd9dcf..630d6cff2ff969c280fd0f06f17ce7a960901008 100644 (file)
@@ -377,9 +377,9 @@ static int cmd_log_walk(struct rev_info *rev)
                         * walking the reflogs.
                         */
                        free_commit_buffer(commit);
+                       free_commit_list(commit->parents);
+                       commit->parents = NULL;
                }
-               free_commit_list(commit->parents);
-               commit->parents = NULL;
                if (saved_nrl < rev->diffopt.needed_rename_limit)
                        saved_nrl = rev->diffopt.needed_rename_limit;
                if (rev->diffopt.degraded_cc_to_c)