From patchwork Wed Feb 14 14:25:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13556598 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 B205F5645D for ; Wed, 14 Feb 2024 14:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920737; cv=none; b=M8t++YIM1rQt5qoGInoIGJNDN2I9ex0EaY2Cxf/thBLTFoQ2E7eLxvRftJpzImB0ZYSmps25KojsaA99StP/BW2XjxHO1YrB4PPXCy90tITtuhjuX+Ap4YB1ru+GZiJynX76VeBcXjaqYydB/XiWTZ4PVKNzomZvMm3loVLAR60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920737; c=relaxed/simple; bh=dhCE+huWXteC6mmhP+7RS+wH/sY+meWZqTNaOBwgfmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uLqki1u4Z/YL8obBxLu00UxzA+H2jnhAF3/Gs9QGnAaQPXHj5JRjjGLUx1/27auFSHlv2e77LnWhuJ4G09yikCUTYZTpZQF/M3Ztjlcb4Gb2+XLv0+lbvfUJ/Q7ZzKm+b7v3k1SiIVYfPxRz97Px2xKiWKOzg9ptuI2q9kgYKLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YHWIksq+; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YHWIksq+" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d11c55d7f2so7448221fa.2 for ; Wed, 14 Feb 2024 06:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707920733; x=1708525533; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z5Mbj7tfXSKjkwIrHld85eScy2JdGwyHQrBCiDIdT+E=; b=YHWIksq+WnK6Tk20dSGcc+A6rv/e2AOVgp3oeuwrSu4YZWFfGQB1zQdpN1lxP8HLF1 i9fcXnemg7Bm4k7vdZSuyxsqemo1mx/LaoNa6kgS/X23TTLSZLhOMJr7jM7vRO4lq2PO 0iuGFQiCZuONZooMYrlEKzmk+fEgYyN7Z03r0W8veDlKa/HPdNMAou9KmZpfo/AVOLyD r7s+EV14JXAPkgJ0jPOPKHMtTDznyyl+CHeJiopt37eevx7rBUFXnjh6OCKZ8QUfTZN4 bbKJzOeB8xSDqUs/DGdtaKnUvmZ9zOkhdjkUOX37/svZpnHuHLQO7eCkSc+9C6aMVnoM lAgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707920733; x=1708525533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z5Mbj7tfXSKjkwIrHld85eScy2JdGwyHQrBCiDIdT+E=; b=dK6U17St7Hld35OA87B/TKlQu5OG8T8MrfphTCRzB4R77kR7ulPumaG1BUinMchXp+ /LgT9u4JBLnzXj0Eb9IAwSfZDAJOQ/SH//WBixlUW8oMbiZh0P+M8ueQ3D4g8XhenbuI HM8kgHfIJ9K3kBtStGRtf6zwHtOXJWWuEcf7xaAhFYDkcQCNH7Gf0gvoX2rVKJb2MoGF qHGEsuBG9Z7Pex3IcAVEYCXvkBQzdtpNcMzNlQ3Cvg7bvK8pwQFWdiiphXH6zvKEcB4r 9o0FzM0eqKTgDo0lJwfcOvjDgwWQLa6lrWvHyAXd0aS5kqMT0NH5qxhmIFn3NtpeB/gX +pNQ== X-Gm-Message-State: AOJu0YzNPEHy6UTmWd25C3mF5KZpQFS2j4KwXr53eFlt6euDMJL6egSB WE1XzupuMwOKd0j3/Sq5ZOaxqf7IVqEVi0Qd3nfb/RDLHs1gw6vXl+V3OgXu X-Google-Smtp-Source: AGHT+IG4R/5xLYXmCbkp1L1oZLz3uEzqmQ+S3mySB+sCEUs1a8yC298d7pzvXsHi5VcxGOGR+OeXdQ== X-Received: by 2002:a2e:9657:0:b0:2cf:481b:9cc5 with SMTP id z23-20020a2e9657000000b002cf481b9cc5mr2317505ljh.19.1707920732493; Wed, 14 Feb 2024 06:25:32 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVV1uugc5S6zfP8gS746CXvf5M9mpmpP083uqUvRX9hulDRiOkdPQJ1udVm5N+zXZVicwumu2Id77wrLIXgo/9795WsXVYQ4iWaiSDIV/3L9s55k7gxy05zGFWZo6nvhJ6nxLTlu038wmxlLvGRWHWIgTud4PoAOTsh1A== Received: from christian-Precision-5550.lan ([2001:861:2420:9770:4d2b:b120:8137:3062]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b00411ce6def3fsm2146871wmp.38.2024.02.14.06.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:25:32 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Linus Arver , Eric Sunshine Subject: [PATCH v3 1/5] t9210: do not rely on lazy fetching to fail Date: Wed, 14 Feb 2024 15:25:09 +0100 Message-ID: <20240214142513.4002639-2-christian.couder@gmail.com> X-Mailer: git-send-email 2.44.0.rc0.51.gda36843b44 In-Reply-To: <20240214142513.4002639-1-christian.couder@gmail.com> References: <20240208135055.2705260-1-christian.couder@gmail.com> <20240214142513.4002639-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Junio C Hamano With "rev-list --missing=print $start", where "$start" is a 40-hex object name, the object may or may not be lazily fetched from the promisor. Make sure it fails by forcing dereference of "$start" at that point. Signed-off-by: Junio C Hamano --- t/t9210-scalar.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh index 4432a30d10..428339e342 100755 --- a/t/t9210-scalar.sh +++ b/t/t9210-scalar.sh @@ -154,7 +154,14 @@ test_expect_success 'scalar clone' ' test_cmp expect actual && test_path_is_missing 1/2 && - test_must_fail git rev-list --missing=print $second && + + # This relies on the fact that the presence of "--missing" + # on the command line forces lazy fetching off before + # "$second^{blob}" gets parsed. Without "^{blob}", a + # bare object name "$second" is taken into the queue and + # the command may not fail with a fixed "rev-list --missing". + test_must_fail git rev-list --missing=print "$second^{blob}" -- && + git rev-list $second && git cat-file blob $second >actual && echo "second" >expect && From patchwork Wed Feb 14 14:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13556600 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 BDF6D56762 for ; Wed, 14 Feb 2024 14:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920738; cv=none; b=hTMnUY3nCnmdInr8WEtanzeGY2QVFLMDFu68Ym8F4IHvx6kfSy0eD5H+UECbEvcvFfb4lLt38zN9kXXIZlUD78stNG2P4qVsxFOBJ1sCyd+ybBalqnRPzz++LamBour+/znhD4hsUpxsbxk9ijxdC6WSZrLZ1yMYg0lfRhxWrCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920738; c=relaxed/simple; bh=Dxc33nRNIlbA6elYpHiYl94IJgiQQMD1Pj78f3PoRxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NLCkdXCbRG1MoIFA7Uy2hrsbqmNmt3VyUMho3jRXVGzyNZDCCiU3ALPnoKwLV0muMNBpFjonjY1+ACkpVOCxiSo2YS0gM6Im5/y2zTNWciXZiJbBwIbl/EcWJpsMAiREh80/DmQAZAMjIkJsCrDQ8LgnCo/Nk4pE/NVUDdtmEpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Hue/R9kD; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hue/R9kD" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-411f03e5c46so3349055e9.0 for ; Wed, 14 Feb 2024 06:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707920733; x=1708525533; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gnUxNkCNK+Mk0z25u0z4dFKFaLh9Oge/JjoqROpyqc4=; b=Hue/R9kDX2069L5XOxqDL02uFLEqwQB5LvHFol07FRI47dnmn4Lp/G+x89U9NsqLko tplqiX4xAB4mOB9v99snAv3K5DvPEUGqLm/55napT7IAnftMOcdnKYWrmiMXnDhbEpyu OFCU1R3m46+wtkFPAS6Neqb+kAPxA6BYwjswGiKLPdykO5tG4XAv3TYgAoWi/g6ddPx+ 0DidKKBq7zLwUpH1YTNbMadiBSomiWUsxuRRo0K/AJujakGEC9RbklX8vzC2SulK1Rf5 /jDYWqOMh2Ub8nJ86ReDDNyA+I0QIN2zCpcRQN8Yc9n7VxOvf06U6CAjFwWhRHSNhKYH pK/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707920733; x=1708525533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gnUxNkCNK+Mk0z25u0z4dFKFaLh9Oge/JjoqROpyqc4=; b=hcmIGItjPGnmn+4BC4oaOXr3pjEpcNs5lby8Wi89jr+XBTBYZUdCaeuT+WDr4FouUc cKUahq5EUVNPaN8/YV+l6Hc/zmVi9+16wU+4/nabRgcneA78R/t8Q84HLU1ao1jYRmXl qT0sp88LVPrZgUIixc5wKNA04Do2ZMTmC25LSNxadS/XdSbt4l3AF67/0cvxz65Z9fMj 6qr02PzYM/ZrLH9vypbnDICPyhteVvXmKXhItPB+hS7mk4NAmue9GdnjkZHStsNrtZtT o6l+9If0YCK1KlddTiLEMpsmkUrGAmFPO1842/W4IvVWRZP1us/w4t4z7fIk6JCGXt4f VziA== X-Gm-Message-State: AOJu0YwhY/EmVu4nyGrxh1R3Q6UHIellPCI4qR6cpHy4715DOSMZvuM0 8HrkzQomvALINF/F8oPd+I75wc0xcAr6F/mcCU8nOwkdJFT55XlnKgya40Sc X-Google-Smtp-Source: AGHT+IGV+AG7Epd/2JWu5JTELbGDs8A0sYmbFZO797EVt9t00TQ5o5GltRUCT4i+hxEZsFaR3Smg0g== X-Received: by 2002:a05:600c:35c1:b0:410:99ee:d65a with SMTP id r1-20020a05600c35c100b0041099eed65amr1738208wmq.20.1707920733203; Wed, 14 Feb 2024 06:25:33 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXK7d0wvp6fVsWsSiMw6SK5PKojRQGP9ZV5OZO/9ONz7Iypv2dxPxpXprI+snasMqdcdRmnqr0Huh/T5oAwquoKG1IKqV8XzDNuDVaVA+7u85ZW47bfoVtRzcLZzGP6Zx7vh0szqRAyF2soqaBsEp96co7w4BDehPyV4LpfFe2wFc+6YkiNcZEdCbtrvIeGynm7owc+V359gsr14EqqA/z4Di+CzCMWKyntGV8j3oLz Received: from christian-Precision-5550.lan ([2001:861:2420:9770:4d2b:b120:8137:3062]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b00411ce6def3fsm2146871wmp.38.2024.02.14.06.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:25:32 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Linus Arver , Eric Sunshine , Christian Couder , Christian Couder Subject: [PATCH v3 2/5] revision: clarify a 'return NULL' in get_reference() Date: Wed, 14 Feb 2024 15:25:10 +0100 Message-ID: <20240214142513.4002639-3-christian.couder@gmail.com> X-Mailer: git-send-email 2.44.0.rc0.51.gda36843b44 In-Reply-To: <20240214142513.4002639-1-christian.couder@gmail.com> References: <20240208135055.2705260-1-christian.couder@gmail.com> <20240214142513.4002639-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In general when we know a pointer variable is NULL, it's clearer to explicitly return NULL than to return that variable. In get_reference() when 'object' is NULL, we already return NULL when 'revs->exclude_promisor_objects && is_promisor_object(oid)' is true, but we return 'object' when 'revs->ignore_missing' is true. Let's make the code clearer and more uniform by also explicitly returning NULL when 'revs->ignore_missing' is true. Helped-by: Eric Sunshine Signed-off-by: Christian Couder --- revision.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revision.c b/revision.c index 2424c9bd67..4c5cd7c3ce 100644 --- a/revision.c +++ b/revision.c @@ -385,7 +385,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name, if (!object) { if (revs->ignore_missing) - return object; + return NULL; if (revs->exclude_promisor_objects && is_promisor_object(oid)) return NULL; die("bad object %s", name); From patchwork Wed Feb 14 14:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13556601 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 2E8845813F for ; Wed, 14 Feb 2024 14:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920741; cv=none; b=mUMrhyDrxzLx4n7ijyy4pcE71jAmdPvi7GJy1l+2/2oqghjr1PZDQDPS11N5wNoKjpxN+zNoCNGvGpmRWC83LLwyjOSdcGdXI22oRdsBArYhoo9dRcxCP8ulVxjBjdDPcfqDEKiniG3gKRqVsnS3kSRrem4I1vLC0Pt8YY6Zy7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920741; c=relaxed/simple; bh=5nN7PCkMnOl6irnT2/UCukUhG295v3VwjpAuyBWB3jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=folr0Q6D32MFLFzFujssgpo0hCGcLx+HMc+797lJ8Xol2qDq6Mn4ClXUVT36JLspi4hvx5H/gG8cn0jTUzFwEIjzr2anQD8Itzes5Sz9a3cB90B90wfVKbv3cSnteZbzW5Ml/I0TgDCb0i8iCFjrJmPia+yXn3M6I8AZojV9krY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kvLIT+MD; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kvLIT+MD" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51167e470f7so6800731e87.2 for ; Wed, 14 Feb 2024 06:25:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707920737; x=1708525537; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nQMITNF0upK+7gZ4ZuIZ67TW7nc5tOPXMcQcm2qM/vA=; b=kvLIT+MDTzkOLMYNVe1gUGJ5xeC+C/OmLqmgY8y+RO3jw4eb8F/57n6QX7HJV6k2a5 cqw89LS5qInvcfcoiLH9GzzYzqdpaybdXI+NR+GOkobJ+b/dd5+XRwtyU/UbJhgG2woe OaJn34sNI+P5N4MOZWG3umH4fgTqDoPLZKYXTpB76b6REw85OobJZ0fXgmE9bpZlW5KA M6kTnQibX99Hj9x6viavMHhm/mSHsbvTwekUPjq4A8j3kfevIOi09BqQvBhoBAycXX67 AbYvg8qquOVx6NX9B6ZU+n32MTNfr3siUASUOe1qIy9Q/hGhBdMB+kx3uIM0MB3yes5Z 0JRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707920737; x=1708525537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nQMITNF0upK+7gZ4ZuIZ67TW7nc5tOPXMcQcm2qM/vA=; b=SVS6UkvPBhEZTvnG4XXx2c7W6Ehl6dkzIDqn9OtXyVgCuUHYoPUP91ItnTg92x4+lS Zuyz15/U2ioJQ7zwGual8/c/eol/YsOSGW8wto6MeKP/t8nMrlEfVe7aKdk6d5DtpWqh OLzpG2a+MK0lAt8rsBZo89iqLC9KGlTgKQC54nVV3HH+LK7xZrrufKakhGB8kndtn919 f6HKAAeUORcjeLmfLDH9U1tvlgu6s+ky4LhgE2SfOFsdU88iKJXQ6IOwZhnJFk+e3hcL pJlrr1foNTVlHf9tbzg2T3wCxQODBXZ284UPvCyyZgeLuzXGeUMI0Qq4eZd0n7zM5A4a YqFA== X-Gm-Message-State: AOJu0YyUh7flVscJ3iHrZI7vY/yfyjDzG3palXnGXtXwRXDmUAA1y1Ew 8+stS7TzSpEIKPFDzv1odfjpxqnkc7glyxaumY0yewyKXweuuOqTYLNoXIj/ X-Google-Smtp-Source: AGHT+IFg1L0qRJVGJ4aGt9aC/lIBCbCCptBbWs04gJczIBPuhBl4qfKdBwKf9DksQftXvdo+9SL9Tg== X-Received: by 2002:a05:6512:239e:b0:511:ac65:4e68 with SMTP id c30-20020a056512239e00b00511ac654e68mr1209142lfv.15.1707920735989; Wed, 14 Feb 2024 06:25:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX0D3H5Fh6OCprmLVUJqG9lWTgs9TyeTmpxdJEnh/ORO/nJbyLRPjfnC8w4855+luYJd8xDNnX0TMNUXjUUATbUEUSBXj9LHk5CrQX6xZFbNbyNaI9S5xm9Pw43bK2sQlGK/lvGB8UNbQ2XwYQcI2P8xeFCXawDoRLXYMsMSx8fiYijgx5hfi8sJvZrEAABW5lshgha8vg7neMPmxZOaL+XB4xIDFFK3fH8H07gwNo1 Received: from christian-Precision-5550.lan ([2001:861:2420:9770:4d2b:b120:8137:3062]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b00411ce6def3fsm2146871wmp.38.2024.02.14.06.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:25:33 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Linus Arver , Eric Sunshine , Christian Couder , Christian Couder Subject: [PATCH v3 3/5] oidset: refactor oidset_insert_from_set() Date: Wed, 14 Feb 2024 15:25:11 +0100 Message-ID: <20240214142513.4002639-4-christian.couder@gmail.com> X-Mailer: git-send-email 2.44.0.rc0.51.gda36843b44 In-Reply-To: <20240214142513.4002639-1-christian.couder@gmail.com> References: <20240208135055.2705260-1-christian.couder@gmail.com> <20240214142513.4002639-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In a following commit, we will need to add all the oids from a set into another set. In "list-objects-filter.c", there is already a static function called add_all() to do that. Let's rename this function oidset_insert_from_set() and move it into oidset.{c,h} to make it generally available. While at it, let's remove a useless `!= NULL`. Signed-off-by: Christian Couder --- list-objects-filter.c | 11 +---------- oidset.c | 10 ++++++++++ oidset.h | 6 ++++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/list-objects-filter.c b/list-objects-filter.c index da287cc8e0..4346f8da45 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -711,15 +711,6 @@ static void filter_combine__free(void *filter_data) free(d); } -static void add_all(struct oidset *dest, struct oidset *src) { - struct oidset_iter iter; - struct object_id *src_oid; - - oidset_iter_init(src, &iter); - while ((src_oid = oidset_iter_next(&iter)) != NULL) - oidset_insert(dest, src_oid); -} - static void filter_combine__finalize_omits( struct oidset *omits, void *filter_data) @@ -728,7 +719,7 @@ static void filter_combine__finalize_omits( size_t sub; for (sub = 0; sub < d->nr; sub++) { - add_all(omits, &d->sub[sub].omits); + oidset_insert_from_set(omits, &d->sub[sub].omits); oidset_clear(&d->sub[sub].omits); } } diff --git a/oidset.c b/oidset.c index d1e5376316..91d1385910 100644 --- a/oidset.c +++ b/oidset.c @@ -23,6 +23,16 @@ int oidset_insert(struct oidset *set, const struct object_id *oid) return !added; } +void oidset_insert_from_set(struct oidset *dest, struct oidset *src) +{ + struct oidset_iter iter; + struct object_id *src_oid; + + oidset_iter_init(src, &iter); + while ((src_oid = oidset_iter_next(&iter))) + oidset_insert(dest, src_oid); +} + int oidset_remove(struct oidset *set, const struct object_id *oid) { khiter_t pos = kh_get_oid_set(&set->set, *oid); diff --git a/oidset.h b/oidset.h index ba4a5a2cd3..262f4256d6 100644 --- a/oidset.h +++ b/oidset.h @@ -47,6 +47,12 @@ int oidset_contains(const struct oidset *set, const struct object_id *oid); */ int oidset_insert(struct oidset *set, const struct object_id *oid); +/** + * Insert all the oids that are in set 'src' into set 'dest'; a copy + * is made of each oid inserted into set 'dest'. + */ +void oidset_insert_from_set(struct oidset *dest, struct oidset *src); + /** * Remove the oid from the set. * From patchwork Wed Feb 14 14:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13556602 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 65A5458208 for ; Wed, 14 Feb 2024 14:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920741; cv=none; b=T2WvZPnVJ17KUG28veSAtAP4oLW5dfhL1tP/5f5nOCQ13Acxo8w0aZ6BAZbx6jSrfI/IFq8mk/vX0OrEkD3JxoOEak4ULzOAlJlbKoyd5WFguRbxA7SijkIzlo0z1P3yDrYa69nQjSfHQhvh9kzZaim6c0wMYUF+pI36HbAv0kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920741; c=relaxed/simple; bh=+A2x+78oJ214aJwVUgpGyqAaZEeS8ctgMXyCJfoNOzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j+iHPoGlNMNUnv4s0rMh84jbm7+IbmK7g+HrADPJn5b30k2BV/2+keXKcmbiEkJHXdWsbXEYSHBTBwrCzEYa4dIv1fOte8G1sbq71b0P9446DXc8i9bTSvcrN3lXXBOXO0IdNdbmhj0PgbIoti2pSusrZXVYks0FplC5cOHO8pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dvFgw2qr; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dvFgw2qr" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3394b892691so575354f8f.1 for ; Wed, 14 Feb 2024 06:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707920737; x=1708525537; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GHyLuG/A0kwiPsQ/I3b17OCMQ+Vhva0X8aSEWeqHOCw=; b=dvFgw2qrDMoLipQg9I60PAWr+X9hoZkA2n1CtEcs68ais3/q+eH5ZIe89V5CsoY5nb RvZfAmhCo0F+aQBAqtGMqPNsOukj63oQRJY+4MmL+yJPH70Q4e8LKjSlMl1ByqKiZXLn btxRoxGv70foYGzbZJeu3OXC2Nkv+EqXTGTV2J/Ycn9tAaf5Sy5aQiDL5YxrMiijswGa JejQdZZaefBkZHeWVBzOERAVrjQV/oYK9ymk7/B3Sjctp0JrMzE+8bnI4JOA0Z604GSJ 0j9gyRWWJF80AnBEJ/4XUO2FRTqsTWTQQMMoZK6xp19w8cUye4rTEZcFlqTQfGwsbzW4 iRUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707920737; x=1708525537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GHyLuG/A0kwiPsQ/I3b17OCMQ+Vhva0X8aSEWeqHOCw=; b=vkWqnECidGBfagzhd7rcTN+fApRNjodjbTlk/b+d0nKh95ZolRGcaZILWIGIQbAXzP mxPG/Ts1TQ76d6GHXf7773zagQduaOqolXc0fLnBF2jpR8fX4OkbUa5RwjC9SeLmmmsk 54s0LubYmFNiH55Na5+cf+KhSJX3r3kn4Wh8YHWoeyGiJnsTjbPBBjSjSYERjDyNcJdO YAzeCw0f1q0e4zHaCaXW/1o3SYrpxTw8jcFjsRFxpX9z/wJT4eYSg01607s6ZeA61sNX 6rTLZwcVjrhN26iapoXVg3WAgzxt+DCF4PEO5Yue76B+YV2RxVBcSr/ffCBub4EC/kiZ AzxA== X-Gm-Message-State: AOJu0YwSYjU5rn8DrgBLEhiZOVD/IHElOur6KOaoCGwAfHTwIuGbY3lf ct7OVyQn1HCSeWNIE2ZAAVDfq425Eln8PuGNfhSLqedGIYH0z+2UOHcLa+cB X-Google-Smtp-Source: AGHT+IEGvrcK7DBX6JROA/owPEIeNaNpMw0pNGTRz4KDD5Ghrr/9+5TBvroo1PEYl807G8Q7MQFFXA== X-Received: by 2002:a5d:4243:0:b0:33c:d5da:7970 with SMTP id s3-20020a5d4243000000b0033cd5da7970mr2073153wrr.6.1707920736785; Wed, 14 Feb 2024 06:25:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVaDxJprmqAp4GmOga4tXreeNWRcylF26jq5lwil0eZoR+zZPG/a0Chs8or4tqlAF6ZfCT28BCwhZRedIm4O3Be8ws72XLJ2Afxp0xJvB3rV6f7qmNuTUhfayy/0PH8eOWb4Fk2mo10fHaevH8b15kZh5Md6ki4u4OJ2HHy8PT92ElTGKBTNm8b1eMly2xkYa+RgJLWrJo6iKTSwoOAdBn5wXCrDF8cVyRqAUwmZtN9 Received: from christian-Precision-5550.lan ([2001:861:2420:9770:4d2b:b120:8137:3062]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b00411ce6def3fsm2146871wmp.38.2024.02.14.06.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:25:36 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Linus Arver , Eric Sunshine , Christian Couder , Christian Couder Subject: [PATCH v3 4/5] t6022: fix 'test' style and 'even though' typo Date: Wed, 14 Feb 2024 15:25:12 +0100 Message-ID: <20240214142513.4002639-5-christian.couder@gmail.com> X-Mailer: git-send-email 2.44.0.rc0.51.gda36843b44 In-Reply-To: <20240214142513.4002639-1-christian.couder@gmail.com> References: <20240208135055.2705260-1-christian.couder@gmail.com> <20240214142513.4002639-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Christian Couder --- t/t6022-rev-list-missing.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 211672759a..5f1be7abb5 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -46,9 +46,10 @@ do git rev-list --objects --no-object-names \ HEAD ^$obj >expect.raw && - # Blobs are shared by all commits, so evethough a commit/tree + # Blobs are shared by all commits, so even though a commit/tree # might be skipped, its blob must be accounted for. - if [ $obj != "HEAD:1.t" ]; then + if test $obj != "HEAD:1.t" + then echo $(git rev-parse HEAD:1.t) >>expect.raw && echo $(git rev-parse HEAD:2.t) >>expect.raw fi && From patchwork Wed Feb 14 14:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13556603 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 134725821A for ; Wed, 14 Feb 2024 14:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920743; cv=none; b=A9vcK1nY52TCV7dSg1PrinR3FWJ+j7PXiAkMUGCfT+F4N0kFao2cSS9pEzzcKHyGqFBE39OXgo1ti9x314eCPgB5aBhIDGcXclL49559oOHnS4ZwOhJDe4a71M+5YiZ1eqmuUajjM29pz01Gac0z/DHxXoQiY4nq/p3eiUEmNeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920743; c=relaxed/simple; bh=qYDKnH8XsoxhgXHF1MGxDi82L0SeIB0WPBYwt+1CLjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuZI5pV3l7i176BD7ztnkLaA89QiRn+8M8nkzE2dYeX+RhlznYNaDMyanszCiOme9qFPHRtZRyNMGbBkLhkDI+fHAnt3RhZm7T4B6FUuP3IlOj+iYaAOoX63//PqCEZ83K9L56AhXJ+3piO8TlPNAP+Hwo1W7AhuGQKevhQgKbg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RptboWYj; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RptboWYj" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d10f52e7d8so15749261fa.3 for ; Wed, 14 Feb 2024 06:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707920739; x=1708525539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KPCVVzHLuZot1w52tgWkn2blYrDJ9lNOsU33TvSANHE=; b=RptboWYj3SjtmsJdFMN/XSRQhXluMovM58+hClwjg6al4BxzWb4cfewxkP8LtLaqfD p9OjZNgnFivK7emXS8HYXFxvvD7kOWFitG5AoL5pWk7csgqY2si7IueivrAr0KCzUIdH U7XTiFMeC6kWlUnFp/TpPEqJsdx8183kpPtErA11/bc6+BK7gxwMu9KBDAuS69ACJnYK Tj3hxK6RRLFv0wD93ap/hNcVc344yyspv/IKgNe5xRvRcpIXWlDzBXsSE/ktJaTB+tnn W449VRNPOdlgkV4Znow6hgA0ylth+7oeZ7PUQ4mZNtNDcBYYJPbXGQvZKKPkcShyhOhx 3WOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707920739; x=1708525539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KPCVVzHLuZot1w52tgWkn2blYrDJ9lNOsU33TvSANHE=; b=oY6Ni6TAD0jIHZ0RRQpnlZy8HZYFlDXekriC2TVlZKIZ4qQuNRnaxNsZWJ/Z5ZPoLT SN9/p+bocmrO3rZ4z67nmocg4VwkDV5pLmjVkSip44jpdWhx1X4EHo2v0XwPWp6Jm+h0 tc6NR/oNlAA0G3A/q+MkyqGjtsPwBG8fZjJYKQJQXKasrWzPHYUBxa05/xCFIPZLRmeV pgGLbGIIVSaNtZMV+uuTa53+2WZtUESJYVBmuUFvI9iW9yMQhJn8DjD/2bD2D4rAkW72 QDcYv754kXhC5vbcETsOA1HhmeBey7Cou+4xho5RIT04qd2SExWscADLfEDfeAmYYtI0 KPIA== X-Gm-Message-State: AOJu0YyiSUVlGZyYy6Y7yUTVEiVCspL0vaVa8VX/GltpjSlzdbD6XNYT jyuRLHHeAkJf4ZSw9tgcblIMjgdUY5hUMyK2kYbiZXE/osST3lwMdxivmcIO X-Google-Smtp-Source: AGHT+IH90rRxWSjudovS050qcGKex5CRGeR8GLsazR57TwG0Q338/NCULK8VIoojrC1/a7JyohiZeg== X-Received: by 2002:a2e:bc21:0:b0:2d0:cb3d:29e4 with SMTP id b33-20020a2ebc21000000b002d0cb3d29e4mr3144930ljf.41.1707920738679; Wed, 14 Feb 2024 06:25:38 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVnqRW/ZUz98Bdvol8yxf8vBp+3d0AGqGvgXrZUudDn1mGUpTa4f8djUHlrBjxJNpt0LTq0xeUjI9TESl2IfbgrXsJf+v0ViwpMqj4S9wZHW8UhmVB+oXeFrlNDaBfJIm7C4QB8D399xr0DI2woqPA5RaOVGGgXef2kiZqfADWdJxuFWSgN1Ea783nMqjMlLQy1vWMuRYoPE2gKc7DoObfSHAsTTbnnJI81bf8rLnyr Received: from christian-Precision-5550.lan ([2001:861:2420:9770:4d2b:b120:8137:3062]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b00411ce6def3fsm2146871wmp.38.2024.02.14.06.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:25:37 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Linus Arver , Eric Sunshine , Christian Couder , Christian Couder Subject: [PATCH v3 5/5] rev-list: allow missing tips with --missing=[print|allow*] Date: Wed, 14 Feb 2024 15:25:13 +0100 Message-ID: <20240214142513.4002639-6-christian.couder@gmail.com> X-Mailer: git-send-email 2.44.0.rc0.51.gda36843b44 In-Reply-To: <20240214142513.4002639-1-christian.couder@gmail.com> References: <20240208135055.2705260-1-christian.couder@gmail.com> <20240214142513.4002639-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In 9830926c7d (rev-list: add commit object support in `--missing` option, 2023-10-27) we fixed the `--missing` option in `git rev-list` so that it works with with missing commits, not just blobs/trees. Unfortunately, such a command would still fail with a "fatal: bad object " if it is passed a missing commit, blob or tree as an argument (before the rev walking even begins). When such a command is used to find the dependencies of some objects, for example the dependencies of quarantined objects (see the "QUARANTINE ENVIRONMENT" section in the git-receive-pack(1) documentation), it would be better if the command would instead consider such missing objects, especially commits, in the same way as other missing objects. If, for example `--missing=print` is used, it would be nice for some use cases if the missing tips passed as arguments were reported in the same way as other missing objects instead of the command just failing. We could introduce a new option to make it work like this, but most users are likely to prefer the command to have this behavior as the default one. Introducing a new option would require another dumb loop to look for that option early, which isn't nice. Also we made `git rev-list` work with missing commits very recently and the command is most often passed commits as arguments. So let's consider this as a bug fix related to these recent changes. While at it let's add a NEEDSWORK comment to say that we should get rid of the existing ugly dumb loops that parse the `--exclude-promisor-objects` and `--missing=...` options early. Helped-by: Linus Arver Signed-off-by: Christian Couder --- Documentation/rev-list-options.txt | 4 +++ builtin/rev-list.c | 18 +++++++++- revision.c | 14 ++++++-- t/t6022-rev-list-missing.sh | 56 ++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index a583b52c61..bb753b6292 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -1019,6 +1019,10 @@ Unexpected missing objects will raise an error. + The form '--missing=print' is like 'allow-any', but will also print a list of the missing objects. Object IDs are prefixed with a ``?'' character. ++ +If some tips passed to the traversal are missing, they will be +considered as missing too, and the traversal will ignore them. In case +we cannot get their Object ID though, an error will be raised. --exclude-promisor-objects:: (For internal use only.) Prefilter object traversal at diff --git a/builtin/rev-list.c b/builtin/rev-list.c index b3f4783858..ec455aa972 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -545,6 +545,18 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) * * Let "--missing" to conditionally set fetch_if_missing. */ + /* + * NEEDSWORK: These loops that attempt to find presence of + * options without understanding that the options they are + * skipping are broken (e.g., it would not know "--grep + * --exclude-promisor-objects" is not triggering + * "--exclude-promisor-objects" option). We really need + * setup_revisions() to have a mechanism to allow and disallow + * some sets of options for different commands (like rev-list, + * replay, etc). Such a mechanism should do an early parsing + * of options and be able to manage the `--missing=...` and + * `--exclude-promisor-objects` options below. + */ for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (!strcmp(arg, "--exclude-promisor-objects")) { @@ -753,8 +765,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (arg_print_omitted) oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE); - if (arg_missing_action == MA_PRINT) + if (arg_missing_action == MA_PRINT) { oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE); + /* Add missing tips */ + oidset_insert_from_set(&missing_objects, &revs.missing_commits); + oidset_clear(&revs.missing_commits); + } traverse_commit_list_filtered( &revs, show_commit, show_object, &info, diff --git a/revision.c b/revision.c index 4c5cd7c3ce..80c349d347 100644 --- a/revision.c +++ b/revision.c @@ -388,6 +388,10 @@ static struct object *get_reference(struct rev_info *revs, const char *name, return NULL; if (revs->exclude_promisor_objects && is_promisor_object(oid)) return NULL; + if (revs->do_not_die_on_missing_objects) { + oidset_insert(&revs->missing_commits, oid); + return NULL; + } die("bad object %s", name); } object->flags |= flags; @@ -1947,6 +1951,7 @@ void repo_init_revisions(struct repository *r, init_display_notes(&revs->notes_opt); list_objects_filter_init(&revs->filter); init_ref_exclusions(&revs->ref_excludes); + oidset_init(&revs->missing_commits, 0); } static void add_pending_commit_list(struct rev_info *revs, @@ -2178,13 +2183,18 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl if (revarg_opt & REVARG_COMMITTISH) get_sha1_flags |= GET_OID_COMMITTISH; + /* + * Even if revs->do_not_die_on_missing_objects is set, we + * should error out if we can't even get an oid, as + * `--missing=print` should be able to report missing oids. + */ if (get_oid_with_context(revs->repo, arg, get_sha1_flags, &oid, &oc)) return revs->ignore_missing ? 0 : -1; if (!cant_be_filename) verify_non_filename(revs->prefix, arg); object = get_reference(revs, arg, &oid, flags ^ local_flags); if (!object) - return revs->ignore_missing ? 0 : -1; + return (revs->ignore_missing || revs->do_not_die_on_missing_objects) ? 0 : -1; add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags); add_pending_object_with_path(revs, object, arg, oc.mode, oc.path); free(oc.path); @@ -3830,8 +3840,6 @@ int prepare_revision_walk(struct rev_info *revs) FOR_EACH_OBJECT_PROMISOR_ONLY); } - oidset_init(&revs->missing_commits, 0); - if (!revs->reflog_info) prepare_to_use_bloom_filter(revs); if (!revs->unsorted_input) diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 5f1be7abb5..78387eebb3 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -78,4 +78,60 @@ do done done +for missing_tip in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t" +do + # We want to check that things work when both + # - all the tips passed are missing (case existing_tip = ""), and + # - there is one missing tip and one existing tip (case existing_tip = "HEAD") + for existing_tip in "" "HEAD" + do + for action in "allow-any" "print" + do + test_expect_success "--missing=$action with tip '$missing_tip' missing and tip '$existing_tip'" ' + oid="$(git rev-parse $missing_tip)" && + path=".git/objects/$(test_oid_to_path $oid)" && + + # Before the object is made missing, we use rev-list to + # get the expected oids. + if test "$existing_tip" = "HEAD" + then + git rev-list --objects --no-object-names \ + HEAD ^$missing_tip >expect.raw + else + >expect.raw + fi && + + # Blobs are shared by all commits, so even though a commit/tree + # might be skipped, its blob must be accounted for. + if test "$existing_tip" = "HEAD" && test $missing_tip != "HEAD:1.t" + then + echo $(git rev-parse HEAD:1.t) >>expect.raw && + echo $(git rev-parse HEAD:2.t) >>expect.raw + fi && + + mv "$path" "$path.hidden" && + test_when_finished "mv $path.hidden $path" && + + git rev-list --missing=$action --objects --no-object-names \ + $oid $existing_tip >actual.raw && + + # When the action is to print, we should also add the missing + # oid to the expect list. + case $action in + allow-any) + ;; + print) + grep ?$oid actual.raw && + echo ?$oid >>expect.raw + ;; + esac && + + sort actual.raw >actual && + sort expect.raw >expect && + test_cmp expect actual + ' + done + done +done + test_done