You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.6 KiB
65 lines
1.6 KiB
20 years ago
|
#!/bin/sh
|
||
|
##
|
||
|
## applypatch takes four file arguments, and uses those to
|
||
|
## apply the unpacked patch (surprise surprise) that they
|
||
|
## represent to the current tree.
|
||
|
##
|
||
|
## The arguments are:
|
||
|
## $1 - file with commit message
|
||
|
## $2 - file with the actual patch
|
||
20 years ago
|
## $3 - "info" file with Author, email and subject
|
||
|
## $4 - optional file containing signoff to add
|
||
20 years ago
|
##
|
||
20 years ago
|
signoff="$4"
|
||
20 years ago
|
final=.dotest/final-commit
|
||
|
##
|
||
|
## If this file exists, we ask before applying
|
||
|
##
|
||
|
query_apply=.dotest/.query_apply
|
||
20 years ago
|
MSGFILE=$1
|
||
|
PATCHFILE=$2
|
||
20 years ago
|
INFO=$3
|
||
20 years ago
|
EDIT=${VISUAL:-$EDITOR}
|
||
|
EDIT=${EDIT:-vi}
|
||
|
|
||
20 years ago
|
export GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' .dotest/info)"
|
||
|
export GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' .dotest/info)"
|
||
|
export GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' .dotest/info)"
|
||
20 years ago
|
export SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' .dotest/info)"
|
||
|
|
||
20 years ago
|
if [ -n "$signoff" -a -f "$signoff" ]; then
|
||
|
cat $signoff >> $MSGFILE
|
||
|
fi
|
||
|
|
||
20 years ago
|
(echo "[PATCH] $SUBJECT" ; if [ -s $MSGFILE ]; then echo ; cat $MSGFILE; fi ) > $final
|
||
20 years ago
|
|
||
|
f=0
|
||
|
[ -f $query_apply ] || f=1
|
||
|
|
||
|
while [ $f -eq 0 ]; do
|
||
|
echo "Commit Body is:"
|
||
|
echo "--------------------------"
|
||
|
cat $final
|
||
|
echo "--------------------------"
|
||
|
echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
|
||
|
read reply
|
||
|
case $reply in
|
||
|
y|Y) f=1;;
|
||
|
n|N) exit 2;; # special value to tell dotest to keep going
|
||
|
e|E) $EDIT $final;;
|
||
|
a|A) rm -f $query_apply
|
||
|
f=1;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
20 years ago
|
echo
|
||
20 years ago
|
echo Applying "'$SUBJECT'"
|
||
20 years ago
|
echo
|
||
|
|
||
20 years ago
|
git-apply --index $PATCHFILE || exit 1
|
||
20 years ago
|
tree=$(git-write-tree) || exit 1
|
||
20 years ago
|
echo Wrote tree $tree
|
||
20 years ago
|
commit=$(git-commit-tree $tree -p $(cat .git/HEAD) < $final) || exit 1
|
||
20 years ago
|
echo Committed: $commit
|
||
|
echo $commit > .git/HEAD
|