From: Junio C Hamano Date: Thu, 6 Nov 2014 18:52:36 +0000 (-0800) Subject: Merge branch 'tm/line-log-first-parent' X-Git-Tag: v2.2.0-rc1~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=64b9326460e066a6ae598ed53f38bec8ab4e577d;p=thirdparty%2Fgit.git Merge branch 'tm/line-log-first-parent' "git log --first-parent -L..." used to crash. * tm/line-log-first-parent: line-log: fix crash when --first-parent is used --- 64b9326460e066a6ae598ed53f38bec8ab4e577d diff --cc line-log.c index 038c58a395,fe04c9d109..b7864ad586 --- a/line-log.c +++ b/line-log.c @@@ -1139,8 -1162,11 +1139,11 @@@ static int process_ranges_merge_commit( struct commit **parents; struct commit_list *p; int i; - int nparents = count_parents(commit); + int nparents = commit_list_count(commit->parents); + if (nparents > 1 && rev->first_parent_only) + nparents = 1; + diffqueues = xmalloc(nparents * sizeof(*diffqueues)); cand = xmalloc(nparents * sizeof(*cand)); parents = xmalloc(nparents * sizeof(*parents)); diff --cc t/t4211-line-log.sh index 7369d3c517,3be25a3a7f..0901b30982 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@@ -64,34 -64,22 +64,39 @@@ test_bad_opts "-L 1,1000:b.c" "has only test_bad_opts "-L :b.c" "argument.*not of the form" test_bad_opts "-L :foo:b.c" "no match" -# There is a separate bug when an empty -L range is the first -L encountered, -# thus to demonstrate this particular bug, the empty -L range must follow a -# non-empty -L range. -test_expect_success '-L {empty-range} (any -L)' ' +test_expect_success '-L X (X == nlines)' ' + n=$(wc -l