From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 3266E1F45A for ; Tue, 25 Oct 2022 18:25:29 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=ttaylorr-com.20210112.gappssmtp.com header.i=@ttaylorr-com.20210112.gappssmtp.com header.b="LLckcXUe"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbiJYSZY (ORCPT ); Tue, 25 Oct 2022 14:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbiJYSZX (ORCPT ); Tue, 25 Oct 2022 14:25:23 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA318E22C5 for ; Tue, 25 Oct 2022 11:25:22 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id r142so11109645iod.11 for ; Tue, 25 Oct 2022 11:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=h0H3Y7Ov9pNnaI+ya8JdeaMNDx+/cT3Yny7W2vIXj24=; b=LLckcXUeaArClZPW5CeZGorEdTHUejd2RPyjwJOEWyJCqoDJpmyRgw3/5VCVFy7Hty GUCtMmfFuCUF7H4lPyeuVg9dL3VLRGDNN9ujTURAZvnfWsbKBekhxbGf7yZVTazyLMc/ E5Ti/NJBlSvkwTXE6rmp+/y8Fm1AthIhzCyRk7RLrH5kggAvVlvSqp6gFjTucFk0cCuv rJkHJnrTDisk7pE0H/rEurr5/Ap8dX34FqcCjVHI2hYvSwShMbWZWptdy8TiYkCbaLFn euQoZB+gxvBSHV1QmISdljSyJb/MgZx8h1gdjeqNUqTCL5ieDQ0NSRlJ2XtaRRaU25au QK/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h0H3Y7Ov9pNnaI+ya8JdeaMNDx+/cT3Yny7W2vIXj24=; b=kI7V2zk4CqsCeWqRf5HCKc59CvMyAXMxyj3kvNGqHcTa6chJQAuzX1vGEqD7x0SvXe DSqpjc9EpahUbEtA+iqzf1zP1fc5IZjojyhiB1DqiS9QqWrzlT2JYAZoPGoZmk3jv7b1 pNqr2t11HCkhHlnPKQiTxge/SIcLsQab/aQ5AihJRKo0v3ZAA1+c4iBbcTirK8/O2H/C AbIn4G38nVxnTplRnOIIEahkRKz/8xqjpgluKkoX9d7XYqVnyvlRakinsTJu1MDdyB2c dfKkib3maNRuWeSke/ZKuQR/3x1OvP8zpxFpWMEhgW+rXnk1tFlCndQWC/UbFivZULSA JZ3w== X-Gm-Message-State: ACrzQf0dzN189iLhkp/sK0z+oYgZM+Jftc5N9EXRqyG9A2qZD9SEoOPj yMJvUxnL9zZUDry0G8RwOw9lLd46XebvPQ2D X-Google-Smtp-Source: AMsMyM794u7TUfn567OnO/vuzxoBlQMyUEGhkM8P/RW275mOkhXwBC+j29+3HV49PXYYxnS4OdhdBg== X-Received: by 2002:a02:62cc:0:b0:363:d7ea:f3d with SMTP id d195-20020a0262cc000000b00363d7ea0f3dmr25341751jac.120.1666722322015; Tue, 25 Oct 2022 11:25:22 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id e24-20020a026d58000000b003633b78ee12sm1133495jaf.75.2022.10.25.11.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 11:25:21 -0700 (PDT) Date: Tue, 25 Oct 2022 14:25:20 -0400 From: Taylor Blau To: git@vger.kernel.org, git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye Subject: [PATCH] midx.c: clear auxiliary MIDX files first Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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