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

bugreport: git apply -3 confusing "lacks the necessary blob"

From
JKJan Kratochvil <jan@jankratochvil.net>
Date
Aug 18, 2021, 18:17 UTC
Message-ID
<YR1OszUm08BMAE1N@host1.jankratochvil.net>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue) git apply -3 b.diff

What did you expect to happen? (Expected behavior)
<<<<<<< ours
c
||||||| base
a
=======
b
>>>>>>> theirs

What happened instead? (Actual behavior) error: patch failed: x:1 error: repository lacks the necessary blob to fall back on 3-way merge. error: x: patch does not apply

What's different between what you expected and what actually happened? The conflicting patch has not been applied to resolve it manually.

Anything else you want to add: The problem is 'git apply -3' will print confusing "lacks the necessary blob" message despite the real error message should be: "b.diff is missing line starting with 'index', cannot apply by -3/--3way"

reproducer: (set -ex;: rm -rf gitgit;mkdir gitgit;cd gitgit;git init;echo a >x;git add x;git commit -am.;git checkout -b b;echo b >x;git commit -am.;git checkout master;echo c >x;git commit -am.;git diff master^..b|grep -v ^index >b.diff;git apply -3 b.diff || cat b.diff)

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.31.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.12.11-300.fc34.x86_64 #1 SMP Wed Jun 16 15:47:58 UTC 2021 x86_64 compiler info: gnuc: 11.0 libc info: glibc: 2.33 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks] not run from a git repository - no hooks to show

Next: Bagas Sanjaya
Message 1 of 7 in “bugreport: git apply -3 confusing "lacks the necessary blob"”
  1. Jan KratochvilAug 18, 2021
  2. Bagas SanjayaAug 20, 2021
  3. Jan KratochvilAug 20, 2021
  4. Junio C HamanoAug 20, 2021
  5. Jan KratochvilAug 20, 2021
  6. Jan KratochvilAug 27, 2021
  7. Junio C HamanoAug 27, 2021

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.