Re: bugreport: git apply -3 confusing "lacks the necessary blob"
- From
- Jan Kratochvil <jan@jankratochvil.net>
- Date
- Aug 27, 2021, 15:15 UTC
- Message-ID
- <YSkBg3lBAZ2pxCP2@host1.jankratochvil.net>
- In-Reply-To
- <xmqqtujkui9v.fsf@gitster.g>
On Fri, 20 Aug 2021 19:40:12 +0200, Junio C Hamano wrote:
> But I think Jan is talking about the case where users get a patch > that lacks the "index" information out of other people's "diff" > implementation and try to "apply -3" without realizing that it is > not Git's "diff" output.
For example from Phabricator: https://reviews.llvm.org/file/data/3ceoc32b3yv43vk3nw4q/PHID-FILE-lfeeh2qu4vrngdcwwudo/D107456.diff
> Perhaps something like the attached patch would be a good start.
Do you plan to check it in?
Thanks, Jan Kratochvil
Show 13 quoted lines
> diff --git i/apply.c w/apply.c
> index 44bc31d6eb..9972ada57e 100644
> --- i/apply.c
> +++ w/apply.c
> @@ -3566,6 +3566,8 @@ static int try_threeway(struct apply_state *state,
> /* Preimage the patch was prepared for */
> if (patch->is_new)
> write_object_file("", 0, blob_type, &pre_oid);
> + else if (!*patch->old_oid_prefix && !*patch->new_oid_prefix)
> + return error(_("cannot 'apply -3' a patch without the index line"));
> else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
> read_blob_object(&buf, &pre_oid, patch->old_mode))
> return error(_("repository lacks the necessary blob to perform 3-way merge."));