From f9365c0a24b9d2346a9b2b5a24e1fa02039f23e5 Mon Sep 17 00:00:00 2001 From: Stephen Manz Date: Sun, 11 Jul 2021 00:27:18 +0000 Subject: [PATCH 1/3] t2400: clean up '"add" worktree with lock' test - remove unneeded `git rev-parse` which must have come from a copy-paste of another test - unlock the worktree with test_when_finished Signed-off-by: Stephen Manz Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t2400-worktree-add.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 96dfca1554..93d3795cab 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -67,8 +67,8 @@ test_expect_success '"add" worktree' ' ' test_expect_success '"add" worktree with lock' ' - git rev-parse HEAD >expect && git worktree add --detach --lock here-with-lock main && + test_when_finished "git worktree unlock here-with-lock || :" && test -f .git/worktrees/here-with-lock/locked ' From f7c35ea2a1292d581ca79d395fc978f92a3aec5b Mon Sep 17 00:00:00 2001 From: Stephen Manz Date: Sun, 11 Jul 2021 00:27:19 +0000 Subject: [PATCH 2/3] worktree: mark lock strings with `_()` for translation - default lock string, "added with --lock" - temporary lock string, "initializing" Signed-off-by: Stephen Manz Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 976bf8ed06..4829b9507f 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -303,9 +303,9 @@ static int add_worktree(const char *path, const char *refname, */ strbuf_addf(&sb, "%s/locked", sb_repo.buf); if (!opts->keep_locked) - write_file(sb.buf, "initializing"); + write_file(sb.buf, _("initializing")); else - write_file(sb.buf, "added with --lock"); + write_file(sb.buf, _("added with --lock")); strbuf_addf(&sb_git, "%s/.git", path); if (safe_create_leading_directories_const(sb_git.buf)) From 0db4961c49bb70cef89ed3d7c90f8f5d9dfc822d Mon Sep 17 00:00:00 2001 From: Stephen Manz Date: Thu, 15 Jul 2021 02:32:30 +0000 Subject: [PATCH 3/3] worktree: teach `add` to accept --reason with --lock The default reason stored in the lock file, "added with --lock", is unlikely to be what the user would have given in a separate `git worktree lock` command. Allowing `--reason` to be specified along with `--lock` when adding a working tree gives the user control over the reason for locking without needing a second command. Signed-off-by: Stephen Manz Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- Documentation/git-worktree.txt | 4 ++-- builtin/worktree.c | 21 ++++++++++++++++----- t/t2400-worktree-add.sh | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index f1bb1fa5f5..720663746b 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -9,7 +9,7 @@ git-worktree - Manage multiple working trees SYNOPSIS -------- [verse] -'git worktree add' [-f] [--detach] [--checkout] [--lock] [-b ] [] +'git worktree add' [-f] [--detach] [--checkout] [--lock [--reason ]] [-b ] [] 'git worktree list' [--porcelain] 'git worktree lock' [--reason ] 'git worktree move' @@ -242,7 +242,7 @@ With `list`, annotate missing working trees as prunable if they are older than `