From: Mathias Rav <m@git.strova.dk>
To: git@vger.kernel.org
Cc: peff@peff.net, pwagland@gmail.com
Subject: [PATCH] revision: ignore non-existent objects in resolve-undo list
Date: Tue, 18 Oct 2022 17:55:30 +0200 [thread overview]
Message-ID: <20221018175530.086c8c74@apus> (raw)
Garbage collection could inadvertently prune blobs mentioned only in the
resolve-undo extension prior to the bugfix in 5a5ea141e7
("revision: mark blobs needed for resolve-undo as reachable", 2022-06-09).
If a repository is affected by this bug, an obscure error can occur in
`git gc` after updating to a version of git that has the bugfix:
$ git gc
Enumerating objects: 327687, done.
Counting objects: 100% (327687/327687), done.
Delta compression using up to 8 threads
Compressing objects: 100% (70883/70883), done.
fatal: unable to read 616c8d17f4625f227708aae480e71233f7f58dce
fatal: failed to run repack
A similar error occurs in `git rev-list --objects --indexed-objects`.
Fix the error by emitting a warning when the resolve-undo list mentions
objects that do not exist and then ignoring the nonexistent object.
The bugfix 5a5ea141e7 already contained code to emit this warning,
but since the code used lookup_blob() (and not parse_object()),
it would only warn in the unlikely scenario where the resolve-undo list
mentions an existing object that is not a blob.
I have encountered this error on two different clones of a large
mono-repository in checkouts with dozens of worktrees that see frequent
rebasing (causing a lot of git gc churn) and frequent merge conflicts
during rebasing, leading to resolve-undo lists in the index.
Somehow it seems the resolve-undo lists in the index persist after the
merge conflicts are resolved, which makes the error more frequent than
if the resolve-undo lists were only populated during the merge conflict.
Signed-off-by: Mathias Rav <m@git.strova.dk>
Fixes: 5a5ea141e7
Reported-by: Paul Wagland <pwagland@gmail.com>
---
revision.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/revision.c b/revision.c
index 36e31942ce..03bc45bef1 100644
--- a/revision.c
+++ b/revision.c
@@ -1720,18 +1720,18 @@ static void add_resolve_undo_to_pending(struct index_state *istate, struct rev_i
if (!ru)
continue;
for (i = 0; i < 3; i++) {
- struct blob *blob;
+ struct object *obj;
if (!ru->mode[i] || !S_ISREG(ru->mode[i]))
continue;
- blob = lookup_blob(revs->repo, &ru->oid[i]);
- if (!blob) {
+ obj = parse_object(revs->repo, &ru->oid[i]);
+ if (!obj) {
warning(_("resolve-undo records `%s` which is missing"),
oid_to_hex(&ru->oid[i]));
continue;
}
- add_pending_object_with_path(revs, &blob->object, "",
+ add_pending_object_with_path(revs, obj, "",
ru->mode[i], path);
}
}
--
2.38.0
next reply other threads:[~2022-10-18 16:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 15:55 Mathias Rav [this message]
2022-10-18 16:32 ` [PATCH] revision: ignore non-existent objects in resolve-undo list Junio C Hamano
2022-10-18 16:40 ` Junio C Hamano
2022-10-18 20:29 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018175530.086c8c74@apus \
--to=m@git.strova.dk \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=pwagland@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).