git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] line-log: fix crash when --first-parent is used

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 4, 2014, 21:24 UTC
Message-ID
<xmqq8ujqpsk6.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1415133217-7824-1-git-send-email-tmikov@gmail.com>
Tzvetan Mikov <tmikov@gmail.com> writes:
Show 10 quoted lines
> line-log tries to access all parents of a commit, but only the first
> parent has been loaded if "--first-parent" is specified, resulting
> in a crash.
>
> Limit the number of parents to one if "--first-parent" is specified.
>
> Reported-by: Eric N. Vander Weele <ericvw@gmail.com>
> Signed-off-by: Tzvetan Mikov <tmikov@gmail.com>
> ---
>  PATCH v2: Add a test case (thanks Michael J Gruber)

Thanks, both. The patch looks good (modulo the indentation of nparents assignment, which I'll locally fix up).

Will queue.
Show 32 quoted lines
>  line-log.c          | 3 +++
>  t/t4211-line-log.sh | 5 +++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/line-log.c b/line-log.c
> index 1008e72..86e7274 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -1141,6 +1141,9 @@ static int process_ranges_merge_commit(struct rev_info *rev, struct commit *comm
>  	int i;
>  	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 --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
> index 7369d3c..0901b30 100755
> --- a/t/t4211-line-log.sh
> +++ b/t/t4211-line-log.sh
> @@ -94,4 +94,9 @@ test_expect_success '-L ,Y (Y == nlines + 2)' '
>  	test_must_fail git log -L ,$n:b.c
>  '
>  
> +test_expect_success '-L with --first-parent and a merge' '
> +	git checkout parallel-change &&
> +	git log --first-parent -L 1,1:b.c
> +'
> +
>  test_done
Previous: Tzvetan MikovNext: Tzvetan Mikov
Message 6 of 7 in “line-log: fix crash when --first-parent is used”
  1. line-log: fix crash when --first-parent is usedTzvetan Mikov, Oct 31, 2014
  2. Junio C HamanoNov 3, 2014
  3. Tzvetan MikovNov 3, 2014
  4. Michael J GruberNov 4, 2014
  5. line-log: fix crash when --first-parent is usedTzvetan Mikov, Nov 4, 2014
  6. Junio C HamanoNov 4, 2014
  7. Tzvetan MikovNov 4, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.