mbox series

[0/3] worktree: add -d shorthand for --detach & improve documentation

Message ID 20200904070703.47898-1-sunshine@sunshineco.com (mailing list archive)
Headers show
Series worktree: add -d shorthand for --detach & improve documentation | expand

Message

Eric Sunshine Sept. 4, 2020, 7:07 a.m. UTC
This series grew directly out of suggestions proposed in [1]. Its
purpose is twofold. First, it brings git-worktree in line with the other
"checkout a branch" commands git-switch and git-checkout by teaching it
-d as shorthand for --detach (which those other commands already
understand). Second, it enhances git-worktree documentation to emphasize
that `git worktree add <path>` creates a new branch by default, and to
discuss branch-based vs. throwaway worktrees, which may help newcomers
avoid creating unwanted new branches without realizing they are doing,
and later wondering why `git branch --list` shows branches they did not
intentionally create.

There was an earlier attempt[2] by Pratyush to add -d as shorthand for
--detach (though it did not enhance git-worktree documentation as the
current patch series does), however, that patch was never re-rolled
after reviewers pushed back on a few of the changes it made.

[1]: https://lore.kernel.org/git/CAPig+cQmqKiYWDWFH5eK2S6XPOi2t2+8Oas8yZa8R=bKLym3wQ@mail.gmail.com/
[2]: https://lore.kernel.org/git/20200125173744.4334-1-me@yadavpratyush.com/

Eric Sunshine (3):
  git-checkout.txt: document -d short option for --detach
  worktree: add -d short option for --detach
  git-worktree.txt: discuss branch-based vs. throwaway worktrees

 Documentation/git-checkout.txt |  1 +
 Documentation/git-worktree.txt | 13 +++++++++++++
 builtin/worktree.c             |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Sept. 6, 2020, 9:58 p.m. UTC | #1
Eric Sunshine <sunshine@sunshineco.com> writes:

> This series grew directly out of suggestions proposed in [1]. Its
> purpose is twofold. First, it brings git-worktree in line with the other
> "checkout a branch" commands git-switch and git-checkout by teaching it
> -d as shorthand for --detach (which those other commands already
> understand).

Hmph, "checkout" would not affect list of worktrees, but "worktree"
could be used to delete an worktree, so I (or any other naive user
like me) may mistake "-d" to mean "delete a worktree".

But it is not "teach 'worktree' that -d is shorthand for --detach";
it is "teach 'worktree add' that -d is for --detach".  And in that
context, when adding a new worktree, there is no room for such a
confusion to come into the picture.

So I think it is just the way the series is marketted that triggered
a potential negative reaction from me.

>   worktree: add -d short option for --detach