summaryrefslogtreecommitdiffstats
path: root/t/t9817-git-p4-exclude.sh
blob: ec3d937c6a73bb8d89de51839af4bba4c3a73910 (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
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh

test_description='git p4 tests for excluded paths during clone and sync'

. ./lib-git-p4.sh

test_expect_success 'start p4d' '
	start_p4d
'

# Create a repo with the structure:
#
#    //depot/wanted/foo
#    //depot/discard/foo
#
# Check that we can exclude a subdirectory with both
# clone and sync operations.

test_expect_success 'create exclude repo' '
	(
		cd "$cli" &&
		mkdir -p wanted discard &&
		echo wanted >wanted/foo &&
		echo discard >discard/foo &&
		echo discard_file >discard_file &&
		echo discard_file_not >discard_file_not &&
		p4 add wanted/foo discard/foo discard_file discard_file_not &&
		p4 submit -d "initial revision"
	)
'

test_expect_success 'check the repo was created correctly' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot/...@all &&
	(
		cd "$git" &&
		test_path_is_file wanted/foo &&
		test_path_is_file discard/foo &&
		test_path_is_file discard_file &&
		test_path_is_file discard_file_not
	)
'

test_expect_success 'clone, excluding part of repo' '
	test_when_finished cleanup_git &&
	git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
	(
		cd "$git" &&
		test_path_is_file wanted/foo &&
		test_path_is_missing discard/foo &&
		test_path_is_file discard_file &&
		test_path_is_file discard_file_not
	)
'

test_expect_success 'clone, excluding single file, no trailing /' '
	test_when_finished cleanup_git &&
	git p4 clone -//depot/discard_file --dest="$git" //depot/...@all &&
	(
		cd "$git" &&
		test_path_is_file wanted/foo &&
		test_path_is_file discard/foo &&
		test_path_is_missing discard_file &&
		test_path_is_file discard_file_not
	)
'

test_expect_success 'clone, then sync with exclude' '
	test_when_finished cleanup_git &&
	git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
	(
		cd "$cli" &&
		p4 edit wanted/foo discard/foo discard_file_not &&
		date >>wanted/foo &&
		date >>discard/foo &&
		date >>discard_file_not &&
		p4 submit -d "updating" &&

		cd "$git" &&
		git p4 sync -//depot/discard/... &&
		test_path_is_file wanted/foo &&
		test_path_is_missing discard/foo &&
		test_path_is_file discard_file &&
		test_path_is_file discard_file_not
	)
'

test_expect_success 'clone, then sync with exclude, no trailing /' '
	test_when_finished cleanup_git &&
	git p4 clone -//depot/discard/... -//depot/discard_file --dest="$git" //depot/...@all &&
	(
		cd "$cli" &&
		p4 edit wanted/foo discard/foo discard_file_not &&
		date >>wanted/foo &&
		date >>discard/foo &&
		date >>discard_file_not &&
		p4 submit -d "updating" &&

		cd "$git" &&
		git p4 sync -//depot/discard/... -//depot/discard_file &&
		test_path_is_file wanted/foo &&
		test_path_is_missing discard/foo &&
		test_path_is_missing discard_file &&
		test_path_is_file discard_file_not
	)
'

test_done