summaryrefslogtreecommitdiff
path: root/make_patchnum.sh
blob: 9a2f946b18c042c8efa0e43b2445d9c8fe25bc43 (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
#!/bin/sh

. ./config.sh

Existing=`cat .patchnum 2>/dev/null`
Existing_Sha1=`cat .sha1 2>/dev/null`

if test -s ".patch" ; then
	Current=`awk '{print $4}' .patch`
	Sha1=`awk '{print $3}' .patch`
elif test -d ".git" ; then
	# we should do something better here
	Current=`git describe`
	Sha1=`git rev-parse HEAD`
	Changed=`git diff-index --name-only HEAD`
	test -n "$Changed"  && Current="$Current-with-uncommitted-changes"
fi

if test "$Existing" != "$Current" -o "$Existing_Sha1" != "$Sha1" ; then
	(echo "hi there\c" ; echo " ") >.echotmp
	if $contains c .echotmp >/dev/null 2>&1 ; then
		n='-n'
		c=''
	else
		n=''
		c='\c'
	fi
	rm -f .echotmp
	echo "Updating .patchnum and .sha1"
	echo $n "$Current$c" > .patchnum
	echo $n "$Sha1$c" > .sha1

else
	echo "Reusing .patchnum and .sha1" 
fi