From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: "Pratyush Yadav" <me@yadavpratyush.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Eric Sunshine" <sunshine@sunshineco.com>
Subject: [PATCH 2/3] worktree: add -d short option for --detach
Date: Fri, 4 Sep 2020 03:07:02 -0400 [thread overview]
Message-ID: <20200904070703.47898-3-sunshine@sunshineco.com> (raw)
In-Reply-To: <20200904070703.47898-1-sunshine@sunshineco.com>
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.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
Documentation/git-worktree.txt | 1 +
builtin/worktree.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 6ee6ec7982..d252b6873b 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -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].
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 378f332b5d..1737165d2d 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -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")),
--
2.28.0.618.gf4bc123cb7
next prev parent reply other threads:[~2020-09-04 7:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 7:07 [PATCH 0/3] worktree: add -d shorthand for --detach & improve documentation Eric Sunshine
2020-09-04 7:07 ` [PATCH 1/3] git-checkout.txt: document -d short option for --detach Eric Sunshine
2020-09-04 7:07 ` Eric Sunshine [this message]
2020-09-04 7:07 ` [PATCH 3/3] git-worktree.txt: discuss branch-based vs. throwaway worktrees Eric Sunshine
2020-09-06 21:58 ` [PATCH 0/3] worktree: add -d shorthand for --detach & improve documentation Junio C Hamano
2020-09-07 0:02 ` [PATCH v2 0/3] worktree: teach `add` -d " Eric Sunshine
2020-09-07 0:02 ` [PATCH v2 1/3] git-checkout.txt: document -d short option for --detach Eric Sunshine
2020-09-07 0:02 ` [PATCH v2 2/3] worktree: teach `add` to recognize -d as shorthand " Eric Sunshine
2020-09-07 0:02 ` [PATCH v2 3/3] git-worktree.txt: discuss branch-based vs. throwaway worktrees 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=20200904070703.47898-3-sunshine@sunshineco.com \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@yadavpratyush.com \
--cc=szeder.dev@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).