3 ## applypatch takes four file arguments, and uses those to
4 ## apply the unpacked patch (surprise surprise) that they
5 ## represent to the current tree.
8 ## $1 - file with commit message
9 ## $2 - file with the actual patch
10 ## $3 - file with list of filenames the patch touches
11 ## $4 - "info" file with Author, email and subject
12 ## $5 - optional file containing signoff to add
15 final=.dotest/final-commit
17 ## If this file exists, we ask before applying
19 query_apply=.dotest/.query_apply
24 EDIT=${VISUAL:-$EDITOR}
27 export AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' .dotest/info)"
28 export AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' .dotest/info)"
29 export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)"
31 if [ -n "$signoff" -a -f "$signoff" ]; then
32 cat $signoff >> $MSGFILE
35 (echo "[PATCH] $SUBJECT" ; if [ -s $MSGFILE ]; then echo ; cat $MSGFILE; fi ) > $final
38 [ -f $query_apply ] || f=1
40 while [ $f -eq 0 ]; do
41 echo "Commit Body is:"
42 echo "--------------------------"
44 echo "--------------------------"
45 echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
49 n|N) exit 2;; # special value to tell dotest to keep going
51 a|A) rm -f $query_apply
57 echo Applying "'$SUBJECT'"
60 git-check-files $(cat $FILES) || exit 1
61 git-checkout-cache -q $(cat $FILES) || exit 1
62 patch -u --no-backup-if-mismatch -f -p1 --fuzz=0 --input=$PATCHFILE || exit 1
63 git-update-cache --add --remove $(cat $FILES) || exit 1
64 tree=$(git-write-tree) || exit 1
66 commit=$(git-commit-tree $tree -p $(cat .git/HEAD) < $final) || exit 1
67 echo Committed: $commit
68 echo $commit > .git/HEAD