Article View: linux.kernel.git
Article #1434Re: [PATCH] builtin/reflog: say "would prune" for named refs with --dry-run
From: Junio C Hamano
Date: Sun, 25 Oct 2026 18:07
Date: Sun, 25 Oct 2026 18:07
53 lines
14483 bytes
14483 bytes
Laveesh Bansal <laveeshb@laveeshbansal.com> writes:
> With --dry-run --verbose, "git reflog expire --all" reports the entries
> it would remove as "would prune", but when refs are named on the command
> line it reports them as "prune", which looks as if they were removed:
>
> $ git reflog expire --dry-run --verbose --expire=now HEAD
> prune commit (initial): first
>
> Nothing is removed in either case, only the label is wrong. This was
> reported at [1].
>
> fcd2c3d9d8 (reflog + refs-backend: move "verbose" out of the backend,
> 2021-12-22) added dry_run to struct expire_reflog_policy_cb and set it
> in the --all loop, but not in the loop for named refs. Set it there
> too.
> ...
> diff --git a/builtin/reflog.c b/builtin/reflog.c
> index 1211c58fa4..49e5453dd9 100644
> --- a/builtin/reflog.c
> +++ b/builtin/reflog.c
> @@ -279,7 +279,10 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
>
> for (i = 0; i < argc; i++) {
> char *ref;
> - struct expire_reflog_policy_cb cb = { .opts = opts };
> + struct expire_reflog_policy_cb cb = {
> + .opts = opts,
> + .dry_run = !!(flags & EXPIRE_REFLOGS_DRY_RUN),
> + };
This obviously mimics what happens in the "if (do_all)" side.
But I have to wonder why nobody finds it disgusting that what
happens inside the "for_each_string_list_item()" and the later "for
(i = 0; i < rgc; i++)" loop have striking similarity between them.
Would it make sense to retructure the code flow to
if (do_all) {
collect "all" to a strvec or string list
}
foreach arg in argv[]) {
add arg to the same strvec or string list
}
foreach ref in collected {
do the expiration of ref's reflog
}
That will help prevent a similar bug from ever happening again, as
there would be only a single place that sets up how the expiration
is called, instead of two we currently have.
Technical Details
Message-ID:
<xmqqqzhdy7pi.fsf@gitster.g>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73206-linux-kernel-git=dewy.ruReferences:
<20261024013850.66448-1-laveeshb@laveeshbansal.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73206-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] builtin/reflog: say "would prune" for named refs with
--dry-run
Date: Sun, 25 Oct 2026 11:07:53 -0700
Organization: Usenet Network
Message-ID: <xmqqqzhdy7pi.fsf@gitster.g>
References: <20261024013850.66448-1-laveeshb@laveeshbansal.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
logging-data="1083909"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:sXIs9jKcXhjQVpxL8UHPBBiKK4g= sha256:d3lYyyXPrh9mCk3xMILXfys7++w5MswATTFe6YzKuAY=
sha1:Q/DpR6LJzs4Bxa6EaTN34adiIDQ= sha256:tTnjnsg1KSzbuzqTsHJIgUmStkmAt1UoKCOtSwLsxps=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 7D587125B44; Sun, 25 Oct 2026 21:08:38 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.95
X-Spam-Status: No, score=-1.95 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=pobox.com header.b=gvd6hDp7; dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=uE6I4AbP
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id IItajgyWGEAB;
Sun, 25 Oct 2026 21:08:34 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-73206-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id AA4D8125B42; Sun, 25 Oct 2026 21:08:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 33C0E28510; Sun, 25 Oct 2026 18:07:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792951677;
b=3TKk86kxt5olqQhU3u7/3xXcns3uXQRdHYdOY5jtQToy9QAWgn/lmGALvRD1EFeMWBMO
US1KRhi4GUwf+sgvvVcP6GjdtzOg2iPDiB8zDxEg/SUC5Sgo1/0Fo2NIfAT48nzc/eHUe
MnIuesxTO0/c3Fso2MKy7tXtutHRf6MnpyYDyKDsDZGLbv6L9N3XWjc1X2CzKoFy5v6bT
NIlkmvdK4s/+TPSegtRjDAMdfpjtCpD+zjPUEqqsgPumDDU5wh9E97xIl9fbejR4YMGuS
IUy43SmE/K2KuUgGFII5BeAuiMrUOYShJ/3hDLmtcqfKm0PaiEGjOX9S25uLDfoVJvA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792951677;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:
Message-Instance:X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:
X-ME-Proxy:Feedback-ID:Received:From:To:Cc:Subject:In-Reply-To:
References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type;
bh=4SX9diARKtULdHLMABrD683/RlU8Fh0g828iOzOzlBI=;
b=IDRjYrVpV4rufaQwc1m/ZvfNeqSQKuGroMR4LZproj8yY9imw2eBUhBs6mFhMYRKYOv6
guiofs1dcbSpG59VZvHjgnpGgnSwJ7RP1bPv+1aQcgXNust1v8okJODizbOGN/prUB6HN
p5lOQTErC9AfzZCcueKTSWEFQ/uEDvPNyIyYoVPDI2kCBNZ+uqK5+k+BW0s8hyXt7EOop
ZBoBow6zpaOR9glLc/L5Xya9a3g4x62frvHM7O4NvlHByP9VHcPyXBLNM86dXQciCx1/P
0uaIo8PrWgJmQhF/6flqrQTGW5QDylemxWV6C10qzjFd3TYI0LqVcG8u/nEuOOscZ8Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=gvd6hDp7;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=uE6I4AbP;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id BD983606A322;
Sun, 25 Oct 2026 18:07:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=gvd6hDp7;
dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=uE6I4AbP
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.153
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792951676;
b=3g7joYJVC5dAJ366N06likuTQXg0E53OunC0mJJWVFZFR/ysx5fMo0dO/6WNGmA0JexI
DC+klxazRHJl7ek1SzFOnArFfrFdXBeLoKFYDdIihLLywAL12JuR/j470aGOXbY1V/47g
6c1RS54pOdSmAWDSpjn9HZeLBUB5bgPWXW7OHx/HUmztYnoeTCBiZvj4uaRKz0V1WpQqr
l6LjuTcK+vdDoWmQVdHwnj5dMj4+xK7GL7h2x2dLaGgYAsK/puu4thC9lT+v2n42ExxzV
KSHcN2EDFpA9MRIHS0ShIwMl50wejNhwfeIWnF2iK0WhL/WsdmOOy7qS8vkfijy/qYw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792951676;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:
X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance:
X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:
Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
User-Agent:MIME-Version:Content-Type;
bh=4SX9diARKtULdHLMABrD683/RlU8Fh0g828iOzOzlBI=;
b=UmWYA2I7xs2JLdM5fIHF7evltH1m3nV0MSks+QtoKL0gEZk2ccC9Qrf0A7qS1A1XQv6u
JG+haaxH7JEZFfYReHM5H1e3bYN32SVnb2tKuGCNUOq2ejLIaoDSgpebHHv+SZ5/xQp2N
2CsdBpmH26pFfVVK1KXpZ401So20dC+wiV1s4lD4DtiwUoeajcwughZxcIk3E0vExaYX6
LSN1Ni+0raEFhi1dRUnq1B3kS8DZT2CsbcrgBdRJcnjuiHXjl+kP6ggg7O6OUQbavBOvb
zH590DOzUId0MZiFphIwVqxNXb23pWwSzHJ8hDBx+qxypsnL/CdbQn2u+l3VVf6sxbw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=gvd6hDp7;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=uE6I4AbP;
arc=none smtp.remote-ip=103.168.172.153
X-Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id D56C7606A31A
for <git@vger.kernel.org>; Sun, 25 Oct 2026 18:07:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D56C7606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46])
by mailfhigh.phl.internal (Postfix) with ESMTP id 246D014000D4
for <git@vger.kernel.org>; Sun, 25 Oct 2026 14:07:55 -0400 (EDT)
X-Received: from phl-frontend-02 ([10.202.2.161])
by phl-compute-06.internal (MEProxy); Sun, 25 Oct 2026 14:07:55 -0400
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
:cc:content-type:content-type:date:date:from:from:in-reply-to
:in-reply-to:message-id:mime-version:references:reply-to:subject
:subject:to:to; s=fm1; t=1792951675; x=1793038075; bh=4SX9diARKt
ULdHLMABrD683/RlU8Fh0g828iOzOzlBI=; b=gvd6hDp7BmZYzNzvEmsMzW/Xr1
hisEn7iSafDa/3XVSnbHIoGJ4IjBXyQWHIsufPNAoD96mn2X6h20Tu7u9NPPTGXy
nlBm6hb59us8gUgRCE4OwWFxu83T719fZD2appx+ggUdmLEMDC9jTKJdUIwBSjdg
15rSxKO9R3dOFpVkf1KATXdUwmCpW7ZW02/bvvRkf7tqQFecFpwdB7I9ommv4eHE
cWQNXiUuwVZNSYPtA8fwXjM5CYkM3pMTxvaA0WLVsA3CQSRPnw5HvRUxeJ1biVDn
3YmHvHRaddUurDbTrcrL+iSMq69wyAPJ7wzcKPNR9wzGOHhxEi4KoP0DZCcQ==
X-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:subject:subject:to
:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=
1792951675; x=1793038075; bh=4SX9diARKtULdHLMABrD683/RlU8Fh0g828
iOzOzlBI=; b=uE6I4AbP5x7Y/L1m+huXsIgxqXkBVtB1cBO3LNlW5PwGp/CJz6x
iqNHt/6YaTvI/oqLdvpNEa2Y1ZFbu3rPH4BPtGi76mGPV8yv+gm9Sb7Lhy8Q5K2V
Xg6LXXDIgDQiPMkkLEOsZsYM8xe4BwHPaftiNyeoav44jXIvzfXqzJs+5Y61LsGv
OD/4wfAm4v7hU2CXBQf7WgY2U4TW8XXAqwJAmJBOeY4LWcGwx79eL351cMMtiRt9
xOnbnyxPcvGkItcan5Wj9JjyJ6PWKeKFV7b7p+udb5OGy+ZM9prfslTWw7PN4Ufb
u/iBlaP9hOMpYJh3T0WKYBCKUN2BpaXRY0g==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-07;
repo=github.com/dkim2wg/interop; date=2026-10-18; sw=lmtpprox;
action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1792951675; d=pobox.com;
mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
s=fm1:rsa-sha256:YpHXYfKlDzbdzMKjw7ebGPbOM9QJux7JwPkUARnl2ShmBex
FTzQTGW+nVQIaz8wipXRs6OPJZvUqhnMGePbrc/z2CyQjQk6hxQPcBraUC9UopDm
aGN6SyeSqi6ZH3qF1lLVyfAZP6r+sDeJ2A562UZLgo4GneHJ9FtPePRledb0VWMc
ZOgoIqrPfTXazI7MabDZ33GirNLsBkh19Omdi3Er6xJYzZ3wGv5edoLrhl+Xrm0K
Lx5ILDB7x4yn5QsEahG5zB9zsmu/q5qbMpQuJmD5vgBQvLteiHr2m3GYfDuYY5NE
7PTpIDxF/ZjJTT01C8V2mgm4jW97PgqlQcnV9Jw==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-07;
repo=github.com/dkim2wg/interop; date=2026-10-18; sw=lmtpprox;
action=mi-m=1; hc=12;
hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:3fSW0rmNHee6EndyH7lO/B4rQkWL54ADzbmTD7UVdAE=:Jl+SzmiOn8BI7o/jP49AekGh91iSWXWduAZZd6JLhus=;
X-ME-Sender: <xms:ekXeagg6dYde1YJpZs8_6qR693LE8GLDK993NaJMt0FmMW3Z73C3mA>
<xme:ekXeassm3mWXcDGrrtkBtRXa5uJ3zhUVyuWTMDC72Ezyg7iElzahQ2kFYEK8DOi4W
McfOHZQdKYF0T9TeosrKtFcIHJzHD0jo7U7JoRgXi6McpO7IBgSwlw>
X-ME-Received: <xmr:ekXeah5BWAxRaeFGZErmxBxLxoh9hkeRBGUwGOYf-4mOvrheXJGiPjx140hNoh3B9yLYypnKU-G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ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
25 Oct 2026 14:07:54 -0400 (EDT)
X-Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>, Karthik Nayak
<karthik.188@gmail.com>, Sven Weiland <sven.weiland@tngtech.com>
X-In-Reply-To: <20261024013850.66448-1-laveeshb@laveeshbansal.com> (Laveesh
Bansal's message of "Fri, 23 Oct 2026 18:38:50 -0700")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list