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

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

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Nov 4, 2014, 09:34 UTC
Message-ID
<54589DBB.7040900@drmicha.warpmail.net>
In-Reply-To
<CACt9tMj2GBWC6yRpfKXUk1hnh2ZyBqoV5HDmL0cjfxCiawHT=g@mail.gmail.com>
Tzvetan Mikov schrieb am 03.11.2014 um 23:09:
Show 36 quoted lines
> On Mon, Nov 3, 2014 at 12:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 
>>> 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.
>>>
> 
>> [...]
>> Tzvetan, can we have a test for this one?
> 
> Here is a sequence of commands to reproduce the crash:
> 
> git init
> echo "1" > a.txt && git add a.txt && git commit -m "a"
> git checkout -b branch
> echo "2" > b.txt && git add b.txt && git commit -m "b"
> git checkout master
> git merge branch --no-ff -m "merge"
> git log --first-parent -L 1,1:a.txt
> 
> I am not sure whether you have a requirement for a formal test
> included with the patch, but if there is one, I am happy to
> rework it.
> 
> This is a very simple fix for the crash, though possibly
> a "real" comprehensive fix may be needed. I am not sure.
> The real cause is that with "--first-parent" some commit
> objects are never loaded from disk but may still be accessed.
> 
> (sorry about my formatting - have to use GMail)
> 
> regards,
> Tzvetan
> 

A test would be nice, yes. Look in t/t4211-line-log.sh - you should be OK if you add a test at the end which does the following:

"git checkout parallel-change" so that you have commits with more than 1 parent in the history

test "git log -L1,1 b.c" (it core dumps with current git)

That is, you don't have to set up merges and history, you can use the existing one.

Cheers, Michael

Previous: Tzvetan MikovNext: Tzvetan Mikov
Message 4 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.