summaryrefslogtreecommitdiff
path: root/t/t1407-worktree-ref-store.sh
blob: 5df06f355641ad7a38daf34f9fc841e7fe4f8a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh

test_description='test worktree ref store api'

. ./test-lib.sh

RWT="test-ref-store worktree:wt"
RMAIN="test-ref-store worktree:main"

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
'

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
'

test_done