commit: new command to permanently commit patches
[guilt.git] / guilt-repair
blob6b064c0c0191fb77770f7a78d81be55ba7e28105
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 refs/patches/$branch/$(head -1 < "$applied")^`
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 remove_patch_refs < "$applied"
50 printf "" > "$applied"
52 # update the top/bottom/base tags
53 update_stack_tags
55 echo "Done."