* [PATCH] .gitignore git-describe @ 2006-01-08 14:15 Andreas Ericsson 2006-01-08 14:40 ` git-format-patch Date header Timo Hirvonen 0 siblings, 1 reply; 14+ messages in thread From: Andreas Ericsson @ 2006-01-08 14:15 UTC (permalink / raw) Signed-off-by: Andreas Ericsson <ae@op5.se> --- .gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) 265df952d4c61f60eae42261aeea90e9b6d8e414 diff --git a/.gitignore b/.gitignore index 1a9090b..4335061 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ git-count-objects git-cvsexportcommit git-cvsimport git-daemon +git-describe git-diff git-diff-files git-diff-index -- 1.0.7-gb38d1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* git-format-patch Date header 2006-01-08 14:15 [PATCH] .gitignore git-describe Andreas Ericsson @ 2006-01-08 14:40 ` Timo Hirvonen 2006-01-08 15:21 ` Andreas Ericsson 0 siblings, 1 reply; 14+ messages in thread From: Timo Hirvonen @ 2006-01-08 14:40 UTC (permalink / raw) To: git git-format-patch uses "date '+%s %z'" format for the Date header. Sylpheed does not understand this format. How common this convention is? Should we change git-format-patch to use more standard date format? OTOH, I like the %s format because it is so simple and easy to parse :) -- http://onion.dynserv.net/~timo/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 14:40 ` git-format-patch Date header Timo Hirvonen @ 2006-01-08 15:21 ` Andreas Ericsson 2006-01-08 15:37 ` Timo Hirvonen 2006-01-09 6:11 ` Linus Torvalds 0 siblings, 2 replies; 14+ messages in thread From: Andreas Ericsson @ 2006-01-08 15:21 UTC (permalink / raw) To: Timo Hirvonen; +Cc: git Timo Hirvonen wrote: > git-format-patch uses "date '+%s %z'" format for the Date header. > Sylpheed does not understand this format. How common this convention > is? Should we change git-format-patch to use more standard date format? > > OTOH, I like the %s format because it is so simple and easy to parse :) > Actually, that's what's printed in the commit message, so any change would have to be put there and that would break backwards compatibility for new tools that might want to use it. On an unrelated note, please don't start a new thread by replying to an old message. It's very confusing to follow and people may not see your message. This time it was doubly so because the next mail in my inbox is a patch for git-format-patch, to which I thought you replied. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 15:21 ` Andreas Ericsson @ 2006-01-08 15:37 ` Timo Hirvonen 2006-01-08 15:44 ` Andreas Ericsson 2006-01-09 6:11 ` Linus Torvalds 1 sibling, 1 reply; 14+ messages in thread From: Timo Hirvonen @ 2006-01-08 15:37 UTC (permalink / raw) To: Andreas Ericsson; +Cc: git On Sun, 08 Jan 2006 16:21:13 +0100 Andreas Ericsson <ae@op5.se> wrote: > Timo Hirvonen wrote: > > git-format-patch uses "date '+%s %z'" format for the Date header. > > Sylpheed does not understand this format. How common this convention > > is? Should we change git-format-patch to use more standard date format? > > > > OTOH, I like the %s format because it is so simple and easy to parse :) > > > > Actually, that's what's printed in the commit message, so any change > would have to be put there and that would break backwards compatibility > for new tools that might want to use it. So fixing Sylpheed (and maybe other email clients too) is the right solution... > On an unrelated note, please don't start a new thread by replying to an > old message. It's very confusing to follow and people may not see your > message. This time it was doubly so because the next mail in my inbox is > a patch for git-format-patch, to which I thought you replied. Sorry. I replied to your message because it was the message having Date header in the "%s %z" format. -- http://onion.dynserv.net/~timo/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 15:37 ` Timo Hirvonen @ 2006-01-08 15:44 ` Andreas Ericsson 2006-01-08 22:05 ` H. Peter Anvin 0 siblings, 1 reply; 14+ messages in thread From: Andreas Ericsson @ 2006-01-08 15:44 UTC (permalink / raw) To: Timo Hirvonen; +Cc: git Timo Hirvonen wrote: > On Sun, 08 Jan 2006 16:21:13 +0100 > Andreas Ericsson <ae@op5.se> wrote: > > >>Timo Hirvonen wrote: >> >>>git-format-patch uses "date '+%s %z'" format for the Date header. >>>Sylpheed does not understand this format. How common this convention >>>is? Should we change git-format-patch to use more standard date format? >>> >>>OTOH, I like the %s format because it is so simple and easy to parse :) >>> >> >>Actually, that's what's printed in the commit message, so any change >>would have to be put there and that would break backwards compatibility >>for new tools that might want to use it. > > > So fixing Sylpheed (and maybe other email clients too) is the right > solution... > Nopes. In this case fixing my home-hacked git-send-patch script is the right thing to do. git-format-patch has always printed that format, though, so the error lies with me and the patch I sent. I shall have to re-visit it after reading rfc 822 a bit more closely. > >>On an unrelated note, please don't start a new thread by replying to an >>old message. It's very confusing to follow and people may not see your >>message. This time it was doubly so because the next mail in my inbox is >>a patch for git-format-patch, to which I thought you replied. > > > Sorry. I replied to your message because it was the message having Date > header in the "%s %z" format. > I just noticed. Thanks, and sorry. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 15:44 ` Andreas Ericsson @ 2006-01-08 22:05 ` H. Peter Anvin 2006-01-08 23:30 ` Andreas Ericsson 0 siblings, 1 reply; 14+ messages in thread From: H. Peter Anvin @ 2006-01-08 22:05 UTC (permalink / raw) To: Andreas Ericsson; +Cc: Timo Hirvonen, git Andreas Ericsson wrote: > > Nopes. In this case fixing my home-hacked git-send-patch script is the > right thing to do. git-format-patch has always printed that format, > though, so the error lies with me and the patch I sent. I shall have to > re-visit it after reading rfc 822 a bit more closely. > RFC 2822, please. -hpa ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 22:05 ` H. Peter Anvin @ 2006-01-08 23:30 ` Andreas Ericsson 0 siblings, 0 replies; 14+ messages in thread From: Andreas Ericsson @ 2006-01-08 23:30 UTC (permalink / raw) To: git H. Peter Anvin wrote: > Andreas Ericsson wrote: > >> >> Nopes. In this case fixing my home-hacked git-send-patch script is the >> right thing to do. git-format-patch has always printed that format, >> though, so the error lies with me and the patch I sent. I shall have >> to re-visit it after reading rfc 822 a bit more closely. >> > > RFC 2822, please. > Right you are. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: git-format-patch Date header 2006-01-08 15:21 ` Andreas Ericsson 2006-01-08 15:37 ` Timo Hirvonen @ 2006-01-09 6:11 ` Linus Torvalds 2006-01-08 14:01 ` [PATCH] format-patch: Use --mbox by default Andreas Ericsson 1 sibling, 1 reply; 14+ messages in thread From: Linus Torvalds @ 2006-01-09 6:11 UTC (permalink / raw) To: Andreas Ericsson; +Cc: Timo Hirvonen, git On Sun, 8 Jan 2006, Andreas Ericsson wrote: > > Actually, that's what's printed in the commit message, so any change > would have to be put there and that would break backwards compatibility > for new tools that might want to use it. No, git should always take the date in any of a million different formats, and always turn it into "seconds + timezone" internally. The fact that git-format-patch also prints it out in the internal format is unambiguous (nice) but human-unreadable (bad). There are other unambiguous formats it could use, notably standard rfc2822 format ("date -R"). The git "show_date()" function hopefully does exactly that rfc2822 format, but you'd have to make a helper program to do the conversion in git-format-patch.sh. Linus ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] format-patch: Use --mbox by default. @ 2006-01-08 14:01 ` Andreas Ericsson 2006-01-08 20:28 ` Junio C Hamano ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Andreas Ericsson @ 2006-01-08 14:01 UTC (permalink / raw) This patch enables a slightly modified and more correct --mbox output by default. The --date, --author and --mbox options are obsoleted and removed. Previously, author-info and date was by default only printed if the commit was made by someone else, irrespective of the obsoleted options. Since it does no harm having ones own info there too it shouldn't really matter much, and should lessen the confusion regarding how to use git-format-patch with git-am. The patches generated also had bad mail headers for sendmail (of postfix 2.2.2 at least) to use directly (From: line must be on top, Subject: last of header), which isn't really an issue but annoying just the same. I haven't actually tried this new format, but at least 'file' now recognize it as "news or mail text", rather than "ASCII English text". Note that this reverts commit aa66c7ec77d474b737da607d6cb2d07f56628def, "format-patch/commit: Quote single quote in the author name properly" which is no longer needed since the whosepatchScript now prints the headers directly rather than passing them to eval. These changes allow us to remove two conditional statements and the invokation of a sub-shell in the process_one function, so it should be a bit faster too. Signed-off-by: Andreas Ericsson <ae@op5.se> --- Documentation/git-format-patch.txt | 18 ++----------- git-format-patch.sh | 49 +++++++----------------------------- 2 files changed, 12 insertions(+), 55 deletions(-) b38d1ffeb27ba32de849f33a9c416fda4cd8eecb diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 47705de..73e1358 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -9,7 +9,7 @@ git-format-patch - Prepare patches for e SYNOPSIS -------- [verse] -'git-format-patch' [-n | -k] [-o <dir> | --stdout] [-s] [-c] [--mbox] +'git-format-patch' [-n | -k] [-o <dir> | --stdout] [-s] [-c] [--diff-options] <his> [<mine>] DESCRIPTION @@ -27,9 +27,8 @@ When -n is specified, instead of "[PATCH line is formatted as "[PATCH N/M] Subject", unless you have only one patch. -When --mbox is specified, the output is formatted to resemble -UNIX mailbox format, and can be concatenated together for -processing with applymbox. +The output is formatted to resemble UNIX mailbox format, and can +be concatenated together for processing with gitlink::git-am[1]. OPTIONS @@ -45,11 +44,6 @@ OPTIONS Do not strip/add '[PATCH]' from the first line of the commit log message. --a|--author, -d|--date:: - Output From: and Date: headers for commits made by - yourself as well. Usually these are output only for - commits made by people other than yourself. - -s|--signoff:: Add `Signed-off-by:` line to the commit message, using the committer identity of yourself. @@ -61,12 +55,6 @@ OPTIONS has a SP character immediately followed by a TAB character. --m|--mbox:: - Format the output files for closer to mbox format by - adding a phony Unix "From " line, so they can be - concatenated together and fed to `git-applymbox`. - Implies --author and --date. - --stdout:: This flag generates the mbox formatted output to the standard output, instead of saving them into a file per diff --git a/git-format-patch.sh b/git-format-patch.sh index 818059f..047246e 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--mbox] [--diff-options] <upstream> [<our-head>]' +USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--diff-options] <upstream> [<our-head>]' LONG_USAGE='Prepare each commit with its patch since our-head forked from upstream, one file per patch, for e-mail submission. Each output file is numbered sequentially from 1, and uses the first line of the commit @@ -15,9 +15,8 @@ the current working directory. When -n is specified, instead of "[PATCH] Subject", the first line is formatted as "[PATCH N/M] Subject", unless you have only one patch. -When --mbox is specified, the output is formatted to resemble -UNIX mailbox format, and can be concatenated together for processing -with applymbox.' +The output is formatted to resemble UNIX mailbox format, and can be +concatenated together for processing with "git am".' . git-sh-setup # Force diff to run in C locale. @@ -32,14 +31,8 @@ outdir=./ while case "$#" in 0) break;; esac do case "$1" in - -a|--a|--au|--aut|--auth|--autho|--author) - author=t ;; -c|--c|--ch|--che|--chec|--check) check=t ;; - -d|--d|--da|--dat|--date) - date=t ;; - -m|--m|--mb|--mbo|--mbox) - date=t author=t mbox=t ;; -k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\ --keep-subj|--keep-subje|--keep-subjec|--keep-subject) keep_subject=t ;; @@ -48,7 +41,7 @@ do -s|--s|--si|--sig|--sign|--signo|--signof|--signoff) signoff=t ;; --st|--std|--stdo|--stdou|--stdout) - stdout=t mbox=t date=t author=t ;; + stdout=t ;; -o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\ --output-d=*|--output-di=*|--output-dir=*|--output-dire=*|\ --output-direc=*|--output-direct=*|--output-directo=*|\ @@ -173,12 +166,12 @@ titleScript=' whosepatchScript=' /^author /{ - s/'\''/'\''\\'\'\''/g - s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p + s/^author \([^>]*>\)[\t ]*\(.*\)$/From: \1\nDate: \2/p q }' process_one () { + sed -ne "$whosepatchScript" $commsg mailScript=' /./d /^$/n' @@ -191,26 +184,7 @@ process_one () { ;; esac mailScript="$mailScript"' - s|^|Subject: |' - case "$mbox" in - t) - echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line - ;; - esac - - eval "$(sed -ne "$whosepatchScript" $commsg)" - test "$author,$au" = ",$me" || { - mailScript="$mailScript"' - a\ -From: '"$au" - } - test "$date,$au" = ",$me" || { - mailScript="$mailScript"' - a\ -Date: '"$ad" - } - - mailScript="$mailScript"' + s|^|Subject: | a\ : body @@ -218,7 +192,7 @@ Date: '"$ad" n b body' - (cat $commsg ; echo; echo) | + (cat $commsg; echo; echo) | sed -ne "$mailScript" | git-stripspace @@ -239,12 +213,7 @@ Date: '"$ad" git-diff-tree -p $diff_opts "$commit" echo "-- " echo "@@GIT_VERSION@@" - - case "$mbox" in - t) - echo - ;; - esac + echo } total=`wc -l <$series | tr -dc "[0-9]"` -- 1.0.7-gb38d1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] format-patch: Use --mbox by default. 2006-01-08 14:01 ` [PATCH] format-patch: Use --mbox by default Andreas Ericsson @ 2006-01-08 20:28 ` Junio C Hamano 2006-01-09 2:01 ` Andreas Ericsson 2006-01-08 22:14 ` H. Peter Anvin 2006-01-13 23:56 ` [PATCH] format-patch: always --mbox and show sane Date: Junio C Hamano 2 siblings, 1 reply; 14+ messages in thread From: Junio C Hamano @ 2006-01-08 20:28 UTC (permalink / raw) To: Andreas Ericsson; +Cc: git Andreas Ericsson <ae@op5.se> writes: > This patch enables a slightly modified and more correct --mbox > output by default. The --date, --author and --mbox options > are obsoleted and removed. I always use format-patch with -k -m (or -k --stdout), so I have no objections to making --mbox the default. I do not think anybody uses --date or --author in their scripts, but removing the --mbox option _might_ break things for people's scripts. Maybe it is worthwhile to keep it as a no-op option for a while. > Previously, author-info and date was by default only printed if the > commit was made by someone else, irrespective of the obsoleted options. > Since it does no harm having ones own info there too it shouldn't really > matter much, and should lessen the confusion regarding how to use > git-format-patch with git-am. True. Originally it was really "format my changes to submission" tool (--signoff option is a sure sign to tell you that) and propagating authorship info was added as afterthought. > The patches generated also had bad mail headers for sendmail (of > postfix 2.2.2 at least) to use directly (From: line must be on top, > Subject: last of header),... I do not think RFC2822 specifies that. See "3.6 Field definitions", third paragraph, first two sentences. In that sense, technically they are not "bad mail headers", but at the same time, since it is valid in any order, if _one_ popular MTA is unconfortable with a particular ordering, we could order things differently to make it happier (mind you, this would not work for more than one such broken MTAs). Another thing I've been considering is to handle UTF-8 (or i18n.commitencoding in general) a bit better. We currently do not have Content-Type: header, so if you pipe the output to "am", it must be invoked without "-u" to make sure that it takes things as-is ("am -u" assumes things are in latin1 without Content-Type:). If we start to tackle that issue, we might also want to do RFC2047 in headers. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] format-patch: Use --mbox by default. 2006-01-08 20:28 ` Junio C Hamano @ 2006-01-09 2:01 ` Andreas Ericsson 0 siblings, 0 replies; 14+ messages in thread From: Andreas Ericsson @ 2006-01-09 2:01 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Junio C Hamano wrote: > Andreas Ericsson <ae@op5.se> writes: > > >>This patch enables a slightly modified and more correct --mbox >>output by default. The --date, --author and --mbox options >>are obsoleted and removed. > > > I always use format-patch with -k -m (or -k --stdout), so I have > no objections to making --mbox the default. I do not think > anybody uses --date or --author in their scripts, but removing > the --mbox option _might_ break things for people's scripts. > Maybe it is worthwhile to keep it as a no-op option for a while. > The reworked patch (which works for sending patches to myself, so far), prints a warning to stderr that a deprecated option is used and then silently ignores it. > >>The patches generated also had bad mail headers for sendmail (of >>postfix 2.2.2 at least) to use directly (From: line must be on top, >>Subject: last of header),... > > > I do not think RFC2822 specifies that. See "3.6 Field > definitions", third paragraph, first two sentences. > > In that sense, technically they are not "bad mail headers", but > at the same time, since it is valid in any order, if _one_ > popular MTA is unconfortable with a particular ordering, we > could order things differently to make it happier (mind you, > this would not work for more than one such broken MTAs). > The only thing I've seen break is if Subject: is placed on top. It's easier, script-wise, to put it last and that seems to work with qmail and postfix both. > Another thing I've been considering is to handle UTF-8 (or > i18n.commitencoding in general) a bit better. We currently do > not have Content-Type: header, so if you pipe the output to > "am", it must be invoked without "-u" to make sure that it takes > things as-is ("am -u" assumes things are in latin1 without > Content-Type:). If we start to tackle that issue, we might also > want to do RFC2047 in headers. > > You'll have to ask someone else for that. I have no idea how it works and I wouldn't know how to begin doing it in shell. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] format-patch: Use --mbox by default. 2006-01-08 14:01 ` [PATCH] format-patch: Use --mbox by default Andreas Ericsson 2006-01-08 20:28 ` Junio C Hamano @ 2006-01-08 22:14 ` H. Peter Anvin 2006-01-09 2:05 ` Andreas Ericsson 2006-01-13 23:56 ` [PATCH] format-patch: always --mbox and show sane Date: Junio C Hamano 2 siblings, 1 reply; 14+ messages in thread From: H. Peter Anvin @ 2006-01-08 22:14 UTC (permalink / raw) To: Andreas Ericsson; +Cc: Git Mailing List Andreas Ericsson wrote: > > The patches generated also had bad mail headers for sendmail (of > postfix 2.2.2 at least) to use directly (From: line must be on top, > Subject: last of header) Sounds like a bug report against postfix is in order. -hpa ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] format-patch: Use --mbox by default. 2006-01-08 22:14 ` H. Peter Anvin @ 2006-01-09 2:05 ` Andreas Ericsson 0 siblings, 0 replies; 14+ messages in thread From: Andreas Ericsson @ 2006-01-09 2:05 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Git Mailing List H. Peter Anvin wrote: > Andreas Ericsson wrote: > >> >> The patches generated also had bad mail headers for sendmail (of >> postfix 2.2.2 at least) to use directly (From: line must be on top, >> Subject: last of header) > > > Sounds like a bug report against postfix is in order. > No need. It works with 2.2.8. The 2.2.2 it failed with is the default for FC4. I have no interest investigating all the possibilities, and I doubt Vietse will look for bugs in old versions unless they're security related. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] format-patch: always --mbox and show sane Date: 2006-01-08 14:01 ` [PATCH] format-patch: Use --mbox by default Andreas Ericsson 2006-01-08 20:28 ` Junio C Hamano 2006-01-08 22:14 ` H. Peter Anvin @ 2006-01-13 23:56 ` Junio C Hamano 2 siblings, 0 replies; 14+ messages in thread From: Junio C Hamano @ 2006-01-13 23:56 UTC (permalink / raw) To: git; +Cc: Andreas Ericsson, Linus Torvalds Make --mbox, --author, and --date options a no-op, and always use --mbox output, and rewrite the commit log formatting in Perl. This makes it easier to output Date: header in RFC 2822 format, so do that as well. Inspiration for this patch came from Andreas Ericsson's earlier patch. Signed-off-by: Junio C Hamano <junkio@cox.net> --- * I admit that trying to avoid Perl and sticking to multiple sed invocations in this script was a lost battle. This patch is still minimalistic and it does not go all the way to rewrite the main loop of the program, which probably should happen someday. I would not mind if someday somebody rewrote most of the barebone Porcelainish in Python or Perl, but the rewrite should not be for the sake of using that language. It should have other justifications: "there is too much text processing there it would not make sense to do that in shell". I think this patch is borderline to qualify to be in that camp. As the version string at the end shows, this was prepared with the script source itself before building, as a test case. git-format-patch.sh | 143 +++++++++++++++++++++++++++------------------------ 1 files changed, 75 insertions(+), 68 deletions(-) 8b4271ef24818e6d52926bc615e5ce78ba0ed01b diff --git a/git-format-patch.sh b/git-format-patch.sh index d3979d7..7e67c4e 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -34,14 +34,12 @@ outdir=./ while case "$#" in 0) break;; esac do case "$1" in - -a|--a|--au|--aut|--auth|--autho|--author) - author=t ;; -c|--c|--ch|--che|--chec|--check) check=t ;; - -d|--d|--da|--dat|--date) - date=t ;; - -m|--m|--mb|--mbo|--mbox) - date=t author=t mbox=t ;; + -a|--a|--au|--aut|--auth|--autho|--author|\ + -d|--d|--da|--dat|--date|\ + -m|--m|--mb|--mbo|--mbox) # now noop + ;; -k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\ --keep-subj|--keep-subje|--keep-subjec|--keep-subject) keep_subject=t ;; @@ -173,80 +171,89 @@ titleScript=' q ' -whosepatchScript=' -/^author /{ - s/'\''/'\''\\'\'\''/g - s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p - q -}' - process_one () { - mailScript=' - /./d - /^$/n' - case "$keep_subject" in - t) ;; - *) - mailScript="$mailScript"' - s|^\[PATCH[^]]*\] *|| - s|^|[PATCH'"$num"'] |' - ;; - esac - mailScript="$mailScript"' - s|^|Subject: |' - case "$mbox" in - t) - echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line - ;; - esac + perl -w -e ' +my ($keep_subject, $num, $signoff, $commsg) = @ARGV; +my ($signoff_pattern, $done_header, $done_subject, $signoff_seen, + $last_was_signoff); + +if ($signoff) { + $signoff = `git-var GIT_COMMITTER_IDENT`; + $signoff =~ s/>.*/>/; + $signoff_pattern = quotemeta($signoff); +} - eval "$(sed -ne "$whosepatchScript" $commsg)" - test "$author,$au" = ",$me" || { - mailScript="$mailScript"' - a\ -From: '"$au" - } - test "$date,$au" = ",$me" || { - mailScript="$mailScript"' - a\ -Date: '"$ad" - } +my @weekday_names = qw(Sun Mon Tue Wed Thu Fri Sat); +my @month_names = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); - mailScript="$mailScript"' - a\ +sub show_date { + my ($time, $tz) = @_; + my $minutes = abs($tz); + $minutes = ($minutes / 100) * 60 + ($minutes % 100); + if ($tz < 0) { + $minutes = -$minutes; + } + my $t = $time + $minutes * 60; + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($t); + return sprintf("%s %s %d %02d:%02d:%02d %d %+05d", + $weekday_names[$wday], + $month_names[$mon], + $mday, $hour, $min, $sec, + $year+1900, $tz); +} - : body - p - n - b body' +print "From nobody Mon Sep 17 00:00:00 2001\n"; +open FH, "git stripspace <$commsg |" or die "open $commsg pipe"; +while (<FH>) { + unless ($done_header) { + if (/^$/) { + $done_header = 1; + } + elsif (/^author (.*>) (.*)$/) { + my ($author_ident, $author_date) = ($1, $2); + my ($utc, $off) = ($author_date =~ /^(\d+) ([-+]?\d+)$/); + $author_date = show_date($utc, $off); - (cat $commsg ; echo; echo) | - sed -ne "$mailScript" | - git-stripspace - - test "$signoff" = "t" && { - offsigner=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'` - line="Signed-off-by: $offsigner" - grep -q "^$line\$" $commsg || { - echo - echo "$line" - echo - } + print "From: $author_ident\n"; + print "Date: $author_date\n"; } - echo - echo '---' - echo + next; + } + unless ($done_subject) { + unless ($keep_subject) { + s/^\[PATCH[^]]*\]\s*//; + s/^/[PATCH$num] /; + } + print "Subject: $_"; + $done_subject = 1; + next; + } + + $last_was_signoff = 0; + if (/Signed-off-by:/i) { + if ($signoff ne "" && /Signed-off-by:\s*$signoff_pattern$/i) { + $signoff_seen = 1; + } + } + print $_; +} +if (!$signoff_seen && $signoff ne "") { + if (!$last_was_signoff) { + print "\n"; + } + print "$signoff\n"; +} +print "\n---\n\n"; +close FH or die "close $commsg pipe"; +' "$keep_subject" "$num" "$signoff" $commsg + git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary echo git-diff-tree -p $diff_opts "$commit" echo "-- " echo "@@GIT_VERSION@@" - case "$mbox" in - t) - echo - ;; - esac + echo } total=`wc -l <$series | tr -dc "[0-9]"` -- @@GIT_VERSION@@ ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-01-13 23:56 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-01-08 14:15 [PATCH] .gitignore git-describe Andreas Ericsson 2006-01-08 14:40 ` git-format-patch Date header Timo Hirvonen 2006-01-08 15:21 ` Andreas Ericsson 2006-01-08 15:37 ` Timo Hirvonen 2006-01-08 15:44 ` Andreas Ericsson 2006-01-08 22:05 ` H. Peter Anvin 2006-01-08 23:30 ` Andreas Ericsson 2006-01-09 6:11 ` Linus Torvalds 2006-01-08 14:01 ` [PATCH] format-patch: Use --mbox by default Andreas Ericsson 2006-01-08 20:28 ` Junio C Hamano 2006-01-09 2:01 ` Andreas Ericsson 2006-01-08 22:14 ` H. Peter Anvin 2006-01-09 2:05 ` Andreas Ericsson 2006-01-13 23:56 ` [PATCH] format-patch: always --mbox and show sane Date: Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).