git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karthik Nayak <karthik.188@gmail.com>
To: Toon Claes <toon@iotcl.com>, git@vger.kernel.org
Cc: ps@pks.im, kristofferhaugsbakk@fastmail.com, gitster@pobox.com
Subject: Re: [PATCH v3 2/2] reflog: implement subcommand to drop reflogs
Date: Wed, 19 Mar 2025 02:16:09 -0700	[thread overview]
Message-ID: <CAOLa=ZQ-ndKuYMABLveNjLnbR181+RD9_NGHAJsZbdc9eV2nEw@mail.gmail.com> (raw)
In-Reply-To: <8734fagwn2.fsf@iotcl.com>

[-- Attachment #1: Type: text/plain, Size: 4001 bytes --]

Toon Claes <toon@iotcl.com> writes:

> Karthik Nayak <karthik.188@gmail.com> writes:
>

[snip]

>> +static int cmd_reflog_drop(int argc, const char **argv, const char *prefix,
>> +			   struct repository *repo)
>> +{
>> +	int ret = 0, do_all = 0, single_worktree = 0;
>> +	const struct option options[] = {
>> +		OPT_BOOL(0, "all", &do_all, N_("drop the reflogs of all references")),
>> +		OPT_BOOL(0, "single-worktree", &single_worktree,
>> +			 N_("drop reflogs from the current worktree only")),
>> +		OPT_END()
>> +	};
>> +
>> +	argc = parse_options(argc, argv, prefix, options, reflog_drop_usage, 0);
>> +
>> +	if (argc && do_all)
>> +		usage(_("references specified along with --all"));
>
> What is the intended behavior when both `--all` and `<refs>` are
> omitted? It seems nothing happens at the moment. And no error nor
> warning is printed, that feels a bit odd to me.
>
> Now, when you do `git reflog expire --expire=all` it also seems to be
> doing nothing at all. I also think this is weird. And I don't see any
> test coverage for `git reflog expire` without `--all`.
>
> But what is the expected behavior when you omit `--all` and `<refs>`?
> Should it give an error or warning? Should it use HEAD, just like `git
> reflog show` does?
>

As discussed in the other thread [1], ideally this should be raised as
an error. I'm leaving it for now.

[snip]

>> +
>> +test_expect_success 'reflog drop --all' '
>> +	test_when_finished "rm -rf repo" &&
>> +	git init repo &&
>> +	(
>> +		cd repo &&
>> +		test_commit A &&
>> +		test_commit_bulk --ref=refs/heads/branch 1 &&
>> +		git reflog exists refs/heads/main &&
>> +		git reflog exists refs/heads/branch &&
>> +		git reflog drop --all &&
>> +		test_must_fail git reflog exists refs/heads/main &&
>> +		test_must_fail git reflog exists refs/heads/branch
>
> Should we test output of `git reflog list`?
>

I don't see why, we're concerned with individual reflogs and 'exists'
help check against those individual reflogs.

>> +	)
>> +'
>> +
>> +test_expect_success 'reflog drop --all multiple worktrees' '
>> +	test_when_finished "rm -rf repo" &&
>> +	test_when_finished "rm -rf wt" &&
>> +	git init repo &&
>> +	(
>> +		cd repo &&
>> +		test_commit A &&
>> +		git worktree add ../wt &&
>> +		test_commit_bulk -C ../wt --ref=refs/heads/branch 1 &&
>> +		git reflog exists refs/heads/main &&
>> +		git reflog exists refs/heads/branch &&
>> +		git reflog drop --all &&
>> +		test_must_fail git reflog exists refs/heads/main &&
>> +		test_must_fail git reflog exists refs/heads/branch
>
> Shall we test HEAD in both worktrees does not exists?
>

I think it would be a good addition, but I'm not sure if its worthy of a
re-roll.

>> +	)
>> +'
>> +
>> +test_expect_success 'reflog drop --all --single-worktree' '
>> +	test_when_finished "rm -rf repo" &&
>> +	test_when_finished "rm -rf wt" &&
>> +	git init repo &&
>> +	(
>> +		cd repo &&
>> +		test_commit A &&
>> +		git worktree add ../wt &&
>> +		test_commit -C ../wt foobar &&
>> +		git reflog exists refs/heads/main &&
>> +		git reflog exists refs/heads/wt &&
>> +		test-tool ref-store worktree:wt reflog-exists HEAD &&
>> +		git reflog drop --all --single-worktree &&
>> +		test_must_fail git reflog exists refs/heads/main &&
>> +		test_must_fail git reflog exists refs/heads/wt &&
>> +		test_must_fail test-tool ref-store worktree:main reflog-exists HEAD &&
>> +		test-tool ref-store worktree:wt reflog-exists HEAD
>
> Naive question: why is `test-tool ref-store` used and not
> `git -C ../wt reflog exist`?
>

That should work too :)

>> +	)
>> +'
>> +
>> +test_expect_success 'reflog drop --all with reference' '
>> +	test_when_finished "rm -rf repo" &&
>> +	git init repo &&
>> +	(
>> +		cd repo &&
>> +		test_commit A &&
>> +		test_must_fail git reflog drop --all refs/heads/main 2>stderr &&
>> +		test_grep "usage: references specified along with --all" stderr
>> +	)
>> +'
>> +
>>  test_done
>>
>> --
>> 2.48.1

[1]: CAOLa=ZSj11TSTs6CywSX1Q9AAfW28zssS2yrGf8PmBOgd06Etg@mail.gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]

      reply	other threads:[~2025-03-19  9:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 11:17 [PATCH 0/2] EDITME: cover title for 493-add-command-to-purge-reflog-entries Karthik Nayak
2025-03-07 11:17 ` [PATCH 1/2] reflog: drop usage of global variables Karthik Nayak
2025-03-07 21:19   ` Junio C Hamano
2025-03-10 11:41     ` Karthik Nayak
2025-03-10 15:24       ` Junio C Hamano
2025-03-13 13:30         ` Karthik Nayak
2025-03-07 11:17 ` [PATCH 2/2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-07 11:50   ` Patrick Steinhardt
2025-03-07 12:53     ` Karthik Nayak
2025-03-07 12:59       ` Patrick Steinhardt
2025-03-07 13:28         ` Karthik Nayak
2025-03-07 13:28         ` Karthik Nayak
2025-03-07 21:28     ` Junio C Hamano
2025-03-10 11:28       ` Karthik Nayak
2025-03-10  7:39 ` [PATCH 0/2] EDITME: cover title for 493-add-command-to-purge-reflog-entries Kristoffer Haugsbakk
2025-03-10 12:34   ` Karthik Nayak
2025-03-10 15:28   ` Junio C Hamano
2025-03-10 12:36 ` [PATCH v2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-12  7:15   ` Patrick Steinhardt
2025-03-13 14:24     ` Karthik Nayak
2025-03-13 14:45       ` Patrick Steinhardt
2025-03-14  8:40 ` [PATCH v3 0/2] " Karthik Nayak
2025-03-14  8:40   ` [PATCH v3 1/2] reflog: improve error for when reflog is not found Karthik Nayak
2025-03-14  8:40   ` [PATCH v3 2/2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-18 14:01     ` Christian Couder
2025-03-18 17:44       ` Junio C Hamano
2025-03-19  8:17         ` Christian Couder
2025-03-19  9:06           ` Karthik Nayak
2025-03-18 15:56     ` Toon Claes
2025-03-19  9:16       ` Karthik Nayak [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='CAOLa=ZQ-ndKuYMABLveNjLnbR181+RD9_NGHAJsZbdc9eV2nEw@mail.gmail.com' \
    --to=karthik.188@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=ps@pks.im \
    --cc=toon@iotcl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).