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

3 messages, 2 authors, 2021-08-20 · open the first message on its own page

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

From: Jan Kratochvil <hidden>
Date: 2021-08-18 18:24:37

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
quoted
quoted
quoted
quoted
quoted
quoted
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

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

From: Bagas Sanjaya <hidden>
Date: 2021-08-20 09:19:44

On 19/08/21 01.17, Jan Kratochvil wrote:
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)
I can reproduce your issue on latest Git (2.33.0).

It seems like you remove `index` line, which **may** contain blob hash 
information required for three-way merge with git apply -3.

But if you don't remove it when generating patch that way, you will get 
expected conflict when git applying.

-- 
An old man doll... just what I always wanted! - Clara

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

From: Jan Kratochvil <hidden>
Date: 2021-08-20 09:26:44

On Fri, 20 Aug 2021 11:19:39 +0200, Bagas Sanjaya wrote:
On 19/08/21 01.17, Jan Kratochvil wrote:
quoted
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)
I can reproduce your issue on latest Git (2.33.0).

It seems like you remove `index` line, which **may** contain blob hash
information required for three-way merge with git apply -3.

But if you don't remove it when generating patch that way, you will get
expected conflict when git applying.
Yes.

The problem is when the 'index' line is already removed (as it was always
being removed in my existing setup) it is difficult to find out that is the
reason of this confusing message. So the error message should be different
when the 'index' line is missing at all.


Jan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help