-
Notifications
You must be signed in to change notification settings - Fork 2
/
commit
executable file
·68 lines (61 loc) · 1.28 KB
/
commit
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
#!/bin/sh
err()
{
echo "$(basename $0): $1" >&2
exit 1
}
usage()
{
echo "Usage: $(basename $0) [-n] <rev-list>"
}
set -e
if [ "$1" = "-n" ]; then
shift
dryrun=1
else
dryrun=0
fi
: ${SVN=/home/mark/media/src/freebsd-svn}
revs=$1
if git cat-file -e "${revs}"'^{commit}' >/dev/null 2>&1; then
commits=$(git rev-parse "${revs}")
else
commits=$(git rev-list $(git rev-parse "$1") | tail -r)
fi
for commit in ${commits}; do
msg=$(mktemp)
git log -n 1 --format=%B $commit > $msg
patch=$(mktemp)
git show $commit > $patch
pwd=$(pwd)
cd ${SVN}/head
test -z "$(svn status)" || err "unclean branch"
svn up
tmp=$(mktemp)
svn patch $patch > $tmp
if [ -n "$(awk '{if ($1 == "C") print $2}' $tmp)" ]; then
err "patch conflicts"
fi
for file in $(awk '{if ($1 == "A") print $2}' $tmp); do
if [ -f ${file} ]; then
svn propset svn:keywords "FreeBSD=%H" $file
fi
done
( cat ${msg}; svn diff ) | less
printf "\nIs this OK? [y/N] "
read resp
case $resp in
[Yy]*)
if [ $dryrun -eq 0 ]; then
svn commit --file $msg
fi
;;
*)
rm -f $msg $patch
cd $pwd
err "aborted"
;;
esac
rm -f $msg $patch
cd $pwd
done