diff options
author | Stephen Manz <smanz@alum.mit.edu> | 2021-07-15 04:32:30 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-07-15 22:30:59 +0200 |
commit | 0db4961c49bb70cef89ed3d7c90f8f5d9dfc822d (patch) | |
tree | f10f2d05c39256c27539c57ecea1be698152b872 /t/t2400-worktree-add.sh | |
parent | worktree: mark lock strings with `_()` for translation (diff) | |
download | git-0db4961c49bb70cef89ed3d7c90f8f5d9dfc822d.tar.xz git-0db4961c49bb70cef89ed3d7c90f8f5d9dfc822d.zip |
worktree: teach `add` to accept --reason <string> 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 <smanz@alum.mit.edu>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2400-worktree-add.sh')
-rwxr-xr-x | t/t2400-worktree-add.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 93d3795cab..37ad79470f 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -72,6 +72,20 @@ test_expect_success '"add" worktree with lock' ' test -f .git/worktrees/here-with-lock/locked ' +test_expect_success '"add" worktree with lock and reason' ' + lock_reason="why not" && + git worktree add --detach --lock --reason "$lock_reason" here-with-lock-reason main && + test_when_finished "git worktree unlock here-with-lock-reason || :" && + test -f .git/worktrees/here-with-lock-reason/locked && + echo "$lock_reason" >expect && + test_cmp expect .git/worktrees/here-with-lock-reason/locked +' + +test_expect_success '"add" worktree with reason but no lock' ' + test_must_fail git worktree add --detach --reason "why not" here-with-reason-only main && + test_path_is_missing .git/worktrees/here-with-reason-only/locked +' + test_expect_success '"add" worktree from a subdir' ' ( mkdir sub && |