]> granicus.if.org Git - git/commitdiff
worktree: accept -f as short for --force for removal
authorStefan Beller <sbeller@google.com>
Tue, 17 Apr 2018 18:19:39 +0000 (11:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Apr 2018 00:19:05 +0000 (09:19 +0900)
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>
Documentation/git-worktree.txt
builtin/worktree.c

index e7eb24ab8528e39aa4e0a75f6feaa46d9cfb39fe..99b713c8490d2a4defaacf292ef8348a1e83af9d 100644 (file)
@@ -14,7 +14,7 @@ SYNOPSIS
 'git worktree lock' [--reason <string>] <worktree>
 'git worktree move' <worktree> <new-path>
 'git worktree prune' [-n] [-v] [--expire <expire>]
-'git worktree remove' [--force] <worktree>
+'git worktree remove' [-f] <worktree>
 'git worktree unlock' <worktree>
 
 DESCRIPTION
index 670555deddaca8ff8050c03ea68c83c7b4e459e6..dba460f8130c0d9835a32b5e259694e58b6f2df8 100644 (file)
@@ -790,8 +790,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
 {
        int force = 0;
        struct option options[] = {
-               OPT_BOOL(0, "force", &force,
-                        N_("force removing even if the worktree is dirty")),
+               OPT__FORCE(&force,
+                        N_("force removing even if the worktree is dirty"),
+                        PARSE_OPT_NOCOMPLETE),
                OPT_END()
        };
        struct worktree **worktrees, *wt;