summaryrefslogtreecommitdiff
path: root/t/t7419-submodule-set-branch.sh
blob: 3b925c302fc4e2194a2e0ad10c0b48823f2cf021 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#
# Copyright (c) 2019 Denton Liu
#
 
test_description='Test submodules set-branch subcommand
 
This test verifies that the set-branch subcommand of git-submodule is working
as expected.
'
 
TEST_NO_CREATE_REPO=1
. ./test-lib.sh
 
test_expect_success 'submodule config cache setup' '
	mkdir submodule &&
	(cd submodule &&
		git init &&
		echo a >a &&
		git add . &&
		git commit -ma &&
		git checkout -b topic &&
		echo b >a &&
		git add . &&
		git commit -mb
	) &&
	mkdir super &&
	(cd super &&
		git init &&
		git submodule add ../submodule &&
		git commit -m "add submodule"
	)
'
 
test_expect_success 'ensure submodule branch is unset' '
	(cd super &&
		! grep branch .gitmodules
	)
'
 
test_expect_success 'test submodule set-branch --branch' '
	(cd super &&
		git submodule set-branch --branch topic submodule &&
		grep "branch = topic" .gitmodules &&
		git submodule update --remote &&
		cat <<-\EOF >expect &&
		b
		EOF
		git -C submodule show -s --pretty=%s >actual &&
		test_cmp expect actual
	)
'
 
test_expect_success 'test submodule set-branch --default' '
	test_commit -C submodule c &&
	(cd super &&
		git submodule set-branch --default submodule &&
		! grep branch .gitmodules &&
		git submodule update --remote &&
		cat <<-\EOF >expect &&
		c
		EOF
		git -C submodule show -s --pretty=%s >actual &&
		test_cmp expect actual
	)
'
 
test_expect_success 'test submodule set-branch -b' '
	test_commit -C submodule b &&
	(cd super &&
		git submodule set-branch -b topic submodule &&
		grep "branch = topic" .gitmodules &&
		git submodule update --remote &&
		cat <<-\EOF >expect &&
		b
		EOF
		git -C submodule show -s --pretty=%s >actual &&
		test_cmp expect actual
	)
'
 
test_expect_success 'test submodule set-branch -d' '
	test_commit -C submodule d &&
	(cd super &&
		git submodule set-branch -d submodule &&
		! grep branch .gitmodules &&
		git submodule update --remote &&
		cat <<-\EOF >expect &&
		d
		EOF
		git -C submodule show -s --pretty=%s >actual &&
		test_cmp expect actual
	)
'
 
test_done