worktree: accept -f as short for --force for removal

Many commands support a "--force" option, frequently abbreviated as "-f", however, "git worktree remove"'s hand-rolled OPT_BOOL forgets to recognize the short form, despite git-worktree.txt documenting "-f" as supported. Replace OPT_BOOL with OPT__FORCE, which provides "-f" for free, and makes 'remove' consistent with 'add' option parsing (which also specifies the PARSE_OPT_NOCOMPLETE flag). Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Apr 17, 2018 at 11:19 UTC d228eea5146540b09376f90e2b805553cdc78590
2 files changed +4 -3
Documentation/git-worktree.txt
+1 -1
@@ -14,7 +14,7 @@ SYNOPSIS
14 'git worktree lock' [--reason <string>] <worktree>
15 'git worktree move' <worktree> <new-path>
16 'git worktree prune' [-n] [-v] [--expire <expire>]
17 -'git worktree remove' [--force] <worktree>
17 +'git worktree remove' [-f] <worktree>
18 'git worktree unlock' <worktree>
19
20 DESCRIPTION
builtin/worktree.c
+3 -2
@@ -790,8 +790,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
790 {
791 int force = 0;
792 struct option options[] = {
793 - OPT_BOOL(0, "force", &force,
794 - N_("force removing even if the worktree is dirty")),
793 + OPT__FORCE(&force,
794 + N_("force removing even if the worktree is dirty"),
795 + PARSE_OPT_NOCOMPLETE),
796 OPT_END()
797 };
798 struct worktree **worktrees, *wt;