aboutsummaryrefslogtreecommitdiffstats
path: root/pre-applypatch
blob: 5d85ca0e59795c255567993a696b85351658579a (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
#!/bin/sh

. git-sh-setup

# Avoid duplicated test numbers --- checking 'seen' is enough
# as we will usually add, but never remove them.
added=$(
	git diff-index --cached --name-only --diff-filter=A HEAD -- t |
	sed -ne 's|t/\(t[0-9][0-9][0-9][0-9]\)-.*\.sh$|\1|p'
)
if test -n "$added"
then
	bad=
	exists=$(
		git ls-tree --name-only seen:t |
		sed -ne 's|^\(t[0-9][0-9][0-9][0-9]\)-.*\.sh$|\1|p' |
		tr "\012" " "
	)
	for a in $added
	do
		case " $exists " in
		*" $a "*)
			echo >&2 "Test number $a already taken"
			bad=1
			;;
		esac
	done
	if test -n "$bad"
	then
		: exit 1
	fi
fi