From: Patrick Steinhardt <ps@pks.im>
To: Laveesh Bansal <laveeshb@laveeshbansal.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Karthik Nayak <karthik.188@gmail.com>,
Sven Weiland <sven.weiland@tngtech.com>
Subject: Re: [PATCH] builtin/reflog: say "would prune" for named refs with --dry-run
Date: Thu, 29 Oct 2026 13:18:41 +0100 [thread overview]
Message-ID: <auM5oUilcWRuWhDA@pks.im> (raw)
In-Reply-To: <20261024013850.66448-1-laveeshb@laveeshbansal.com>
On Fri, Oct 23, 2026 at 06:38:50PM -0700, Laveesh Bansal wrote:
> 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.
Phew, kind of lucky that it's only the message and not us accidentally
pruning stuff.
> Add tests for named refs and --all. No test checked the keep/prune
> wording before.
Tiny nit, not worth a reroll: this paragraph doesn't really add a ton of
value, as it's self-evident from the patch.
> diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
> index 93b5b49e1d..998a7e8667 100755
> --- a/t/t1410-reflog.sh
> +++ b/t/t1410-reflog.sh
> @@ -240,6 +240,40 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' '
> check_fsck "missing blob $F"
> '
>
> +# A dry run only ever says "keep" or "would prune".
> +check_dry_run_output () {
> + test_grep "^would prune " "$1" &&
> + sed -e "/^keep /d" -e "/^would prune /d" \
> + -e "/^Marking reachable objects/d" "$1" >unexpected &&
> + test_must_be_empty unexpected
> +}
Okay, this is quite defensive in that it both checks that we print
"would prune" but none of the other lines. We could have made it even
more defensive by filtering out "would prune" lines and then testing
that the result is empty. But this here is certainly good enough, I'd
say.
So overall this looks good to me as-is, thanks!
Patrick
prev parent reply other threads:[~2026-10-29 12:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 1:38 [PATCH] builtin/reflog: say "would prune" for named refs with --dry-run Laveesh Bansal
2026-10-25 18:07 ` Junio C Hamano
2026-10-25 19:15 ` Laveesh Bansal
2026-10-26 1:16 ` Junio C Hamano
2026-10-29 12:18 ` Patrick Steinhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auM5oUilcWRuWhDA@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=laveeshb@laveeshbansal.com \
--cc=sven.weiland@tngtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.