2 USAGE='--author <author> --patches </path/to/quilt/patch/directory>'
7 while case "$#" in 0) break;; esac
10 --au=*|--aut=*|--auth=*|--autho=*|--author=*)
11 quilt_author=$(expr "$1" : '-[^=]*\(.*\)')
15 --au|--aut|--auth|--autho|--author)
16 case "$#" in 1) usage ;; esac
22 --pa=*|--pat=*|--patc=*|--patch=*|--patche=*|--patches=*)
23 QUILT_PATCHES=$(expr "$1" : '-[^=]*\(.*\)')
27 --pa|--pat|--patc|--patch|--patche|--patches)
28 case "$#" in 1) usage ;; esac
41 if [ -n "$quilt_author" ] ; then
42 quilt_author_name=$(expr "z$quilt_author" : 'z\(.*[^ ]\) *<.*') &&
43 quilt_author_email=$(expr "z$quilt_author" : '.*<\([^>]*\)') &&
44 test '' != "$quilt_author_name" &&
45 test '' != "$quilt_author_email" ||
46 die "malformatted --author parameter"
49 # Quilt patch directory
50 : ${QUILT_PATCHES:=patches}
51 if ! [ -d "$QUILT_PATCHES" ] ; then
52 echo "The \"$QUILT_PATCHES\" directory does not exist."
56 # Temporay directories
58 tmp_msg="$tmp_dir/msg"
59 tmp_patch="$tmp_dir/patch"
60 tmp_info="$tmp_dir/info"
63 # Find the intial commit
64 commit=$(git-rev-parse HEAD)
66 mkdir $tmp_dir || exit 2
67 for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
69 (cat $QUILT_PATCHES/$patch_name | git-mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3
71 # Parse the author information
72 export GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' "$tmp_info")
73 export GIT_AUTHOR_EMAIL=$(sed -ne 's/Email: //p' "$tmp_info")
74 while test -z "$GIT_AUTHOR_EMAIL" && test -z "$GIT_AUTHOR_NAME" ; do
75 if [ -n "$quilt_author" ] ; then
76 GIT_AUTHOR_NAME="$quilt_author_name";
77 GIT_AUTHOR_EMAIL="$quilt_author_email";
79 echo "No author found in $patch_name";
87 patch_author_name=$(expr "z$patch_author" : 'z\(.*[^ ]\) *<.*') &&
88 patch_author_email=$(expr "z$patch_author" : '.*<\([^>]*\)') &&
89 test '' != "$patch_author_name" &&
90 test '' != "$patch_author_email" &&
91 GIT_AUTHOR_NAME="$patch_author_name" &&
92 GIT_AUTHOR_EMAIL="$patch_author_email"
95 export GIT_AUTHOR_DATE=$(sed -ne 's/Date: //p' "$tmp_info")
96 export SUBJECT=$(sed -ne 's/Subject: //p' "$tmp_info")
97 if [ -z "$SUBJECT" ] ; then
98 SUBJECT=$(echo $patch_name | sed -e 's/.patch$//')
101 git-apply --index -C1 "$tmp_patch" &&
102 tree=$(git-write-tree) &&
103 commit=$((echo "$SUBJECT"; echo; cat "$tmp_msg") | git-commit-tree $tree -p $commit) &&
104 git-update-ref HEAD $commit || exit 4
106 rm -rf $tmp_dir || exit 5