git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] worktree: teach `add` to accept --reason <string> with --lock

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 9, 2021, 06:11 UTC
Message-ID
<CAPig+cQbBPGN+Dcvmy+ZAZeKLpffRrN4-2PNjRHzDHj56axcJg@mail.gmail.com>
In-Reply-To
<xmqq7di3jkki.fsf@gitster.g>
On Tue, Jul 6, 2021 at 3:42 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> 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.

My one bit of pushback is that, although the meaning of `--reason` is plenty clear in the context of `git worktree lock`, it may become ambiguous in the context of `git worktree add` if worktrees ever grow additional attributes/features which are also accompanied by "reasons". That possibility suggests that this particular reason-giving option of `git worktree add` ought to be named `--lock-reason`, but `git worktree add --lock --lock-reason=<reason>` feels clunky and redundant, which is why I was wondering if `git worktree --lock[=<reason>]` would be a better (and more convenient) UI.

I'm questioning the UI choice now so we can avoid backpedalling later on, if it ever comes to that, but perhaps my concern is unfounded. (Indeed, I haven't been able to come up with cases which would make `--reason` ambiguous.)

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 27 in “worktree: teach `add` to accept --reason <string> with --lock”
  1. worktree: teach `add` to accept --reason <string> with --lockStephen Manz via GitGitGadget, Jul 6, 2021
  2. Eric SunshineJul 6, 2021
  3. Junio C HamanoJul 6, 2021
  4. Eric SunshineJul 9, 2021
  5. Junio C HamanoJul 9, 2021
  6. Eric SunshineJul 10, 2021
  7. 0/3 worktree: teach add to accept --reason with --lockStephen Manz via GitGitGadget, Jul 8, 2021
  8. 1/3 t2400: remove unneeded `git rev-parse` from '"add" worktree with lock' testStephen Manz via GitGitGadget, Jul 8, 2021
  9. 2/3 worktree: default lock string should be marked with `_()` for translationStephen Manz via GitGitGadget, Jul 8, 2021
  10. Eric SunshineJul 9, 2021
  11. Junio C HamanoJul 9, 2021
  12. 3/3 worktree: teach `add` to accept --reason <string> with --lockStephen Manz via GitGitGadget, Jul 8, 2021
  13. Eric SunshineJul 9, 2021
  14. Junio C HamanoJul 9, 2021
  15. Eric SunshineJul 10, 2021
  16. 0/3 worktree: teach add to accept --reason with --lockStephen Manz via GitGitGadget, Jul 11, 2021
  17. 2/3 worktree: mark lock strings with `_()` for translationStephen Manz via GitGitGadget, Jul 11, 2021
  18. 1/3 t2400: clean up '"add" worktree with lock' testStephen Manz via GitGitGadget, Jul 11, 2021
  19. 3/3 worktree: teach `add` to accept --reason <string> with --lockStephen Manz via GitGitGadget, Jul 11, 2021
  20. Eric SunshineJul 13, 2021
  21. Eric SunshineJul 13, 2021
  22. 0/3 worktree: teach add to accept --reason with --lockStephen Manz via GitGitGadget, Jul 15, 2021
  23. 1/3 t2400: clean up '"add" worktree with lock' testStephen Manz via GitGitGadget, Jul 15, 2021
  24. 2/3 worktree: mark lock strings with `_()` for translationStephen Manz via GitGitGadget, Jul 15, 2021
  25. 3/3 worktree: teach `add` to accept --reason <string> with --lockStephen Manz via GitGitGadget, Jul 15, 2021
  26. Eric SunshineJul 15, 2021
  27. Eric SunshineJul 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.