From patchwork Thu Apr 13 11:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13210163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE3E8C77B6E for ; Thu, 13 Apr 2023 11:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjDMLRG (ORCPT ); Thu, 13 Apr 2023 07:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjDMLQw (ORCPT ); Thu, 13 Apr 2023 07:16:52 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56ABBA24E for ; Thu, 13 Apr 2023 04:16:32 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 809BD5C0076; Thu, 13 Apr 2023 07:16:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 13 Apr 2023 07:16:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1681384591; x=1681470991; bh=9s qLGlAbOJqQ1Q/dr20+KitMYFnrWMdZfkZS7V6pQJ4=; b=Xw31XP3jIfe0wxYuno pvK7GjfUwx4t8aTPpI5levuQJb80RKH25xBhYvMCm8qtUgirvHCYadKXCebQGiPm l0WxEgJdm98PG1JgZpgF4f/zitHfzmsQXehdilq2vMoMqcx/LOGMHeBn0+7BaACw AN/Dnl3+hCb8RwWid28XL8E4oV28zY3HJOdnlGKmPfjLzTBDHYAAXjonLx7h8Rbe /wW/UHxOmiQ7plf/x1COBFWz1ABEfcAvp0MqjJxLqC7MkBGjOfWLD4Hda4jjf1Uw 2VEFH5vKzwD40vJ84rd4SgkG2IF8er1Wwp1u9U8KnUMDlYen122tQha+Xbyii1WG e56Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1681384591; x=1681470991; bh=9sqLGlAbOJqQ1 Q/dr20+KitMYFnrWMdZfkZS7V6pQJ4=; b=a3freVCd7OKzRFiwHXFETe6borLQ+ aA7ZYhKb8SCZ8sBYYTrqJ+IlnAaF+IW1w/30D/g30H/z7PbfCyzCjY3PaJXXhDtI YNiyq1FGGgdzk7hP+rbcD7OJsK4+nADoCak961dOENZxFA4UzcaR8l2Z3rK2Fm9g ylmR2a6cdXq0b8xZcUoVnRwlvcBSyXEEwbwRVBpUmVouuy/ovktMsYjhaKM6P/pd oKhctRuRTIFAVW8w8alJdJKf8L2M5KBNuF5DXPlJiT7EhC9cgAaymTwS5A27IL3u VlIoTCBhLmUlX1rOS3/KKkhX5K8e1aJLRQuqgyxUFyuEhW069d4CF7QYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekkedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Apr 2023 07:16:29 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id e97d63e3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 13 Apr 2023 11:16:07 +0000 (UTC) Date: Thu, 13 Apr 2023 13:16:28 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Taylor Blau , peff@peff.net, dstolee@microsoft.com Subject: [PATCH v3 06/10] pack-objects: fix error when same packfile is included and excluded Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When passing the same packfile both as included and excluded via the `--stdin-packs` option, then we will return an error because the excluded packfile cannot be found. This is because we will only set the `util` pointer for the included packfile list if it was found, so that we later die when we notice that it's in fact not set for the excluded packfile list. Fix this bug by always setting the `util` pointer for both the included and excluded list entries. Signed-off-by: Patrick Steinhardt --- builtin/pack-objects.c | 8 +++----- t/t5331-pack-objects-stdin.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 7d0e864c35..c5147d392f 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3355,11 +3355,9 @@ static void read_packs_list_from_stdin(void) for (p = get_all_packs(the_repository); p; p = p->next) { const char *pack_name = pack_basename(p); - item = string_list_lookup(&include_packs, pack_name); - if (!item) - item = string_list_lookup(&exclude_packs, pack_name); - - if (item) + if ((item = string_list_lookup(&include_packs, pack_name))) + item->util = p; + if ((item = string_list_lookup(&exclude_packs, pack_name))) item->util = p; } diff --git a/t/t5331-pack-objects-stdin.sh b/t/t5331-pack-objects-stdin.sh index def7640c91..1e23cc2e61 100755 --- a/t/t5331-pack-objects-stdin.sh +++ b/t/t5331-pack-objects-stdin.sh @@ -169,4 +169,24 @@ test_expect_success 'pack-objects --stdin with duplicate packfile' ' ) ' +test_expect_success 'pack-objects --stdin with same packfile excluded and included' ' + test_when_finished "rm -fr repo" && + + git init repo && + ( + cd repo && + test_commit "commit" && + git repack -ad && + + { + basename .git/objects/pack/pack-*.pack && + printf "^%s\n" "$(basename .git/objects/pack/pack-*.pack)" + } >packfiles && + + git pack-objects --stdin-packs generated-pack packed-objects && + test_must_be_empty packed-objects + ) +' + test_done