]> git.ipfire.org Git - thirdparty/git.git/commitdiff
worktree: teach `add` to recognize -d as shorthand for --detach
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 7 Sep 2020 00:02:21 +0000 (20:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Sep 2020 01:53:56 +0000 (18:53 -0700)
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@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-worktree.txt
builtin/worktree.c

index 6ee6ec79824a6a8e43d2411b9226c72a49d52c9e..d252b6873b0a0dddc77a9b128928b48129e49f51 100644 (file)
@@ -143,6 +143,7 @@ To remove a locked working tree, specify `--force` twice.
        exists. `-B` overrides this safeguard, resetting `<new-branch>` to
        `<commit-ish>`.
 
+-d::
 --detach::
        With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD"
        in linkgit:git-checkout[1].
index 378f332b5d07edb55b48559ba328f980b84927e6..1737165d2dc0e7fa45771f765bf518a208b6fd21 100644 (file)
@@ -555,7 +555,7 @@ static int add(int ac, const char **av, const char *prefix)
                           N_("create a new branch")),
                OPT_STRING('B', NULL, &new_branch_force, N_("branch"),
                           N_("create or reset a branch")),
-               OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")),
+               OPT_BOOL('d', "detach", &opts.detach, N_("detach HEAD at named commit")),
                OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
                OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")),
                OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),