Skip to content

Commit f35650d

Browse files
peffgitster
authored andcommitted
log: do not free parents when walking reflog
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>
1 parent 822601e commit f35650d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ static int cmd_log_walk(struct rev_info *rev)
377377
* walking the reflogs.
378378
*/
379379
free_commit_buffer(commit);
380+
free_commit_list(commit->parents);
381+
commit->parents = NULL;
380382
}
381-
free_commit_list(commit->parents);
382-
commit->parents = NULL;
383383
if (saved_nrl < rev->diffopt.needed_rename_limit)
384384
saved_nrl = rev->diffopt.needed_rename_limit;
385385
if (rev->diffopt.degraded_cc_to_c)

0 commit comments

Comments
 (0)