2017-04-24 13:01:23 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test worktree ref store api'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2018-03-24 10:44:52 +03:00
|
|
|
RWT="test-tool ref-store worktree:wt"
|
|
|
|
RMAIN="test-tool ref-store worktree:main"
|
2017-04-24 13:01:23 +03:00
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
test_commit first &&
|
|
|
|
git worktree add -b wt-master wt &&
|
|
|
|
(
|
|
|
|
cd wt &&
|
|
|
|
test_commit second
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'resolve_ref(<shared-ref>)' '
|
|
|
|
SHA1=`git rev-parse master` &&
|
|
|
|
echo "$SHA1 refs/heads/master 0x0" >expected &&
|
|
|
|
$RWT resolve-ref refs/heads/master 0 >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
$RMAIN resolve-ref refs/heads/master 0 >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'resolve_ref(<per-worktree-ref>)' '
|
|
|
|
SHA1=`git -C wt rev-parse HEAD` &&
|
|
|
|
echo "$SHA1 refs/heads/wt-master 0x1" >expected &&
|
|
|
|
$RWT resolve-ref HEAD 0 >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
|
|
|
|
SHA1=`git rev-parse HEAD` &&
|
|
|
|
echo "$SHA1 refs/heads/master 0x1" >expected &&
|
|
|
|
$RMAIN resolve-ref HEAD 0 >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2017-04-24 13:01:24 +03:00
|
|
|
test_expect_success 'create_symref(FOO, refs/heads/master)' '
|
|
|
|
$RWT create-symref FOO refs/heads/master nothing &&
|
|
|
|
echo refs/heads/master >expected &&
|
|
|
|
git -C wt symbolic-ref FOO >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
|
|
|
|
$RMAIN create-symref FOO refs/heads/wt-master nothing &&
|
|
|
|
echo refs/heads/wt-master >expected &&
|
|
|
|
git symbolic-ref FOO >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2017-08-23 15:37:00 +03:00
|
|
|
test_expect_success 'for_each_reflog()' '
|
2018-05-13 05:24:13 +03:00
|
|
|
echo $ZERO_OID > .git/logs/PSEUDO-MAIN &&
|
2017-08-23 15:37:00 +03:00
|
|
|
mkdir -p .git/logs/refs/bisect &&
|
2018-05-13 05:24:13 +03:00
|
|
|
echo $ZERO_OID > .git/logs/refs/bisect/random &&
|
2017-08-23 15:37:00 +03:00
|
|
|
|
2018-05-13 05:24:13 +03:00
|
|
|
echo $ZERO_OID > .git/worktrees/wt/logs/PSEUDO-WT &&
|
2017-08-23 15:37:00 +03:00
|
|
|
mkdir -p .git/worktrees/wt/logs/refs/bisect &&
|
2018-05-13 05:24:13 +03:00
|
|
|
echo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&
|
2017-08-23 15:37:00 +03:00
|
|
|
|
2018-09-13 08:17:41 +03:00
|
|
|
$RWT for-each-reflog | cut -d" " -f 2- | sort >actual &&
|
2017-08-23 15:37:00 +03:00
|
|
|
cat >expected <<-\EOF &&
|
|
|
|
HEAD 0x1
|
|
|
|
PSEUDO-WT 0x0
|
|
|
|
refs/bisect/wt-random 0x0
|
|
|
|
refs/heads/master 0x0
|
|
|
|
refs/heads/wt-master 0x0
|
|
|
|
EOF
|
|
|
|
test_cmp expected actual &&
|
|
|
|
|
2018-09-13 08:17:41 +03:00
|
|
|
$RMAIN for-each-reflog | cut -d" " -f 2- | sort >actual &&
|
2017-08-23 15:37:00 +03:00
|
|
|
cat >expected <<-\EOF &&
|
|
|
|
HEAD 0x1
|
|
|
|
PSEUDO-MAIN 0x0
|
|
|
|
refs/bisect/random 0x0
|
|
|
|
refs/heads/master 0x0
|
|
|
|
refs/heads/wt-master 0x0
|
|
|
|
EOF
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2017-04-24 13:01:23 +03:00
|
|
|
test_done
|