From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] revision: mark blobs needed for resolve-undo as reachable
Date: Mon, 13 Jun 2022 22:49:29 -0400 [thread overview]
Message-ID: <Yqf3OT9vSvWETVCJ@nand.local> (raw)
In-Reply-To: <xmqqfskdieqz.fsf@gitster.g>
On Thu, Jun 09, 2022 at 04:44:20PM -0700, Junio C Hamano wrote:
> The resolve-undo extension was added to the index in cfc5789a
> (resolve-undo: record resolved conflicts in a new index extension
> section, 2009-12-25). This extension records the blob object names
> and their modes of conflicted paths when the path gets resolved
> (e.g. with "git add"), to allow "undoing" the resolution with
> "checkout -m path". These blob objects should be guarded from
> garbage-collection while we have the resolve-undo information in the
> index (otherwise unresolve operation may try to use a blob object
> that has already been pruned away).
>
> But the code called from mark_reachable_objects() for the index
> forgets to do so. Teach add_index_objects_to_pending() helper to
> also add objects referred to by the resolve-undo extension.
Nice find!
> Also make matching changes to "fsck", which has code that is fairly
> similar to the reachability stuff, but have parallel implementations
> for all these stuff, which may (or may not) someday want to be unified.
I wasn't sure what the change in fsck was when skimming the diffstat
before reading your patch message, but makes sense. I'm glad that you
included this, too.
> +static void add_resolve_undo_to_pending(struct index_state *istate, struct rev_info *revs)
> +{
> + struct string_list_item *item;
> + struct string_list *resolve_undo = istate->resolve_undo;
> +
> + if (!resolve_undo)
> + return;
> +
> + for_each_string_list_item(item, resolve_undo) {
> + const char *path = item->string;
> + struct resolve_undo_info *ru = item->util;
> + int i;
> +
> + if (!ru)
> + continue;
> + for (i = 0; i < 3; i++) {
> + struct blob *blob;
> +
> + if (!ru->mode[i] || !S_ISREG(ru->mode[i]))
> + continue;
> +
> + blob = lookup_blob(revs->repo, &ru->oid[i]);
> + if (!blob) {
> + warning(_("resolve-undo records `%s` which is missing"),
> + oid_to_hex(&ru->oid[i]));
> + continue;
> + }
> + add_pending_object_with_path(revs, &blob->object, "",
> + ru->mode[i], path);
> + }
> + }
> +}
This implementation looks good to my eyes.
> @@ -1718,6 +1752,8 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
> add_cache_tree(istate->cache_tree, revs, &path, flags);
> strbuf_release(&path);
> }
> +
> + add_resolve_undo_to_pending(istate, revs);
> }
Great; this fixes the bug for cruft packs, too, whose reachable pack is
generated with `--indexed-objects`, so the cruft pack will no longer
contain the resolve-undo objects.
> +test_expect_success 'resolve-undo keeps blobs from gc' '
Very thorough. Thanks!
Taylor
next prev parent reply other threads:[~2022-06-14 2:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 23:44 [PATCH] revision: mark blobs needed for resolve-undo as reachable Junio C Hamano
2022-06-13 15:15 ` Derrick Stolee
2022-06-13 20:11 ` Junio C Hamano
2022-06-14 0:24 ` Ævar Arnfjörð Bjarmason
2022-06-14 14:35 ` Derrick Stolee
2022-06-15 2:02 ` Taylor Blau
2022-06-15 3:48 ` Jeff King
2022-06-15 20:47 ` Taylor Blau
2022-06-15 17:11 ` Junio C Hamano
2022-06-16 14:10 ` Ævar Arnfjörð Bjarmason
2022-06-14 2:49 ` Taylor Blau [this message]
2022-07-11 8:19 ` fsck segfault (was: Re: [PATCH] revision: mark blobs needed for resolve-undo as reachable) SZEDER Gábor
2022-07-11 19:39 ` fsck segfault Junio C Hamano
2022-07-11 23:25 ` [PATCH 2/1] fsck: do not dereference NULL while checking resolve-undo data Junio C Hamano
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=Yqf3OT9vSvWETVCJ@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).