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

Re: [Bug report] git cherry-pick silently ignores error whereas git apply fails for hunk apply

From
Johannes Sixt <j6t@kdbg.org>
Date
Nov 8, 2025, 08:26 UTC
Message-ID
<6f9a0358-4d87-477a-a067-081ce6b2d102@kdbg.org>
In-Reply-To
<CAEyHQXUgzRnT=8Fydn9Ew6V29hfJcjR8i26mdvGOXaWD=agzNA@mail.gmail.com>
Am 08.11.25 um 04:44 schrieb Bhavik Bavishi:
Show 15 quoted lines
>>> If you use `git apply --3way`, does it still fail, or does it succeed
>>> and does it produce the same result as `git cherry-pick` or a different
>>> result?
>> I've compare the file content of `mango/utils/apple_utils.cc` for `git
> apply --3way` and  `git cherry-pick` is same
> 
> If I understand correctly, `git cherry-pick` is processed as expected, but for
> some reason we are not able to follow this behavior because the end result is
> missing content. expectation was to have this content either be applied
> successfully or fail with a conflict (indicating it could not be applied).
> 
> query: is there a way to understand this behavior? Based on that, we can then
> correct or update the file format to avoid such issues in the future, or
> introduce an additional process to run `git apply` (without `--3way`) and check
> if there is any hunk failed to apply and notify for the same.

`git cherry-pick` and `git apply --3wax` use a merge strategy. If this operation omits a change, then it is usually the case that it was determined that the change was already applied independently. This in turn can happen in a situation where there are repeated occurrences of the same text, and only some of them are changed, like this (and I am speculating here):

base: ...ABC...ABC... theirs: ...ABC...AXC... ours: .........AXC...ABC...

Here, the merge strategy thinks that the change of the second "ABC" to "AXC" on their side matches up with the first "ABC", but that has already been changed to "AXC" independently on our side, hence, there is nothing more to do.

-- Hannes
Previous: Bhavik BavishiNext: Chris Torek
Message 5 of 7 in “[Bug report] git cherry-pick silently ignores error whereas git apply fails for hunk apply”
  1. Bhavik BavishiNov 7, 2025
  2. Johannes SixtNov 7, 2025
  3. Bhavik BavishiNov 7, 2025
  4. Bhavik BavishiNov 8, 2025
  5. Johannes SixtNov 8, 2025
  6. Chris TorekNov 8, 2025
  7. Bhavik BavishiNov 9, 2025

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.