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

Re: [RFC PATCH] `log --merge` also for rebase/cherry pick/revert

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jan 15, 2024, 10:48 UTC
Message-ID
<648774b5-5208-42d3-95c7-e0cba4d6a159@gmail.com>
In-Reply-To
<20240112150346.73735-1-mi.al.lohmann@gmail.com>
Hi Michael
On 12/01/2024 15:03, Michael Lohmann wrote:
Show 24 quoted lines
> Hi Phillip,
> 
> On 12. Jan 2024, at 12:01, phillip.wood123@gmail.com wrote:
>> I should start by saying that I didn't know "git log --merge" existed before
>> I saw this message
> I also just found it and it looked very useful...
> 
>> so please correct me if I've misunderstood what this patch is doing. If I
>> understand correctly it shows the commits from each side of the merge and is
>> equivalent to
>>
>>     git log HEAD MERGE_HEAD ^$(git merge-base HEAD MERGE_HEAD)
>>
>> When a commit is cherry-picked the merge base used is CHERRY_PICK_HEAD^ [*]
>> so I'm not sure what
>>
>>     git log HEAD CHERRY_PICK_HEAD ^$(git merge-base HEAD CHERRY_PICK_HEAD)
> 
> Almost, but not quite: "git log —merge" only shows the commits touching the
> conflict, so it would be equivalent to (I think):
> 
>     git log HEAD CHERRY_PICK_HEAD ^$(git merge-base HEAD CHERRY_PICK_HEAD) -- $(git diff --name-only --diff-filter=U --relative)
> 
> (or replace CHERRY_PICK with one of the other actions)
Thanks for clarifying that.
Show 6 quoted lines
>> Indeed there HEAD and CHERRY_PICK_HEAD may not share a common ancestor.
> 
> True - but same for MERGE_HEAD ("git merge --allow-unrelated-histories"). I
> have to confess I did not check how it would behave under those circumstances.
> It could either error, or (more helpful) show the log touching the file until
> the root commit.

What I was trying to get at was that with "git merge" "git log --merge" will show commits that are part of the merge. With "git cherry-pick" that's not the case because we're selecting the commits to show using the merge base of HEAD and CHERRY_PICK_HEAD while cherry-pick uses CHERRY_PICK_HEAD^ as the base of the merge. I think Junio explains why it is still useful to show those commits in [1] i.e. they help the user understand the conflicts even though they are not part of the merge. It might be worth expanding the commit message to explain that.

Best Wishes
Phillip
[1] https://lore.kernel.org/git/xmqqil3y9rvm.fsf@gitster.g/
Previous: Junio C HamanoNext: Junio C Hamano
Message 28 of 30 in “`log --merge` also for rebase/cherry pick/revert”
  1. `log --merge` also for rebase/cherry pick/revertMichael Lohmann, Jan 11, 2024
  2. Junio C HamanoJan 12, 2024
  3. 1/2 revision: ensure MERGE_HEAD is a ref in prepare_show_mergeMichael Lohmann, Jan 12, 2024
  4. 2/2 revision: Implement `git log --merge` also for rebase/cherry_pick/revertMichael Lohmann, Jan 12, 2024
  5. Junio C HamanoJan 12, 2024
  6. Patrick SteinhardtJan 15, 2024
  7. Junio C HamanoJan 15, 2024
  8. 1/2 revision: ensure MERGE_HEAD is a ref in prepare_show_mergeMichael Lohmann, Jan 17, 2024
  9. 2/2 revision: Implement `git log --merge` also for rebase/cherry_pick/revertMichael Lohmann, Jan 17, 2024
  10. Full disclosureMichael Lohmann, Jan 17, 2024
  11. Christian CouderJan 17, 2024
  12. Full disclosureMichael Lohmann, Jan 17, 2024
  13. Ruben SafirJan 21, 2024
  14. Junio C HamanoJan 17, 2024
  15. Elijah NewrenJan 24, 2024
  16. Junio C HamanoJan 24, 2024
  17. Johannes SixtJan 24, 2024
  18. Junio C HamanoJan 24, 2024
  19. Johannes SixtJan 24, 2024
  20. Junio C HamanoJan 24, 2024
  21. Junio C HamanoFeb 9, 2024
  22. Johannes SixtJan 12, 2024
  23. Johannes SixtJan 12, 2024
  24. Junio C HamanoJan 12, 2024
  25. phillip.wood123@gmail.comJan 12, 2024
  26. Michael LohmannJan 12, 2024
  27. Junio C HamanoJan 12, 2024
  28. Phillip WoodJan 15, 2024
  29. Junio C HamanoJan 12, 2024
  30. Michael LohmannJan 12, 2024

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.