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

Re: [PATCH 6/6] revision: add parents after child for ^!

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 16, 2022, 15:55 UTC
Message-ID
<xmqqh717jou6.fsf@gitster.g>
In-Reply-To
<29d50baa-1923-38e1-6ecb-73840376d28e@web.de>
René Scharfe <l.s.r@web.de> writes:
> "git diff A B", "git diff A..B", "git diff ^A B" and "git diff "B ^A"
> all produce the same output.  So I suspect we could reverse the order
> for A..B as well without ill effect if we wanted.
Yup.
>> Can't we "fix" it at the consumer end, perhaps by checking where
>> these commits came from by looking at rev.cmdline?
>
> We could.

Yeah, doing so may be more in line with how two-tree comparison is parsed (your observation above on four combinations).

Show 19 quoted lines
> --- >8 ---
> Subject: [PATCH] diff: support ^! for merges
>
> revision.c::handle_revision_arg_1() resolves <rev>^! by first adding the
> negated parents and then <rev> itself.  builtin_diff_combined() expects
> the first tree to be the merge and the remaining ones to be the parents,
> though.  This mismatch results in bogus diff output.
>
> Remember the first tree that doesn't belong to a parent and use it
> instead of blindly picking the first one.  This makes "git diff <rev>^!"
> consistent with "git show <rev>^!".
>
> Reported-by: Tim Jaacks <tim.jaacks@garz-fricke.com>
> Suggested-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> The check "i < rev.cmdline.nr" is necessary to avoid segfaults e.g.
> in t0005.  I wonder why.  Shouldn't rev.pending.objects and
> rev.cmdline.rev always have the same number of entries?

Things that did not come from command line can go into pending, can't they? E.g. add_head_to_pending(), when lack of rev defaults to "HEAD", touches pending without touching cmdline?

Previous: René ScharfeNext: René Scharfe
Message 11 of 16 in “revision: fix order of revs for ^!”
  1. 0/6 revision: fix order of revs for ^!René Scharfe, Sep 15, 2022
  2. 1/6 revision: use strtol_i() for exclude_parentRené Scharfe, Sep 15, 2022
  3. Chris TorekSep 17, 2022
  4. 2/6 revision: factor out get_commit()René Scharfe, Sep 15, 2022
  5. 3/6 revision: factor out add_parent()René Scharfe, Sep 15, 2022
  6. 4/6 revision: factor out add_parents()René Scharfe, Sep 15, 2022
  7. 5/6 revision: rename add_parents_only() to add_nth_parent()René Scharfe, Sep 15, 2022
  8. 6/6 revision: add parents after child for ^!René Scharfe, Sep 15, 2022
  9. Junio C HamanoSep 15, 2022
  10. René ScharfeSep 16, 2022
  11. Junio C HamanoSep 16, 2022
  12. René ScharfeSep 18, 2022
  13. 0/3 diff: support ^! for mergesRené Scharfe, Oct 1, 2022
  14. 1/3 revision: use strtol_i() for exclude_parentRené Scharfe, Oct 1, 2022
  15. 2/3 revisions.txt: unspecify order of resolved parts of ^!René Scharfe, Oct 1, 2022
  16. 3/3 diff: support ^! for mergesRené Scharfe, Oct 1, 2022

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.