From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.146 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796126983; b=wbE5BvTttEYl9HG3xQJubRcSyf0b1mGwZNRC32pIb2h2foMkv3Ij6832yuBRWW3Hq/sT 280vinQRwMhyzERm2FcnodV/o6ZwKjFkLBoF8TCCeppnW6lcUDmL5+rw/SFOdrbUtqduv foye1Tlfsf7Lto1gPg7DInP8ba2tf5NNUgVTZ5DW+AK1pd33GRAvzirWi7/Ko+jIj1yZd q4EptGjX4MoRo7/+NK+pW5HKgAa+G/8hNNmWsBowmP90n3YqI6jYtd4PGZZqLIJdtyUWP GTwAJ0gXbkDXvlAIK9c5QqKjeNHZbscZN5HK4J8qI06gk7GbPkwGgpZhE0RMq0Ii0cw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126983; 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:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=qeyxsFdSOA5LaMP9auvKtdxouhdMcxOr02w3WuJ8qnw=; b=3B6O+CgfFAO+n3S5zfBK98AIij95ImfiGv1gSTtwjKdFk3hnpdOW3GhUCWKUgi9kgLrW VwWwXBXS1gSAkd1FjLL6u88T3QuQAK30jFIM0d6PhUy9TBpCaBQLgUKVUZfoA1TCqbLHo JLoJwvrVEtqVBeCLhGgwmpxrEaV1QsCP2IdG3JEQuDPlHE58tO2HYMlryAPJ/oNIu6LdG Fe56FuZhHpD4YIv97GIhYVNGwD3fQoRu/BUdvqicMQjUPcXiwPvNO69vEF9DmYbT2Ktca lMZdkMuZopia1t0Bwy91t2vQjcqcn7YTOL3aAJhwukfP6jpuj1X8/1H1T6sOcC/Y9Wg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=CB+CFiy9; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=rkdlcsQg; arc=none smtp.remote-ip=202.12.124.146 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 BDDD7606A31A for ; Tue, 1 Dec 2026 12:09:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BDDD7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=CB+CFiy9; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=rkdlcsQg Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id C3D441D00283 for ; Tue, 1 Dec 2026 07:09:41 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Tue, 01 Dec 2026 07:09:41 -0500 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:subject :subject:to:to; s=fm3; t=1796126981; x=1796213381; bh=qeyxsFdSOA 5LaMP9auvKtdxouhdMcxOr02w3WuJ8qnw=; b=CB+CFiy98wR/+ATExTJtyDbeS9 LTzR9Q4MDhyXGz6IhXCLDWVpIdjTt5xN4yFycA1XbBbIeXOwnq5NY6bk/TL5cy+r S+HiDjJN1i9FSZl+mJhqRXtgaW1vOooF26JtyprA+/JrGBt0UQtdpojJCAowCDtK nNMFAJg5+Ttw5JVusGbTVX+9O9HFeO47rMPPqPWZxxJbYY5qwfzxI43iXWpp/6YJ oxUEixErwxdJ53mJ1i9mYt7Vx+KIaRP2CHPxSieZMVpED37QnsD0/xzQrYlrAAEh O/mWInPNZgcRqwdAM6gKQOUmqHR/+LJATp+wi5P/fL/ew5MiIZVjuCdJFz/Q== 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=fm3; t= 1796126981; x=1796213381; bh=qeyxsFdSOA5LaMP9auvKtdxouhdMcxOr02w 3WuJ8qnw=; b=rkdlcsQgw6yp9P2on6iP6jtijh4U3S7XYzRD+Eb+1YcNRTD+vkW G797tBnMs+5QpyTYzT20LfoRYYG4arFpabnZg+r+UOqmC5sYUuyic9M5k+wIobFp ke2U71WnoHpH3Q/ctUW8XPEPtnAHLqjXvtJbjMTtph/ihoOTweFQr6lUViwlxLy+ XFeDQIzRVYNcW0XvjwwIG07NT4f+bdChCkaxe6KAlIBZb+Oh5aJ2q5x04VGM8+xJ umC7WaUh0FJ1z6MiWLE/nV/bvAS5ws5PXIFZoXcWqjpCE5JTT0cwkyPgVz6i5YqT wxkj7hnndMrHvMWctFmTErou2s9KP+b4N0w== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796126981; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:gpvUsVX2DSex1+hlTYtIYcqC2AO12ADzVnDPoX09iw+Crm4 RDL8GJQI5weayI7LLgRI39FfXLQPx3r4RkBkalNiCjFrt0999bgCU7+bpwSySJ47 UBwezXMfQGVK54eqPmiIHI56yxP3UoxX/BzxO5o5p0dPnC2SaFMbQdf6e93kqO0U KMZGxPdLdtJ1MjTZYcYDnUwAXVBnmV1Obn/XNFQp/SnJI0PLEjGZGr5T3VaCOkz+ UJ15zuUsFqjtjOrshS7HEEXqmNnZao/r5KgPR64FdEijpZGOmW+2KJQ33iLkU9Uv 5ulOtiphkXSTNc+5ivYP/Ryxh+a9LFlZ3fjgiNA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:5rhOixuh8HB8gzq7ovoXFvEOrkcQ4w3QuaJu++qFdk8=:JS34MIB/7Fjq8Vp+KUss6GG/wJhtHbbCte24t7OhXhY=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTG0NtARiYc+sfCcUSY5K9Ve/Hbkxa6rYCyrkFzhCLaKyo+UyeTukhLfvsU/onPoTU BpGmEPIQGe4JjpBOW4j2pOSrd38h3QIexe/T+hEAvGmgCVCBuJonG9wm/NDmCcnb7gGVqg rAGENKA0ZqYllDr0ic/MqzN/H7zPBm/kKYW4qFIJkhbjg6h3tB2BZI3J0tSZwNv51AlxjP VX09qYzAiqjQ+BxNrnar01545kgutzKfrHfpQgBK4mfrH/wk4QC79r5BNeKHPLnhkaZTBs KB393fyuQsuiMxLwpCOHTPakOwX6Mn629SOCkm0CXbGJU8fvF1rrZwVV84ny93leL+CaFu NcZJ9S0LXHUb7AT5SqMK9YqzMNLUIoDiuNkQ8MeGQcuhpreFNjrXC1PZWcNdBJncuWhdf8 zo8a7nSA4/sriTZGXZyZCZXJui1XFZblclWOXCGyakiQPAg9nmNWviEzr0h7OHlGqsGdYk 9aSsh/I8tgQ/VI5Ep/iUg2hdudPZqREilYgyyTWKSz4/jmx04QFqGCAQxoUla34BhbbGEa c+oP2BnJTdFuoxBSOuLUVBfamYbn8kPUNM+OZ5WTpiVAxOymFZ2+rD4z2C2msDswLDl+SL tjsLW8glC8wZdPKUre+edeYFyTi9PBEYC8LuHlSr1BHudc+mNOOeVsvy0byw X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 07:09:39 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id b041e70f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 12:09:37 +0000 (UTC) Date: Tue, 1 Dec 2026 13:09:34 +0100 From: Patrick Steinhardt To: Laveesh Bansal Cc: git@vger.kernel.org, Junio C Hamano , Karthik Nayak , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Subject: Re: [PATCH v3 2/2] builtin/reflog: expire each reflog only once Message-ID: References: <3ac3a8fbba527fefeb331ae0334c4106a9806b5b.1795290319.git.laveeshb@laveeshbansal.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ac3a8fbba527fefeb331ae0334c4106a9806b5b.1795290319.git.laveeshb@laveeshbansal.com> On Sat, Nov 21, 2026 at 11:53:17AM -0800, Laveesh Bansal wrote: > "git reflog expire" processes a reflog once for every time it is named, > and reports it every time: > > $ git reflog expire --dry-run --verbose --expire=now main main > would prune commit (initial): one > would prune commit (initial): one > > The same happens for two names of the same ref, such as "main" and > "refs/heads/main", and for a name that --all already covers. > > With --updateref, naming a ref twice can also lose entries. The first > pass can move the ref to the last entry it kept, and the second pass > then prunes entries that mention commits the new tip does not reach. > > Skip a reflog that this run has already processed. Add tests for the > repeated output and for --updateref. > > Signed-off-by: Laveesh Bansal > --- > > Notes: > I kept the order in which reflogs are expired. With --updateref, > expiring a branch can move it, and "HEAD" is checked against the tip of > every ref, so expiring "HEAD" before or after that branch can prune > different entries. Sorting the names would change that order, so I > used a strset instead. Makes sense, I guess. I wouldn't be surprised if there were users that intentionally or accidentally rely on this behaviour. > This does not catch names that reach a reflog through a worktree > prefix, such as "HEAD" and "main-worktree/HEAD", or names that do not > exist. Those are still processed or reported twice. That's fair -- the change is already an improvement, there's no need for the improvement to cover all known edge cases. > diff --git a/builtin/reflog.c b/builtin/reflog.c > index 42d37a3724..51a3d29505 100644 > --- a/builtin/reflog.c > +++ b/builtin/reflog.c > @@ -285,6 +287,11 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix, > if (ref) > refname = ref; > > + if (!strset_add(&seen, refname)) { > + free(ref); > + continue; > + } Makes sense. If we cannot add the refname because we've already added it then we know that we can skip it. I'd add a NEEDSWORK comment though that mentions that this doesn't work for per-worktree refs so that this limitation is documented. Patrick