diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 6ee6ec7982..ae432d39a8 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -15,6 +15,7 @@ SYNOPSIS 'git worktree move' 'git worktree prune' [-n] [-v] [--expire ] 'git worktree remove' [-f] +'git worktree repair' 'git worktree unlock' DESCRIPTION @@ -110,6 +111,11 @@ and no modification in tracked files) can be removed. Unclean working trees or ones with submodules can be removed with `--force`. The main working tree cannot be removed. +repair:: + +Repair working tree administrative files, if possible, if they have +become corrupted or outdated due to external factors. + unlock:: Unlock a working tree, allowing it to be pruned, moved or deleted. diff --git a/builtin/worktree.c b/builtin/worktree.c index 378f332b5d..88af412d4f 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -1030,6 +1030,19 @@ static int remove_worktree(int ac, const char **av, const char *prefix) return ret; } +static int repair(int ac, const char **av, const char *prefix) +{ + struct option options[] = { + OPT_END() + }; + int rc = 0; + + ac = parse_options(ac, av, prefix, options, worktree_usage, 0); + if (ac) + usage_with_options(worktree_usage, options); + return rc; +} + int cmd_worktree(int ac, const char **av, const char *prefix) { struct option options[] = { @@ -1056,5 +1069,7 @@ int cmd_worktree(int ac, const char **av, const char *prefix) return move_worktree(ac - 1, av + 1, prefix); if (!strcmp(av[1], "remove")) return remove_worktree(ac - 1, av + 1, prefix); + if (!strcmp(av[1], "repair")) + return repair(ac - 1, av + 1, prefix); usage_with_options(worktree_usage, options); } diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh new file mode 100755 index 0000000000..cc679e1a21 --- /dev/null +++ b/t/t2406-worktree-repair.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +test_description='test git worktree repair' + +. ./test-lib.sh + +test_expect_success setup ' + test_commit init +' + +test_done