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

[PATCH] revision: ignore non-existent objects in resolve-undo list

From
Mathias Rav <m@git.strova.dk>
Date
Oct 18, 2022, 15:55 UTC
Message-ID
<20221018175530.086c8c74@apus>

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: Junio C Hamano
Message 1 of 4 in “revision: ignore non-existent objects in resolve-undo list”
  1. revision: ignore non-existent objects in resolve-undo listMathias Rav, Oct 18, 2022
  2. Junio C HamanoOct 18, 2022
  3. Junio C HamanoOct 18, 2022
  4. Jeff KingOct 18, 2022

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.