Skip to content

Commit 318e758

Browse files
committed
Merge branch 'cb/log-follow-with-combined' into maint
"git log -c --follow $path" segfaulted upon hitting the commit that renamed the $path being followed. * cb/log-follow-with-combined: fix segfault with git log -c --follow
2 parents b3bf469 + 46ec510 commit 318e758

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

combine-diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ void diff_tree_combined(const unsigned char *sha1,
13051305
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
13061306

13071307
diffopts = *opt;
1308+
diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts);
13081309
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
13091310
DIFF_OPT_SET(&diffopts, RECURSIVE);
13101311
DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
@@ -1375,6 +1376,8 @@ void diff_tree_combined(const unsigned char *sha1,
13751376
paths = paths->next;
13761377
free(tmp);
13771378
}
1379+
1380+
diff_tree_release_paths(&diffopts);
13781381
}
13791382

13801383
void diff_tree_combined_merge(const struct commit *commit, int dense,

t/t4202-log.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,20 @@ test_expect_success 'show added path under "--follow -M"' '
530530
)
531531
'
532532

533+
test_expect_success 'git log -c --follow' '
534+
test_create_repo follow-c &&
535+
(
536+
cd follow-c &&
537+
test_commit initial file original &&
538+
git rm file &&
539+
test_commit rename file2 original &&
540+
git reset --hard initial &&
541+
test_commit modify file foo &&
542+
git merge -m merge rename &&
543+
git log -c --follow file2
544+
)
545+
'
546+
533547
cat >expect <<\EOF
534548
* commit COMMIT_OBJECT_NAME
535549
|\ Merge: MERGE_PARENTS

0 commit comments

Comments
 (0)