All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Stephen Manz via GitGitGadget <gitgitgadget@gmail.com>,
	Git List <git@vger.kernel.org>, Stephen Manz <smanz@alum.mit.edu>
Subject: Re: [PATCH] worktree: teach `add` to accept --reason <string> with --lock
Date: Tue, 06 Jul 2021 12:42:21 -0700	[thread overview]
Message-ID: <xmqq7di3jkki.fsf@gitster.g> (raw)
In-Reply-To: <CAPig+cSsPrQrP9xk8M8H339_NpYqKh1okeo1V-fAJ2zk3QeOjQ@mail.gmail.com> (Eric Sunshine's message of "Tue, 6 Jul 2021 02:19:43 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

>>  --reason <string>::
>> +       With `lock` or with `add --lock`, an explanation why the working tree is locked.
>
> I realize that you're mimicking the interface of `git worktree lock`
> which accepts an optional `--reason`, but I'm wondering if the
> user-experience might be improved by instead allowing `--lock` to
> accept the reason as an optional argument. For instance:
>
>     git worktree add --lock='just because' ...

Thanks for thinking aloud, but I'd prefer the interface as posted,
simply because there is one less thing for users to remember.  The
justification to lock is given with the --reason=<why> argument no
matter how you acquire the lock on a worktree.


>> diff --git a/builtin/worktree.c b/builtin/worktree.c
>> @@ -31,6 +31,7 @@ struct add_opts {
>>         int checkout;
>>         int keep_locked;
>> +       const char *lock_reason;
>>  };
>
> Whether or not we do go with the approach of allowing `--lock` to take
> the reason as an optional argument, we don't really need two structure
> members here. Instead, we can repurpose `keep_locked` as a `const char
> *` which is NULL if `--lock` was not specified, otherwise non-NULL.

Makes sense.

> However, in this case, it should probably just be a simple `else if`:
>
>     if (!opts->keep_locked)
>         write_file(sb.buf, "initializing");
>     else if (opts->lock_reason)
>         write_file(sb.buf, "%s", opts->lock_reason);
>     else
>         write_file(sb.buf, _("added with --lock"));

Excellent.

Thanks.

  reply	other threads:[~2021-07-06 19:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06  5:47 [PATCH] worktree: teach `add` to accept --reason <string> with --lock Stephen Manz via GitGitGadget
2021-07-06  6:19 ` Eric Sunshine
2021-07-06 19:42   ` Junio C Hamano [this message]
2021-07-09  6:11     ` Eric Sunshine
2021-07-09 15:23       ` Junio C Hamano
2021-07-10  7:11         ` Eric Sunshine
2021-07-08 15:50 ` [PATCH v2 0/3] worktree: teach add to accept --reason " Stephen Manz via GitGitGadget
2021-07-08 15:50   ` [PATCH v2 1/3] t2400: remove unneeded `git rev-parse` from '"add" worktree with lock' test Stephen Manz via GitGitGadget
2021-07-08 15:50   ` [PATCH v2 2/3] worktree: default lock string should be marked with `_()` for translation Stephen Manz via GitGitGadget
2021-07-09  6:19     ` Eric Sunshine
2021-07-09 15:58       ` Junio C Hamano
2021-07-08 15:50   ` [PATCH v2 3/3] worktree: teach `add` to accept --reason <string> with --lock Stephen Manz via GitGitGadget
2021-07-09  7:45   ` [PATCH v2 0/3] worktree: teach add to accept --reason " Eric Sunshine
2021-07-09 16:03     ` Junio C Hamano
2021-07-10  7:15       ` Eric Sunshine
2021-07-11  0:27   ` [PATCH v3 " Stephen Manz via GitGitGadget
2021-07-11  0:27     ` [PATCH v3 1/3] t2400: clean up '"add" worktree with lock' test Stephen Manz via GitGitGadget
2021-07-11  0:27     ` [PATCH v3 2/3] worktree: mark lock strings with `_()` for translation Stephen Manz via GitGitGadget
2021-07-11  0:27     ` [PATCH v3 3/3] worktree: teach `add` to accept --reason <string> with --lock Stephen Manz via GitGitGadget
2021-07-13  3:37       ` Eric Sunshine
2021-07-13  3:47     ` [PATCH v3 0/3] worktree: teach add to accept --reason " Eric Sunshine
2021-07-15  2:32     ` [PATCH v4 " Stephen Manz via GitGitGadget
2021-07-15  2:32       ` [PATCH v4 1/3] t2400: clean up '"add" worktree with lock' test Stephen Manz via GitGitGadget
2021-07-15  2:32       ` [PATCH v4 2/3] worktree: mark lock strings with `_()` for translation Stephen Manz via GitGitGadget
2021-07-15  2:32       ` [PATCH v4 3/3] worktree: teach `add` to accept --reason <string> with --lock Stephen Manz via GitGitGadget
2021-07-15 17:17       ` [PATCH v4 0/3] worktree: teach add to accept --reason " Eric Sunshine
2021-07-17  0:14         ` Eric Sunshine

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=xmqq7di3jkki.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=smanz@alum.mit.edu \
    --cc=sunshine@sunshineco.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.