Merge branch 'master' of s390x:bin/guilt
[guilt.git] / guilt-repair
blob62a0991cbbfb0db25a0fdb1799ae383b392382d9
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2008
6 USAGE="[-f]"
7 . `dirname $0`/guilt
9 safety_abort()
11 die "Please read the man page first. (you need to specify -f to force the repair)."
14 case $# in
16 safety_abort
19 [ "$1" != "-f" ] && safety_abort
22 usage
24 esac
26 oldrev=`git show-ref -s "refs/heads/$branch"`
27 echo "Current HEAD commit $oldrev"
29 if [ -s "$applied" ]; then
30 # there were some patches applied
31 newrev=`git rev-parse $(head -1 < "$applied" | cut -d: -f1)^`
32 else
33 # no patches were applied, but let's do all the work anyway
34 newrev="$oldrev"
37 echo "New HEAD commit $newrev"
39 echo -n "Are you sure you want to proceed? [y/N] "
40 read n
41 if [ "$n" != "y" ] && [ "$n" != "Y" ]; then
42 die "Aborting..."
45 # blow away any commits
46 git reset --hard "$newrev" > /dev/null
48 # blow away the applied stack
49 printf "" > "$applied"
51 # update the top/bottom/base tags
52 update_stack_tags
54 echo "Done."