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

Re: [PATCH v2] revision.c: really honor --first-parent

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2008, 22:38 UTC
Message-ID
<7vej85suc2.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<8c5c35580805131343kc115df6yd7ce3281fb3e6171@mail.gmail.com>
"Lars Hjemli" <hjemli@gmail.com> writes:
Show 20 quoted lines
>>  - My original patch did just that, it simplified the code to make sure
>>   that all other parents beside the first parent are ignored when
>>   walking the tree.
>
> Except for the case where the first parent had been already SEEN; then
> it would continue to test the next parents until one was found which
> was not already SEEN and _that_ parent would be treated as if it was
> first. And as Nanako showed, a simple `git rev-list HEAD^..HEAD` marks
> both HEAD and HEAD^ as seen. When combined with --first-parent, the
> result (with your patch) is that HEAD^2 is treated as the first
> parent. With my patch on top of yours, the walk stops as HEAD^, which
> is what we probably both want.
>
>>  - Your code now doesn't simplify the (IMO) convoluted walk, and still
>>   marks things as seen, even though in the first-parent case, these
>>   commits are not really seen at all.  It implies that your code
>>   generates differing output, depending on the merges present.
>
> I don't think so. My code should neither follow nor mark as SEEN any
> parent but the first (but I could obviously be wrong).

A major part of the "convoluted walk" is the (il-)logic that skipped earlier SEEN parents and treated the first unseen one as if it was the first parent, which is not exactly Stephen's fault. It was placed by yours truly in the very original code but it was done without much thought.

I think your patch is the correct fix for that convolution, regardless of the traversal order stability issue Stephen mentions.

Previous: Lars HjemliNext: Stephen R. van den Berg
Message 7 of 10 in “"git log --first-parent" shows parents that are not first”
  1. しらいしななこMay 11, 2008
  2. Junio C HamanoMay 11, 2008
  3. revision.c: really honor --first-parentLars Hjemli, May 11, 2008
  4. revision.c: really honor --first-parentLars Hjemli, May 12, 2008
  5. Stephen R. van den BergMay 13, 2008
  6. Lars HjemliMay 13, 2008
  7. Junio C HamanoMay 13, 2008
  8. Stephen R. van den BergMay 14, 2008
  9. Lars HjemliMay 14, 2008
  10. Stephen R. van den BergMay 14, 2008

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.