git-commit-vandalism/t/t2028-worktree-move.sh
Nguyễn Thái Ngọc Duy 58142c09a4 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>
2016-07-08 15:31:04 -07:00

49 lines
1.2 KiB
Bash
Executable File

#!/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