Thread (20 messages) 20 messages, 5 authors, 2025-03-19

Re: [PATCH v3 2/2] reflog: implement subcommand to drop reflogs

From: Christian Couder <hidden>
Date: 2025-03-18 14:01:31

On Fri, Mar 14, 2025 at 9:41 AM Karthik Nayak [off-list ref] wrote:
+Options for `drop`
+~~~~~~~~~~~~~~~~~~~~
+
+--all::
+       Drop the reflogs of all references from all worktrees.
+
+--single-worktree::
+       By default when `--all` is specified, reflogs from all working
+       trees are dropped. This option limits the processing to reflogs
+       from the current working tree only.
It seems to me that "--current-worktree" would have been clearer than
"--single-worktree", but I understand that it would have been
confusing to have a different name for basically the same option in
`git reflog expire` and `git reflog drop`.
+       argc = parse_options(argc, argv, prefix, options, reflog_drop_usage, 0);
+
+       if (argc && do_all)
+               usage(_("references specified along with --all"));
+
+       if (do_all) {
+               struct worktree_reflogs collected = {
+                       .reflogs = STRING_LIST_INIT_DUP,
+               };
+               struct string_list_item *item;
+               struct worktree **worktrees, **p;
+
+               worktrees = get_worktrees();
+               for (p = worktrees; *p; p++) {
+                       if (single_worktree && !(*p)->is_current)
It looks like 'single_worktree' is only used here. This means that if
a user forgets to add --all and only uses --single-worktree, nothing
will happen and it seems to me that the command will exit with code 0.
Even if `git reflog expire` already works like that, I think this is a
bit unfortunate.

Otherwise this patch series looks very well done to me.

Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help