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 - "info" file with Author, email and subject
11 ## $4 - optional file containing signoff to add
14 final
=.dotest
/final-commit
16 ## If this file exists, we ask before applying
18 query_apply
=.dotest
/.query_apply
22 EDIT
=${VISUAL:-$EDITOR}
25 export GIT_AUTHOR_NAME
="$(sed -n '/^Author/ s/Author: //p' .dotest/info)"
26 export GIT_AUTHOR_EMAIL
="$(sed -n '/^Email/ s/Email: //p' .dotest/info)"
27 export GIT_AUTHOR_DATE
="$(sed -n '/^Date/ s/Date: //p' .dotest/info)"
28 export SUBJECT
="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)"
30 if [ -n "$signoff" -a -f "$signoff" ]; then
31 cat $signoff >> $MSGFILE
34 (echo "[PATCH] $SUBJECT" ; if [ -s $MSGFILE ]; then echo ; cat $MSGFILE; fi ) > $final
37 [ -f $query_apply ] || f
=1
39 while [ $f -eq 0 ]; do
40 echo "Commit Body is:"
41 echo "--------------------------"
43 echo "--------------------------"
44 echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
48 n|N
) exit 2;; # special value to tell dotest to keep going
50 a|A
) rm -f $query_apply
56 echo Applying
"'$SUBJECT'"
59 git-apply
--index $PATCHFILE ||
exit 1
60 tree
=$
(git-write-tree
) ||
exit 1
62 commit
=$
(git-commit-tree
$tree -p $
(cat .git
/HEAD
) < $final) ||
exit 1
63 echo Committed
: $commit
64 echo $commit > .git
/HEAD