diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-06-13 19:18:24 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-08 15:31:04 -0700 |
commit | 58142c09a4fe825912e5a2ebfa1ba5f7f6d8beb5 (patch) | |
tree | 14620fbf97f23e4dd31610b2e0776654fe35a4b4 /t | |
parent | worktree.c: add is_worktree_locked() (diff) | |
download | tgif-58142c09a4fe825912e5a2ebfa1ba5f7f6d8beb5.tar.xz |
worktree: add "lock" command
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t2028-worktree-move.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh new file mode 100755 index 0000000000..3a8512c030 --- /dev/null +++ b/t/t2028-worktree-move.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +test_description='test git worktree move, remove, lock and unlock' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit init && + git worktree add source && + git worktree list --porcelain | grep "^worktree" >actual && + cat <<-EOF >expected && + worktree $(pwd) + worktree $(pwd)/source + EOF + test_cmp expected actual +' + +test_expect_success 'lock main worktree' ' + test_must_fail git worktree lock . +' + +test_expect_success 'lock linked worktree' ' + git worktree lock --reason hahaha source && + echo hahaha >expected && + test_cmp expected .git/worktrees/source/locked +' + +test_expect_success 'lock linked worktree from another worktree' ' + rm .git/worktrees/source/locked && + git worktree add elsewhere && + git -C elsewhere worktree lock --reason hahaha ../source && + echo hahaha >expected && + test_cmp expected .git/worktrees/source/locked +' + +test_expect_success 'lock worktree twice' ' + test_must_fail git worktree lock source && + echo hahaha >expected && + test_cmp expected .git/worktrees/source/locked +' + +test_expect_success 'lock worktree twice (from the locked worktree)' ' + test_must_fail git -C source worktree lock . && + echo hahaha >expected && + test_cmp expected .git/worktrees/source/locked +' + +test_done |