git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Victoria Dye <vdye@github.com>
Subject: [PATCH] midx.c: clear auxiliary MIDX files first
Date: Tue, 25 Oct 2022 14:25:20 -0400	[thread overview]
Message-ID: <bf36093cd6d7ac83b16241b0199b3a8c904e6774.1666722316.git.me@ttaylorr.com> (raw)

Since they were added in c528e17966 (pack-bitmap: write multi-pack
bitmaps, 2021-08-31), the routine to remove MIDXs removed the
multi-pack-index file itself before removing its associated .bitmap and
.rev file(s), if any.

This creates a window where a MIDX's .bitmap file exists without its
corresponding MIDX. If a reader tries to load a MIDX bitmap during that
time, they will get a warning, and the MIDX bitmap code will gracefully
degrade.

Remove this window entirely by removing the MIDX last, and removing its
auxiliary files first.

The order here is important, too. We remove the MIDX's .bitmap file
ahead of its .rev, since callers try and read the .bitmap first. The
.rev file is no longer generated by modern versions of Git, but cleaning
up old ones generated by previous versions of Git is still important to
do.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 midx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/midx.c b/midx.c
index 3a8dcfe98e..994129aecd 100644
--- a/midx.c
+++ b/midx.c
@@ -1619,12 +1619,12 @@ void clear_midx_file(struct repository *r)
 		r->objects->multi_pack_index = NULL;
 	}
 
-	if (remove_path(midx.buf))
-		die(_("failed to clear multi-pack-index at %s"), midx.buf);
-
 	clear_midx_files_ext(r->objects->odb->path, ".bitmap", NULL);
 	clear_midx_files_ext(r->objects->odb->path, ".rev", NULL);
 
+	if (remove_path(midx.buf))
+		die(_("failed to clear multi-pack-index at %s"), midx.buf);
+
 	strbuf_release(&midx);
 }
 
-- 
2.38.0.16.g393fd4c6db

             reply	other threads:[~2022-10-25 18:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 18:25 Taylor Blau [this message]
2022-10-26  5:41 ` [PATCH] midx.c: clear auxiliary MIDX files first Jeff King
2022-10-26 13:31   ` Derrick Stolee
2022-10-26 19:59     ` Taylor Blau
2022-10-27 20:28     ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf36093cd6d7ac83b16241b0199b3a8c904e6774.1666722316.git.me@ttaylorr.com \
    --to=me@ttaylorr.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=vdye@github.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).