summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3727531)
raw | patch | inline | side by side (parent: 3727531)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 22 Jul 2005 23:04:34 +0000 (16:04 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Fri, 22 Jul 2005 23:29:28 +0000 (16:29 -0700) |
- 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>
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>
git-format-patch-script | patch | blob | history | |
tools/mailinfo.c | patch | blob | history |
index 9d26c9c46a13115cfa26fe408b1a8892edad3df5..b775b9be683f1819818fa3dfb57392b70ae8574c 100755 (executable)
--- a/git-format-patch-script
+++ b/git-format-patch-script
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-=*|\
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/" ;;
trap 'rm -f $tmp-*' 0 1 2 3 15
series=$tmp-series
+commsg=$tmp-commsg
titleScript='
/./d
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'
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= ;;
*)
*) num=' '`printf "%d/%d" $i $total` ;;
esac
esac
+
file=`printf '%04d-%stxt' $i "$title"`
i=`expr "$i" - 1`
echo "$file"
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
diff --git a/tools/mailinfo.c b/tools/mailinfo.c
index ae279bffa5743aa0d58701f98eff17e25325fe0b..4dcc099195817e29c9ec6091f54d26184a44bcfd 100644 (file)
--- a/tools/mailinfo.c
+++ b/tools/mailinfo.c
static void handle_body(void)
{
int has_from = 0;
+ int has_date = 0;
- /* First line of body can be a From: */
+ /* First lines of body can have From: and Date: */
while (fgets(line, sizeof(line), stdin) != NULL) {
int len = eatspace(line);
if (!len)
continue;
}
}
+ if (!memcmp("Date:", line, 5) && isspace(line[5])) {
+ if (!has_date) {
+ handle_date(line+6);
+ has_date = 1;
+ continue;
+ }
+ }
line[len] = '\n';
handle_rest();
break;