Skip to content

Commit d228eea

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit d228eea

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Documentation/git-worktree.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SYNOPSIS
1414
'git worktree lock' [--reason <string>] <worktree>
1515
'git worktree move' <worktree> <new-path>
1616
'git worktree prune' [-n] [-v] [--expire <expire>]
17-
'git worktree remove' [--force] <worktree>
17+
'git worktree remove' [-f] <worktree>
1818
'git worktree unlock' <worktree>
1919

2020
DESCRIPTION

builtin/worktree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
790790
{
791791
int force = 0;
792792
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),
795796
OPT_END()
796797
};
797798
struct worktree **worktrees, *wt;

0 commit comments

Comments
 (0)