[PATCH v2 0/3] worktree: teach `add` -d for --detach & improve documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a re-roll of [1] which brings `git worktree add` 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). It also 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 branches without realizing they are doing
so, and later wondering why `git branch --list` shows branches they did
not intentionally create.

v2 adjusts the commit message of [2/3] to make it clearer[2] that it
teaches `git worktree add` (not `git worktree`, in general) to
recognized -d as shorthand for --detach.

[1]: https://lore.kernel.org/git/20200904070703.47898-1-sunshine@xxxxxxxxxxxxxx/T/
[2]: https://lore.kernel.org/git/xmqqlfhm36v2.fsf@xxxxxxxxxxxxxxxxxxxxxx/

Eric Sunshine (3):
  git-checkout.txt: document -d short option for --detach
  worktree: teach `add` to recognize -d as shorthand 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(-)

Range-diff against v1:
1:  61ac1d5e14 ! 1:  538aaaf72d git-checkout.txt: document -d short option for --detach
    @@ Metadata
      ## Commit message ##
         git-checkout.txt: document -d short option for --detach
     
    -    git-checkout learned -d as short option for --detach in 163e3b2975
    +    `git checkout` learned -d as short option for --detach in 163e3b2975
         (switch: add short option for --detach, 2019-03-29) but the
         documentation was never updated to reflect the change.
     
2:  4f43ff6ddc ! 2:  49b3b3795d worktree: add -d short option for --detach
    @@ Metadata
     Author: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
     
      ## Commit message ##
    -    worktree: add -d short option for --detach
    +    worktree: teach `add` to recognize -d as shorthand for --detach
     
    -    Like git-switch and git-checkout, git-worktree can check out a branch or
    -    set up a detached HEAD. However, unlike git-switch and git-checkout,
    -    git-worktree does not understand -d as shorthand for --detach, which may
    -    confound users accustomed to using -d for this purpose. Address this
    -    shortcoming by adding -d as shorthand for --detach in order to bring
    -    git-worktree in line with the other commands.
    +    Like `git switch` and `git checkout`, `git worktree add` can check out a
    +    branch or set up a detached HEAD. However, unlike those other commands,
    +    `git worktree add` does not understand -d as shorthand for --detach,
    +    which may confound users accustomed to using -d for this purpose.
    +    Address this shortcoming by teaching `add` to recognize -d for --detach,
    +    thus bringing it in line with the other commands.
     
         Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
     
3:  628a7b7bb0 ! 3:  e5de1aaf18 git-worktree.txt: discuss branch-based vs. throwaway worktrees
    @@ Metadata
      ## Commit message ##
         git-worktree.txt: discuss branch-based vs. throwaway worktrees
     
    -    By default, "git worktree add" creates a new worktree associated with a
    +    By default, `git worktree add` creates a new worktree associated with a
         particular branch (which may have been created automatically if not
         specified explicitly on the command-line). It is also convenient to
         create throwaway worktrees not associated with any branch, which can be
    @@ Commit message
         and throwaway worktrees is to help newcomers understand that the
         simplest form `git worktree add <path>` automatically creates a new
         branch. Stating this early in the description, may help newcomers avoid
    -    creating unwanted new branches without being aware that they are doing
    -    so, and later wondering why `git branch --list` shows branches the user
    -    did not intentionally create.
    +    creating branches without realizing they are doing so, and later
    +    wondering why `git branch --list` shows branches the user did not
    +    intentionally create.
     
         Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
     
-- 
2.28.0.618.gf4bc123cb7




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux