From patchwork Tue Aug 27 21:13:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13780155 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7601D3641 for ; Tue, 27 Aug 2024 21:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793211; cv=none; b=oxlwh4reB3CS4YhD9MVoNaspVunqALJ8cexaOjOYMJw+zoPml9K8Upgk9SENqZJWNjpYC/oJFEpGf348qvhk4o0Y53W+eNkPJR1dJLesQNdgc8edM2gjXrlUYg31uhec+Nlq2x/3Q9dw2ACVixaVkXz5paPepVHHYSvSvYKHYPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793211; c=relaxed/simple; bh=flSxG/gbArynA6JpeoSxMWkUTQP5nR6xhtN/dED9zuQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IJoU/uaYyhbVbSMk5l/Ax+3BGAq9aQmuY99//Pu8d8a2iESnGf2Kb0GtszmJq4bmXGCf51KUDjb7XhKW0pFcevXSLt9aDKUiHia0cXOCTR6wlR8nbHGSjPuWg9+rGtDrLr9b6n7N3HjNk3u5GcSNHkNYq8/5wqiF9guHmOp9W7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=jTNdiiyI; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="jTNdiiyI" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6b747f2e2b7so56544227b3.3 for ; Tue, 27 Aug 2024 14:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1724793209; x=1725398009; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ddxFxfoFLu74Xb00ygbS2gRRSaKj6rDX8EPPnHccbUQ=; b=jTNdiiyIglNT65/VLrouHALto/flW5ve4c2+6cDchz9XDEOz+frIda0vHF/CSaKw4F VoO3y0dPdFGyJhvEQYWipwRBBNxiJL7mhN0pgfCnIAk+OJX8iRU779x+rPtHq+LUSLI5 LvJhBCXgarWG0bD1l+04Jbq8FU31FwJDz59zJA5MQqIta/gbxcrFqvVFowmJqO2f5/6g Fj65As6lU1xrLRDoQ7O1I5U0qiTnYn0v+oDedMQAvvlsRixWXh5L99TFzDzrMRqS1x4A 68zxKzEHQ/3NSTbq4vDYfAdIHHeVjJWUvzPWnDGy5ux5ywnbCZtFkJ904hapyAqp+zWV XWiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724793209; x=1725398009; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ddxFxfoFLu74Xb00ygbS2gRRSaKj6rDX8EPPnHccbUQ=; b=FSMjbi2rylwxjYoX4Tgz0eeRboTDoy/uzGVbWOF4t4SmjqqQr5XDMO5pP1ktsYS++/ XxxpIlWQGKXfI9Gkenngm0W7Fr/jB22MmWM2O/f80znJJP3hSTSpB+Y4pFWEt9NDOxpr NUBVfcAjDotUE8Rd94WBxljvjO+zrv3H8hjRfJF9zmadVcaxBDKXqXIKuphH6qyLMlfK 5Md8ko4vgePitLP+Hqy/CCWSC1e3LQ6bzL7Y1oFF+WfINScUntscZztfF05NLbW7o0K9 H/ZGwVXJ5R5ZiXIKTqYvHnSPoXpETvUlPoz4GhHSkxaKKznMdhbAmZDJF/qqFQaBSdAn WB4A== X-Gm-Message-State: AOJu0Ywsq3qfr8428QaUd9rxjYxwFdlvi8xlkxXeby52f+wn/hGJEtGv CH1yQI5mzY2dqXeRKivdAa9T0ZgZL4MiiT1Y9DdevGhkEVAt9GEf+hEEYWkpjh2q1RtSIWV1GqO x X-Google-Smtp-Source: AGHT+IF2Xtzwtt6zZqeb2B5224p3lgGdz33ANf5waCmlnsrpx9vqW4bL8ejf/lFShR/D/Zla+UPclg== X-Received: by 2002:a05:690c:56c3:b0:6ae:6c9b:378d with SMTP id 00721157ae682-6c6286bd776mr158443717b3.31.1724793208957; Tue, 27 Aug 2024 14:13:28 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007449sm20753037b3.68.2024.08.27.14.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 14:13:28 -0700 (PDT) Date: Tue, 27 Aug 2024 17:13:27 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH 1/5] t/t5332-multi-pack-reuse.sh: verify pack generation with --strict Message-ID: <160673231c55f51c22171a8c2fbb105f7a501083.1724793201.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In our tests for multi-pack reuse, we have two helper functions: - test_pack_objects_reused_all(), and - test_pack_objects_reused() which invoke pack-objects (either with `--all`, or the supplied tips via stdin, respectively) and ensure that (a) the number of reused objects, and (b) the number of packs which those objects were reused from both match the expected values. Both functions discard the output of pack-objects and assert only on the contents of the trace2 stream. However, if we store the pack and attempt to index it with `--strict`, we find that a number of our tests are broken, indicating a bug within multi-pack reuse. That bug will be addressed in a subsequent commit. But let's first harden these tests by trying to index the resulting pack, marking the tests which fail appropriately. Signed-off-by: Taylor Blau --- t/t5332-multi-pack-reuse.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh index 941e73d354..ba888a83d5 100755 --- a/t/t5332-multi-pack-reuse.sh +++ b/t/t5332-multi-pack-reuse.sh @@ -31,20 +31,24 @@ test_pack_objects_reused_all () { : >trace2.txt && GIT_TRACE2_EVENT="$PWD/trace2.txt" \ git pack-objects --stdout --revs --all --delta-base-offset \ - >/dev/null && + >got.pack && test_pack_reused "$1" test_pack_objects_reused () { : >trace2.txt && GIT_TRACE2_EVENT="$PWD/trace2.txt" \ - git pack-objects --stdout --revs >/dev/null && + git pack-objects --stdout --revs >got.pack && test_pack_reused "$1" in <<-EOF && $(git rev-parse $base) ^$(git rev-parse $delta) From patchwork Tue Aug 27 21:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13780156 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46DB41D365B for ; Tue, 27 Aug 2024 21:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793214; cv=none; b=D6nG5SmgdFoL2eb/cRI9mlfPrSyHulvZOlVB91IsZTujiunDS2pvefQCEmN0IpwEur2jY+YkIzxbna+r2NV5Fm7w6FWUJkCDtyqxvppjek3LCWVwBkFF4+ePT8WP1C1RiDnM+uClrrelTocZS1Qni5fOMJ5Gzend6FLE7mTWWzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793214; c=relaxed/simple; bh=4f7BFNKiaLpwtNG7wPlBNb3d3L4AJMgv6HGUNOS8jgg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cRGOB2oBf5Mvinub6afdzOcsMvq9UPHlhJOTwxBzb4KP9x8hgwQQhl4tzt308JiZN3HsZRjv2FdBR8EZwpbSeSgmPRVa8x6Nenmz9Vn2sEl2U447DNU/Rrc1U3iQWDzQBfHyZyI48EUM/AgVRlYL6PPm7QULFbitTDeDlwl8UdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=nNADMimS; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="nNADMimS" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e0b7efa1c1bso5991016276.3 for ; Tue, 27 Aug 2024 14:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1724793212; x=1725398012; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qdsoKEwEudq44U7iidyLm8TCCiWQopKX8U0EB1/XBaw=; b=nNADMimStx5vyhozObVeY4k2obFHDstF+urBoVsXL0mr0JBg9JFeypTeF89wYIvGKz fHN3usRE/gYNtdjqXNncJMOOESIbxqKNv0a39V9QFw6CSrdti9+TOnrn1U/CMsu4tWTy ysmMNsYdpxA8pf1iAfM4x94rMH8A50NfIaqq8criaZe1uBYT4+l1RUwvwneFlCHEvPMw 0YiYcJOJqB6ZGvBLTfx3ICdM0TQ0kZdgvfV/CBjLv4LHTFG1PDyN8X0aamtdjruypyvF sNS74OnCr5H5QE14s3xoiV/RsWCn9sIQuI6yk+jticIGQW09we5V1eIVHeCtgs3lM54X zHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724793212; x=1725398012; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qdsoKEwEudq44U7iidyLm8TCCiWQopKX8U0EB1/XBaw=; b=S4r6aUQwk4QPzxxjIF/BcG+ry0r+S0u9w9gHtE87f3Q/9bnJYnqF8C+uPlt66zJJS1 /nT9lddpDFWP5g6sQVYUAhIBpNc0HR7salVlIEjfuQkG/tLGQPZ8kXsMNHPez6eLjzkA JKo1MMZ2Q1C1iqikXrOwhh4mS+1rEVFX8NsR/uIkK6Y2nt2PgkrFfKjrFcnSOsJC1ECN PTwjCGd/Akd2JlGsEWTeQHwq4LSrALu96D34W5nxEwCI0xquESNzebj3SzlVgYhi88iE 6K5q4Sx1gHN6guE9EalCzGLDs7pTsr8qU9C/dzDOw9SL9heNQ08hUVYV1xYOoeTFwGWK wiRA== X-Gm-Message-State: AOJu0Yx85J6LgvBzC2+KmGUMlnGcJO/oyfmDmaaOMEIbZy2KIDeI/ooT qvjA93ny21iaZahBzrwB96E/GDaXqZzm/Xs3c/P3mQ8P7IwnQpb/s/rnYD+dDwLfJISqvaovjA+ T X-Google-Smtp-Source: AGHT+IFNPVno7J53xhNIPmL+5RqWj8CvJSXXMXS/cHb1Po/wy9Yf8e9o2qzllaDcpiA9pkkxI4/cZw== X-Received: by 2002:a05:690c:399:b0:6c8:7827:f271 with SMTP id 00721157ae682-6c87827f682mr159640317b3.19.1724793211919; Tue, 27 Aug 2024 14:13:31 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c399cb541dsm20665597b3.21.2024.08.27.14.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 14:13:31 -0700 (PDT) Date: Tue, 27 Aug 2024 17:13:30 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH 2/5] pack-bitmap: tag bitmapped packs with their corresponding MIDX Message-ID: <1838bbcf7fe6daa58a7db78b81a2d08138fe176e.1724793201.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The next commit will need to use the bitmap's MIDX (if one exists) to translate bit positions into pack-relative positions in the source pack. Ordinarily, we'd use the "midx" field of the bitmap_index struct. But since that struct is defined within pack-bitmap.c, and our caller is in a separate compilation unit, we do not have access to the MIDX field. Instead, add a "from_midx" field to the bitmapped_pack structure so that we can use that piece of data from outside of pack-bitmap.c. The caller that uses this new piece of information will be added in the following commit. Signed-off-by: Taylor Blau --- midx.c | 1 + pack-bitmap.c | 1 + pack-bitmap.h | 1 + 3 files changed, 3 insertions(+) diff --git a/midx.c b/midx.c index ca98bfd7c6..67e0d64004 100644 --- a/midx.c +++ b/midx.c @@ -496,6 +496,7 @@ int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m, MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * local_pack_int_id + sizeof(uint32_t)); bp->pack_int_id = pack_int_id; + bp->from_midx = m; return 0; } diff --git a/pack-bitmap.c b/pack-bitmap.c index 2e657a2aa4..218d7ac2eb 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -2322,6 +2322,7 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git, packs[packs_nr].pack_int_id = pack_int_id; packs[packs_nr].bitmap_nr = pack->num_objects; packs[packs_nr].bitmap_pos = 0; + packs[packs_nr].from_midx = bitmap_git->midx; objects_nr = packs[packs_nr++].bitmap_nr; } diff --git a/pack-bitmap.h b/pack-bitmap.h index ff0fd815b8..d7f4b8b8e9 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -60,6 +60,7 @@ struct bitmapped_pack { uint32_t bitmap_pos; uint32_t bitmap_nr; + struct multi_pack_index *from_midx; /* MIDX only */ uint32_t pack_int_id; /* MIDX only */ }; From patchwork Tue Aug 27 21:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13780157 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45D431D365B for ; Tue, 27 Aug 2024 21:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793217; cv=none; b=IowVy2Ykhd1NRmwlOYrx8EqbBhckFXwR4F13R+kqDNbURESSA1zwQFYFN3pXXKNO95gDTBTXVT9h32u+JZvLxzL5Y4S8fwseeoK2ownJhGwkYxPimjegGO4ND+o76OF6jik20RHNuJtOAA6g8L2lodXh0GR1j2iYv6puHnqcglI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793217; c=relaxed/simple; bh=4qyL/Wj6mDaEHJ+llZ96c0sX7Cy2gXTqLFvTuAG7nbk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aNHLUCMi28qW59VPC5TfgOGxDVUf4lCUQREjI4MYrxQ8YaOAVimR+DdHwpjCOWA7KGq66/6k/uGJtOgzoPsfzQ+Mx/z9vkzZF/Hz032l0XJf5bWeZ+a4d9wjA/U/2t9t1l/7VgGjrLPRitae+2u4SIybEuO9gQuRXOXBC/KfhMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=Ky2ZlVQE; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="Ky2ZlVQE" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e115ef5740dso6081049276.3 for ; Tue, 27 Aug 2024 14:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1724793215; x=1725398015; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gU4sZzyXS6OlqFeiu/y41CEIAQL5OwzMfLsvQbh9krU=; b=Ky2ZlVQEJ6fWrS3vbdHwX9Goc0IlmLhJBs/1DbnCHGQlKjHKMxy9T9mjGzxE0gKGAn KTIjSJ6/ramncDSP/+J5q6T2Hy5ijMOKiG9SddMcaNsaf+RqK9Wce+aVYW1HEDtpvKZ6 ZqDOcKkkekWk1x9pxoKjsLr/JytYTuTNBKyw4Mn7zSJ2Tzb1YAyXd4H2YdAjZQmVibnk 9sSebXFz50M8J2wruem5ic4aZe0Qexg4L/IunEbjcZUHgSecddp+Qml7l/qQpOxR/BO4 gCYcoFT3G4qcHLKTJaKEPO5DsPVIFZ9rb/QcOyy3QQ2R8S7Ca7DRnI9+XZ5dEHfsN57a hDtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724793215; x=1725398015; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gU4sZzyXS6OlqFeiu/y41CEIAQL5OwzMfLsvQbh9krU=; b=Z6axR79uc+FFHPW3QCL6mFAiQSrcuVAEnJffinZIPWuVELGxKCUdWHUBhw/Liql7Qy iI7uiTXa7ytpFhrxURC46GsXBlkiCsu/mZcvajvDvtwuCfyvpxLoojy1HKRFvOfQ5GhN 1waXTYGk5X4LooSw1sQ9BjB+PJ8gElXnYCxTN9G33DJyAbBNTBWamq2mgDTT7vlVFsku YvngdK9v8cZwH0UVHFbWaF9UHjkbYzIs/INX6gKRb0DibS/EjK7IwqJFJg5gSAoTw4C4 q7tgd2zR/mD27Pt1x1qHcN9h3WyRI8/tdj2YvmyD37X60M9HkXaNBoRFVvtaRyvUYYLx 2wLw== X-Gm-Message-State: AOJu0Yw+0OV70weP77W1KnzfbBNrCKOqbVFKI6IH+dYxQKvPPKAt2X4L QKi/mu9tPHYwKZGsyyKoIzVfrOEiEEweVrNb4Npv7gl1SWqxJcuABOxYwBUwXJGB10zjfNISVty L X-Google-Smtp-Source: AGHT+IEPy6XC9cYapqfAcI9WBj7YcXyBdu/zH3p39JOE3bdf0c3Ysu9vuLaUM4qYCiEoGBjuHeSQJQ== X-Received: by 2002:a05:690c:4583:b0:6b0:407a:e3af with SMTP id 00721157ae682-6c6286b9264mr138411587b3.34.1724793214917; Tue, 27 Aug 2024 14:13:34 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39dd47604sm20672587b3.125.2024.08.27.14.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 14:13:34 -0700 (PDT) Date: Tue, 27 Aug 2024 17:13:33 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH 3/5] builtin/pack-objects.c: translate bit positions during pack-reuse Message-ID: <8998e51135e76061e603304a6b7bbe19893fc067.1724793201.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: When reusing chunks verbatim from an existing source pack, the function write_reused_pack() first attempts to reuse whole words (via the function `write_reused_pack_verbatim()`), and then individual bits (via `write_reused_pack_one()`). In the non-MIDX case, all of this code works fine. Likewise, in the MIDX case, processing bits individually from the first (preferred) pack works fine. However, processing subsequent packs in the MIDX case is broken when there are duplicate objects among the set of MIDX'd packs. This is because we treat the individual bit positions as valid pack positions within the source pack(s), which does not account for gaps in the source pack, like we see when the MIDX must break ties between duplicate objects which appear in multiple packs. The broken code looks like: for (; i < reuse_packfile_bitmap->word_alloc; i++) { for (offset = 0; offset < BITS_IN_EWORD, offset++) { /* ... */ write_reused_pack_one(reuse_packfile->p, pos + offset - reuse_packfile->bitmap_pos, f, pack_start, &w_curs); } } , where the second argument is incorrect and does not account for gaps. Instead, make sure that we translate bit positions in the MIDX's pseudo-pack order to pack positions in the respective source packs by: - Translating the bit position (pseudo-pack order) to a MIDX position (lexical order). - Use the MIDX position to obtain the offset at which the given object occurs in the source pack. - Then translate that offset back into a pack relative position within the source pack by calling offset_to_pack_pos(). After doing this, then we can safely use the result as a pack position. Note that when doing single-pack reuse, as well as reusing objects from the MIDX's preferred pack, such translation is not necessary, since either ties are broken in favor of the preferred pack, or there are no ties to break at all (in the case of non-MIDX bitmaps). Failing to do this can result in strange failure modes. One example that can occur when misinterpreting bits in the above fashion is that Git thinks it's supposed to send a delta that the caller does not want. Under this (incorrect) assumption, we try to look up the delta's base (so that we can patch any OFS_DELTAs if necessary). We do this using find_reused_offset(). But if we try and call that function for an offset belonging to an object we did not send, we'll get back garbage. This can result in us computing a negative fixup value, which results in memory corruption when trying to write the (patched) OFS_DELTA header. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 44 ++++++++++++++++++++++++++++++------- t/t5332-multi-pack-reuse.sh | 31 ++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 778be80f56..700adfb5a8 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1191,6 +1191,7 @@ static void write_reused_pack(struct bitmapped_pack *reuse_packfile, size_t pos = (i * BITS_IN_EWORD); for (offset = 0; offset < BITS_IN_EWORD; ++offset) { + uint32_t pack_pos; if ((word >> offset) == 0) break; @@ -1199,14 +1200,41 @@ static void write_reused_pack(struct bitmapped_pack *reuse_packfile, continue; if (pos + offset >= reuse_packfile->bitmap_pos + reuse_packfile->bitmap_nr) goto done; - /* - * Can use bit positions directly, even for MIDX - * bitmaps. See comment in try_partial_reuse() - * for why. - */ - write_reused_pack_one(reuse_packfile->p, - pos + offset - reuse_packfile->bitmap_pos, - f, pack_start, &w_curs); + + if (reuse_packfile->bitmap_pos) { + /* + * When doing multi-pack reuse on a + * non-preferred pack, translate bit positions + * from the MIDX pseudo-pack order back to their + * pack-relative positions before attempting + * reuse. + */ + struct multi_pack_index *m = reuse_packfile->from_midx; + uint32_t midx_pos; + off_t pack_ofs; + + if (!m) + BUG("non-zero bitmap position without MIDX"); + + midx_pos = pack_pos_to_midx(m, pos + offset); + pack_ofs = nth_midxed_offset(m, midx_pos); + + if (offset_to_pack_pos(reuse_packfile->p, + pack_ofs, &pack_pos) < 0) + BUG("could not find expected object at offset %"PRIuMAX" in pack %s", + (uintmax_t)pack_ofs, + pack_basename(reuse_packfile->p)); + } else { + /* + * Can use bit positions directly, even for MIDX + * bitmaps. See comment in try_partial_reuse() + * for why. + */ + pack_pos = pos + offset; + } + + write_reused_pack_one(reuse_packfile->p, pack_pos, f, + pack_start, &w_curs); display_progress(progress_state, ++written); } } diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh index ba888a83d5..955ea42769 100755 --- a/t/t5332-multi-pack-reuse.sh +++ b/t/t5332-multi-pack-reuse.sh @@ -69,7 +69,7 @@ test_expect_success 'multi-pack reuse is disabled by default' ' test_pack_objects_reused_all 3 1 ' -test_expect_failure 'feature.experimental implies multi-pack reuse' ' +test_expect_success 'feature.experimental implies multi-pack reuse' ' test_config feature.experimental true && test_pack_objects_reused_all 6 2 @@ -86,7 +86,7 @@ test_expect_success 'enable multi-pack reuse' ' git config pack.allowPackReuse multi ' -test_expect_failure 'reuse all objects from subset of bitmapped packs' ' +test_expect_success 'reuse all objects from subset of bitmapped packs' ' test_commit C && git repack -d && @@ -100,7 +100,7 @@ test_expect_failure 'reuse all objects from subset of bitmapped packs' ' test_pack_objects_reused 6 2 in <<-EOF && $(git rev-parse $base) ^$(git rev-parse $delta) @@ -236,4 +236,27 @@ test_expect_success 'non-omitted delta in MIDX preferred pack' ' test_pack_objects_reused_all $(wc -l in && + p="$(git pack-objects $packdir/pack X-Patchwork-Id: 13780158 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B7B1D4151 for ; Tue, 27 Aug 2024 21:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793220; cv=none; b=CfQXQZ7c9z/7wM6w6dZyOFgpgSmcq4sImli9dFGMVdCT7gN0JjZOwKiwxxeDgun69N1gpQgpQqeAiCruoNvFXLHIEdKg8PuohfNGnvxa1IzCe4TtrwMO6AMnIdsYH+g30VXKgclkV/syzMF5YVshoKv2xhDxdAQkd49wo1wk69Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793220; c=relaxed/simple; bh=rHpynxrrIMfRmixj3eCQ4+gBoq2VCScBQQO2t7+Zquk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hKHDRpqj/gANJ883yRc4eKdFwCDtDKfVLd1pvrbKXPzWNVDRmIS6pe37qLXMhCD9laOkUPyao+u3Zr6xkFO1O/nxB7okcTUk9V2I/fQ6rAZCNcfPN2UJZCrbUFZcMXoqeRTEZnOO9pcBYqQq2CTSWJm8oBc8OmFtAhowlIMZ8Gs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=TXQSpd/T; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="TXQSpd/T" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6c32daf0797so58967947b3.0 for ; Tue, 27 Aug 2024 14:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1724793218; x=1725398018; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EF97xyvUiugjVKOpBxdFrk2D3yPbmnr46zpjYqiuewc=; b=TXQSpd/TV14+0H5ch3vxJKlHu1BmHnmw0HRZbpT11N7jWrsieGFN6FRhMLOa6gvGCD aW0nqEP9l2ZV81g8X3MHpJ/A6y6JMd6hh/MzHrfKHDwpOCuYqe60i/7FB9cPSlVJnQa4 /lAwvvovi+dz7bR5p9Zt9OkSaav1/o0UedcIw6ZfwGaJfrKRKuWkG+hiyceXoi/X2CH2 DDCOyxmS3KEIXvJ0QCkW0fyaqF9d0iJw9GhkqhrWJLV9RUfpVrx8n/vOit2FXFkpNSjr reCqT0207UIAqcGwm9KoRPAId2Pr/WTp3xmTqR1IlQuvT2XLEpesr3RNtZpszauoO/8I JxNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724793218; x=1725398018; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EF97xyvUiugjVKOpBxdFrk2D3yPbmnr46zpjYqiuewc=; b=t70ovYFheIb1O7PvI1WkiuDGt+MFgaOyIAr7YIvrho8IpoHDm0hhLcVRZmf2gwSZ1A u6wQWJWHDmnej9Cf1H2LT5jbflTn3/DIWFCzpCtPcql1cHaFwJfTGWbeFiG1V+0JdPMs I8rfJ6mXZ6SlLIxiDbW3f/dAGAS8pESZJlvHed3yi1rOcgrCGVUMCrWcEnRU9g/Or9Wq 1q/KMtIB9bWPdvoApKjbseah9VUFw6L2jdPHz7hRctBQiwoAbFySsVTErqSbUdbpCvHq JHelGQlriRHHcdBlN21R8ze0faYNOtkXfbNQ9Y9yId6q3e5bm04Pe8XffF4mpAhup2DU UVUQ== X-Gm-Message-State: AOJu0YySP8LN1NkJvsUr3gtkWBfFFqJkBiD1TfaGw8+if4sS3Pl2aBDa kWWH/ZebUMobrTAFpf4E9aUKg2sVl0sZtAJQdYF2W5FiDmbDKdzAhzkC3ux60A0EPKJ8B9VgUxd z X-Google-Smtp-Source: AGHT+IFeHOaQQOinKfaPEEz9edSLLrg1iXJ8d06srfP/q87XR18kfRhFgrwlzgD+p2fHeEuxX5wYQA== X-Received: by 2002:a05:690c:46c8:b0:66a:7cbe:6d4b with SMTP id 00721157ae682-6cfb99e6f7fmr50716897b3.12.1724793217861; Tue, 27 Aug 2024 14:13:37 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007fbesm20910237b3.70.2024.08.27.14.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 14:13:37 -0700 (PDT) Date: Tue, 27 Aug 2024 17:13:36 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH 4/5] pack-bitmap.c: avoid repeated `pack_pos_to_offset()` during reuse Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: When calling `try_partial_reuse()`, the (sole) caller from the function `reuse_partial_packfile_from_bitmap_1()` has to translate its bit position to a pack position. In the MIDX bitmap case, the caller translates from the bit position, to a position in the MIDX's pseudo-pack order (with `pack_pos_to_midx()`), then get a pack offset (with `nth_midxed_offset()`) before finally working backwards to get the pack position in the source pack by calling `offset_to_pack_pos()`. In the non-MIDX bitmap case, we can use the bit position as the pack position directly (see the comment at the beginning of the `reuse_partial_packfile_from_bitmap_1()` function for why). In either case, the first thing that `try_partial_reuse()` does after being called is determine the offset of the object at the given pack position by calling `pack_pos_to_offset()`. But we already have that information in the MIDX case! Avoid re-computing that information by instead passing it in. In the MIDX case, we already have that information stored. In the non-MIDX case, the call to `pack_pos_to_offset()` moves from the function `try_partial_reuse()` to its caller. In total, we'll save one call to `pack_pos_to_offset()` when processing MIDX bitmaps. (On my machine, there is a slight speed-up on the order of ~2ms, but it is within the margin of error over 10 runs, so I think you'd have to have a truly gigantic repository to confidently measure any significant improvement here). Signed-off-by: Taylor Blau --- pack-bitmap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 218d7ac2eb..9d9b8c4bfb 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -2055,17 +2055,18 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git, struct bitmapped_pack *pack, size_t bitmap_pos, uint32_t pack_pos, + off_t offset, struct bitmap *reuse, struct pack_window **w_curs) { - off_t offset, delta_obj_offset; + off_t delta_obj_offset; enum object_type type; unsigned long size; if (pack_pos >= pack->p->num_objects) return -1; /* not actually in the pack */ - offset = delta_obj_offset = pack_pos_to_offset(pack->p, pack_pos); + delta_obj_offset = offset; type = unpack_object_header(pack->p, w_curs, &offset, &size); if (type < 0) return -1; /* broken packfile, punt */ @@ -2184,6 +2185,7 @@ static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git for (offset = 0; offset < BITS_IN_EWORD; offset++) { size_t bit_pos; uint32_t pack_pos; + off_t ofs; if (word >> offset == 0) break; @@ -2198,7 +2200,6 @@ static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git if (bitmap_is_midx(bitmap_git)) { uint32_t midx_pos; - off_t ofs; midx_pos = pack_pos_to_midx(bitmap_git->midx, bit_pos); ofs = nth_midxed_offset(bitmap_git->midx, midx_pos); @@ -2213,10 +2214,12 @@ static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git BUG("advanced beyond the end of pack %s (%"PRIuMAX" > %"PRIu32")", pack_basename(pack->p), (uintmax_t)pack_pos, pack->p->num_objects); + + ofs = pack_pos_to_offset(pack->p, pack_pos); } if (try_partial_reuse(bitmap_git, pack, bit_pos, - pack_pos, reuse, &w_curs) < 0) { + pack_pos, ofs, reuse, &w_curs) < 0) { /* * try_partial_reuse indicated we couldn't reuse * any bits, so there is no point in trying more From patchwork Tue Aug 27 21:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13780159 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 808161D416E for ; Tue, 27 Aug 2024 21:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793223; cv=none; b=JCYcJntU1CNU8yNe0eEW7i1E2rakGqKZ3wHmy/MaCA9xpER2UD2sP84LZa9OqzTn9jtkGCLXCOqavlxcAazjMGdvBJjURS7erc9TwQTvMrROkt+pbz7t90x++7VIFVJTfaQtOH3a2yo6aCx1X33Xg52ojaNkMA08HFAFB1vohdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724793223; c=relaxed/simple; bh=sRCenHX+uGn6RzKr6OENVaPcgml6ER3kG8hSFmLUk+g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MGEQzSaYNKhqgOmU1HOgjhdhDacOnJdYKYoL+1K8Hn4qwvzxOsmf4YaZHq+KwbnmFEXkFNm53Dq5X/bn/Q/0H2L3UyeIe5w3Jc7tksKGG7i0xaSxurjHllayGkOn0LkR5CLZHR4EvkXbuDyrwgbDSLJJQe4LkrMCr2087sOXyZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=1B6d4v9J; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="1B6d4v9J" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e11693fbebaso6310103276.3 for ; Tue, 27 Aug 2024 14:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1724793221; x=1725398021; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rWPLWUVIQMhKDaXo0VADEbWKFDERNdh3GSoAUeWfHqI=; b=1B6d4v9JUkjR+riwk54iEhd3zDWHfRVTZ2IG6FSZ132XgUnowYge0/rCRlr2MuOVuq 8ltBARbhpjE0BZjrSOfSBwD7x9IiFzXPBLG/P7NNjnRYTp69WL50FyojwhANOtZbqdi8 ChCodJn56VkK6m46sNbfZS6OVX5MgbY0/zdtdMnNBBmyVKbSckLBNpvjvd+afIBwwju+ Ges6Iq10Nwt6hbMMipOW1B+W/3dmoLt7oNa/yi7kcHtKd5iJ00qRztPOhxu9z7z65mC6 izGEmtO02JR82tfaPqgP/2CK5N1QwBA83xtMWTBCQz3jpbLEcX/Bh8XxeIN7W/xyj3Rn jHlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724793221; x=1725398021; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rWPLWUVIQMhKDaXo0VADEbWKFDERNdh3GSoAUeWfHqI=; b=nb18g5mNbVrODHNdUu54IUCrovUhuOgEPhOygWaDUXZg5YEvPAz8/Sdi9t55Mo0X8d CCI/XaeDWTpxeyDu6gj3nU97asrynjLTEYBUWIp/5O0v/k09iBiPHnxmqKvV33wQOzTa DxbqFOwSSSb91sDWCB11QJHWVzgQjtWLeLlwHG7D1xDHKqNmLYhwTwUALfq2tM2XjRLB C6i1DczMwoq6sevUTL43sRJH/Y0WGg68U8Ov9SxWbgLNFbq3CgdTEgCXETbG5C5yvipN o0zhOdPuU8oZhckST8DLvu1/K1oOYrdU0smnFNl2mpaOxHI/ZPXe2NFxgc25LGH3QV6d SmaA== X-Gm-Message-State: AOJu0YzM0XL9AgmVyd0Uz95LpXS+bO+VheBV99MqsUvxNIhRALykA/dQ fyiVH3sq7Jpog0UWpeTmYCZpbU5n/qgoFF7Yk2eEOilv2D5+M4BnkfndCiZggRQGl12IwPIQ9Ka o X-Google-Smtp-Source: AGHT+IH/sHXVTqzUmnVN8zA4ZSHvjcQmNqLJVB1ejKz5eK8/xr6/K7kOugcxp0Gfq97OBr6SioW2Aw== X-Received: by 2002:a05:690c:4d49:b0:66a:d93b:3047 with SMTP id 00721157ae682-6cfba48827cmr45703017b3.25.1724793221198; Tue, 27 Aug 2024 14:13:41 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39e50178fsm20507927b3.141.2024.08.27.14.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 14:13:40 -0700 (PDT) Date: Tue, 27 Aug 2024 17:13:39 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH 5/5] builtin/pack-objects.c: do not open-code `MAX_PACK_OBJECT_HEADER` Message-ID: <82754d92509e364e96fe35ca20eb709eb6f38641.1724793201.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The function `write_reused_pack_one()` defines an header to store the OFS_DELTA header, but uses the constant "10" instead of "MAX_PACK_OBJECT_HEADER" (as is done elsewhere in the same patch, circa bb514de356c (pack-objects: improve partial packfile reuse, 2019-12-18)). Declare the `ofs_header` field to be sized according to `MAX_PACK_OBJECT_HEADER` (which is 10, as defined in "pack.h") instead of the constant 10. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 700adfb5a8..c6e2852d3c 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1072,7 +1072,7 @@ static void write_reused_pack_one(struct packed_git *reuse_packfile, fixup = find_reused_offset(offset) - find_reused_offset(base_offset); if (fixup) { - unsigned char ofs_header[10]; + unsigned char ofs_header[MAX_PACK_OBJECT_HEADER]; unsigned i, ofs_len; off_t ofs = offset - base_offset - fixup;