summaryrefslogtreecommitdiff
path: root/git-format-patch-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-07-22 23:04:34 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-22 23:29:28 (GMT)
commit44d2eb51b1c360c0337429f9a4a4f95d26d047eb (patch)
tree0fa4a95b0b9b0f02597e70cfcc0d61676bb55e8d /git-format-patch-script
parent3727531899aecac02c50c6580e84c627c25fcaa6 (diff)
downloadgit-44d2eb51b1c360c0337429f9a4a4f95d26d047eb.zip
git-44d2eb51b1c360c0337429f9a4a4f95d26d047eb.tar.gz
git-44d2eb51b1c360c0337429f9a4a4f95d26d047eb.tar.bz2
[PATCH] git-format-patch-script and mailinfo updates.
- avoid duplicating [PATCH] in the commit message body if the original commit has it already (happens for commits done from mails via applymbox). - check if the commit author is different from the one who is running the script, and emit an appropriate "From:" and "Date: " lines to the output. - with '--date', emit "Date: " line to preserve the original author date even for the user's own commit. - teach mailinfo to grok not just "From: " but "Date: ". The patch e-mail output by format-patch starts with the first line from the original commit message, prefixed with [PATCH], and optionally a From: line if you are reformatting a patch obtained from somebody else, a Date: line from the original commit if (1) --date is specified or (2) for somebody else's patch, and the rest of the commit message body. Expected use of this is to move the title line from the commit to Subject: when sending it via an e-mail, and leave the From: and the Date: lines as the first lines of your message. The mailinfo command has been changed to read Date: (in addition to From: it already understands) and do sensible things when running applymbox. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'git-format-patch-script')
-rwxr-xr-xgit-format-patch-script38
1 files changed, 31 insertions, 7 deletions
diff --git a/git-format-patch-script b/git-format-patch-script
index 9d26c9c..b775b9b 100755
--- a/git-format-patch-script
+++ b/git-format-patch-script
@@ -30,6 +30,8 @@ outdir=./
while case "$#" in 0) break;; esac
do
case "$1" in
+ -d|--d|--da|--dat|--date)
+ date=t ;;
-n|--n|--nu|--num|--numb|--numbe|--number|--numbere|--numbered)
numbered=t ;;
-o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\
@@ -56,6 +58,8 @@ esac
junio=`git-rev-parse --verify "$junio"`
linus=`git-rev-parse --verify "$linus"`
+me=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`
+
case "$outdir" in
*/) ;;
*) outdir="$outdir/" ;;
@@ -66,6 +70,7 @@ tmp=.tmp-series$$
trap 'rm -f $tmp-*' 0 1 2 3 15
series=$tmp-series
+commsg=$tmp-commsg
titleScript='
/./d
@@ -82,6 +87,12 @@ titleScript='
q
'
+whosepatchScript='
+/^author /{
+ s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p
+ q
+}'
+
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
stripCommitHead='/^'"$_x40"' (from '"$_x40"')$/d'
@@ -91,9 +102,8 @@ total=`wc -l <$series`
i=$total
while read commit
do
- title=`git-cat-file commit "$commit" |
- git-stripspace |
- sed -ne "$titleScript"`
+ git-cat-file commit "$commit" | git-stripspace >$commsg
+ title=`sed -ne "$titleScript" <$commsg`
case "$numbered" in
'') num= ;;
*)
@@ -102,6 +112,7 @@ do
*) num=' '`printf "%d/%d" $i $total` ;;
esac
esac
+
file=`printf '%04d-%stxt' $i "$title"`
i=`expr "$i" - 1`
echo "$file"
@@ -109,15 +120,28 @@ do
mailScript='
/./d
/^$/n
- s|^|[PATCH'"$num"'] |
+ s|^\[PATCH[^]]*\] *||
+ s|^|[PATCH'"$num"'] |'
+
+ eval "$(sed -ne "$whosepatchScript" $commsg)"
+ test "$au" = "$me" || {
+ mailScript="$mailScript"'
+ a\
+From: '"$au"
+ }
+ test "$date,$au" = ",$me" || {
+ mailScript="$mailScript"'
+ a\
+Date: '"$ad"
+ }
+
+ mailScript="$mailScript"'
: body
p
n
b body'
- git-cat-file commit "$commit" |
- git-stripspace |
- sed -ne "$mailScript"
+ sed -ne "$mailScript" <$commsg
echo '---'
echo
git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary