-
Notifications
You must be signed in to change notification settings - Fork 2.7k
cherry-pick failed : add_cacheinfo failed to refresh for path #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It seems the problem is caused by git lfs, after I remove the .gitattributes file from git repository. |
This looks like it's a problem with Git for Window's cherry pick implementation, rather than Git LFS's implementation of anything. @dscho or @chucklu could you please re-open this issue? If I am wrong, and this is indeed a problem with Git LFS, please don't hesitate to let me know and I'd be more than happy to figure out what's going on. |
If anybody can come up with a truly verifiable MCVE, that would be quite welcome. For the record, the suggested one produces this on my side: $ git cherry-pick 9e3252^..126c0c
error: object 9e3252dd3d7e9f5475320cb280327ebd248e64e2 is a tree, not a commit
fatal: bad revision '9e3252^..126c0c' So: that's not an MCVE. |
Hi @dscho ,
|
Please do so every time you offer an MCVE. If it is not verifiable on the other end, it is not verifiable, and therefore not complete, so it is not an MCVE but an ME. And since it is frustrating for everybody else, either, it is an MFE. |
Sorry, I have tired to reproduce it in a new git repository. |
On Wed, 8 Aug 2018, Chuck Lu wrote:
Sorry, I have tired to reproduce it in a new git repository.
Good. This is essentially what you ask every person to do who tries to
help you.
But I failed to reproduce, the error only happened in a particular
repository, and it' s not public.
You could try to see whether it reproduces with some trimmed down branch
(i.e. where you delete all files that are unrelated to the operation), and
if that works, try to trim it down further and further (reducing file
size, replacing file contents with dummy stuff), and whenever it is
magically "fixed", go back to where it was not fixed. You will eventually
end up with a totally anonymized MCVE that other people can use to
reproduce (and to fix) the bug.
|
@dscho I came up with a (hopefully) MCVE. Could you please look into this? :) It's been an extremely frustrating/crippling error to deal with. It was introduced sometime in the last few months; I haven't yet figured out when.
(n.b. I changed the hash above to the nearest one in your repo; the one I built from has my own extra local commits so technically its hash is different.) |
@dscho: Actually, just kidding, I figured it out. It was due to my local addition of |
I just ran into this issue with |
Please first try to reproduce it with v2.25.0, and if it does, please work on an MCVE. Then open a new bug (referencing this bug for the historical record). Thank you. |
@ChristianStadelmann You could open another new issue, if you can provide a git repository which can stably reproduce this bug. |
Ok, thanks for the hints. I'll be trying to find a MCVE and open a new issue then. |
The issue happened with a quite large and complex Repo which surely is no MCVE. Is there any guide to extract a MCVE? Anything better than bisecting and comparing git config and repo metadata? |
There is no comprehensive guide, no. A couple of things you could try:
|
This issue (and #2781) might be related with the question I just posted on stackoverflow, which does have a MCVE. The major difference being that I use a custom merge driver instead of git lfs. |
Indeed, I think what is happening here is that there is a file with no line endings at all, and during the cherry-pick, the merge driver updated it to have CR/LF line endings. And then |
I bet it is this call: https://github.com/git-for-windows/git/blob/v2.32.0.windows.1/merge-recursive.c#L1365-L1366. Right after we asked the low-level merge driver to write that file, and right after we read back the contents written by said driver, we write the loose object verbatim. Via But when we then ask a couple of busy hours later I think I have a fix, at least it fixes the issue demonstrated in the MCVE (for everybody lurking in this ticket: take home this lesson as to just how important an MCVE is): diff --git a/merge-recursive.c b/merge-recursive.c
index 69d678c9cd77..3c5b6297e399 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1351,6 +1351,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
else if (oideq(&b->oid, &o->oid))
oidcpy(&result->blob.oid, &a->oid);
else if (S_ISREG(a->mode)) {
+ struct strbuf dest = STRBUF_INIT;
mmbuffer_t result_buf;
int ret = 0, merge_status;
@@ -1361,6 +1362,21 @@ static int merge_mode_and_contents(struct merge_options *opt,
if ((merge_status < 0) || !result_buf.ptr)
ret = err(opt, _("Failed to execute internal merge"));
+ if (!ret &&
+ convert_to_git(opt->repo->index, filename,
+ result_buf.ptr, result_buf.size,
+ &dest, 0)) {
+ /*
+ * Cannot use SWAP() because result_buf.size is
+ * an unsigned long and dest.len is a size_t.
+ */
+ size_t len = dest.len;
+ dest.len = result_buf.size;
+ result_buf.size = len;
+ SWAP(result_buf.ptr, dest.buf);
+ }
+ strbuf_release(&dest);
+
if (!ret &&
write_object_file(result_buf.ptr, result_buf.size,
blob_type, &result->blob.oid)) I will now work on a regression test and then contribute the patch to the Git mailing list. |
Waaaait a moment. The custom merge driver is supposed to receive the clean contents, not the smudged ones. For example, if CR/LF line endings are configured, the merge driver sees the files with LF-only line endings, just like they are in Git's database. Likewise, the merge driver is supposed to write a result that is clean, not smudged. In our case, this would be without CR/LF line endings. In your MCVE, the contents of So the bug is actually in the merge driver, and above-mentioned diff is incorrect. I admit that the error message is not helpful at all, and should probably be improved. |
@Deeem2031 I left this answer at the StackOverflow post:
|
I think even |
Hello there, how is the issue going. I'm facing the following :
|
Setup
defaults?
Details
Bash
Minimal, Complete, and Verifiable example
this will help us understand the issue.
cherry-pick successfully
cherry-pick failed
The trace info for cherry-pick is as following:
The text was updated successfully, but these errors were encountered: