Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2018-08-29 00:20:24 +0300
committerJunio C Hamano <gitster@pobox.com>2018-08-30 19:28:02 +0300
commit68a6b3a1bd45eb1814a0c1cedfe347692c3f2ff7 (patch)
tree2179e2f878c546a9cbf6e803dd9d860dd0b08340 /builtin/worktree.c
parente19831c94f91fd410fe001c0372b9c88b40d335b (diff)
worktree: teach 'move' to override lock when --force given twice
For consistency with "add -f -f", which allows a missing but locked worktree path to be re-used, allow "move -f -f" to override a lock, as well, as a convenience. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/worktree.c')
-rw-r--r--builtin/worktree.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 3eb2f89b0f1..354a6c0eb59 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -740,13 +740,17 @@ static void validate_no_submodules(const struct worktree *wt)
static int move_worktree(int ac, const char **av, const char *prefix)
{
+ int force = 0;
struct option options[] = {
+ OPT__FORCE(&force,
+ N_("force move even if worktree is dirty or locked"),
+ PARSE_OPT_NOCOMPLETE),
OPT_END()
};
struct worktree **worktrees, *wt;
struct strbuf dst = STRBUF_INIT;
struct strbuf errmsg = STRBUF_INIT;
- const char *reason;
+ const char *reason = NULL;
char *path;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
@@ -777,12 +781,13 @@ static int move_worktree(int ac, const char **av, const char *prefix)
validate_no_submodules(wt);
- reason = is_worktree_locked(wt);
+ if (force < 2)
+ reason = is_worktree_locked(wt);
if (reason) {
if (*reason)
- die(_("cannot move a locked working tree, lock reason: %s"),
+ die(_("cannot move a locked working tree, lock reason: %s\nuse 'move -f -f' to override or unlock first"),
reason);
- die(_("cannot move a locked working tree"));
+ die(_("cannot move a locked working tree;\nuse 'move -f -f' to override or unlock first"));
}
if (validate_worktree(wt, &errmsg, 0))
die(_("validation failed, cannot move working tree: %s"),