summaryrefslogtreecommitdiff
path: root/t/t9148-git-svn-propset.sh
blob: 102639090c11f3548b1c2b1b391a04b8b0cf05ba (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
#!/bin/sh
#
# Copyright (c) 2014 Alfred Perlstein
#
 
test_description='git svn propset tests'
 
. ./lib-git-svn.sh
 
foo_subdir2="subdir/subdir2/foo_subdir2"
 
set -e
mkdir import &&
(set -e ; cd import
	mkdir subdir
	mkdir subdir/subdir2
	touch foo 		# for 'add props top level'
	touch subdir/foo_subdir # for 'add props relative'
	touch "$foo_subdir2"	# for 'add props subdir'
	svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null
)
rm -rf import
 
test_expect_success 'initialize git svn' '
	git svn init "$svnrepo"
	'
 
test_expect_success 'fetch revisions from svn' '
	git svn fetch
	'
 
set_props () {
	subdir="$1"
	file="$2"
	shift;shift;
	(cd "$subdir" &&
		while [ $# -gt 0 ] ; do
			git svn propset "$1" "$2" "$file" || exit 1
			shift;shift;
		done &&
		echo hello >> "$file" &&
		git commit -m "testing propset" "$file")
}
 
confirm_props () {
	subdir="$1"
	file="$2"
	shift;shift;
	(set -e ; cd "svn_project/$subdir" &&
		while [ $# -gt 0 ] ; do
			test "$(svn_cmd propget "$1" "$file")" = "$2" || exit 1
			shift;shift;
		done)
}
 
 
#The current implementation has a restriction:
#svn propset will be taken as a delta for svn dcommit only
#if the file content is also modified
test_expect_success 'add props top level' '
	set_props "." "foo" "svn:keywords" "FreeBSD=%H" &&
	git svn dcommit &&
	svn_cmd co "$svnrepo" svn_project &&
	confirm_props "." "foo" "svn:keywords" "FreeBSD=%H" &&
	rm -rf svn_project
	'
 
test_expect_success 'add multiple props' '
	set_props "." "foo" \
		"svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes &&
	git svn dcommit &&
	svn_cmd co "$svnrepo" svn_project &&
	confirm_props "." "foo" \
		"svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes &&
	rm -rf svn_project
	'
 
test_expect_success 'add props subdir' '
	set_props "." "$foo_subdir2" svn:keywords "FreeBSD=%H" &&
	git svn dcommit &&
	svn_cmd co "$svnrepo" svn_project &&
	confirm_props "." "$foo_subdir2" "svn:keywords" "FreeBSD=%H" &&
	rm -rf svn_project
	'
 
test_expect_success 'add props relative' '
	set_props "subdir/subdir2" "../foo_subdir" \
		svn:keywords "FreeBSD=%H" &&
	git svn dcommit &&
	svn_cmd co "$svnrepo" svn_project &&
	confirm_props "subdir/subdir2" "../foo_subdir" \
		svn:keywords "FreeBSD=%H" &&
	rm -rf svn_project
	'
test_done