Chris Packham <> writes:

> Consistent as long as you save as the default .txt. Some people have
> trained themselves to use the save as .eml option which uses RFC822
> style output.


> Could this be done in a applypatch-msg
> hook?

Isn't the hook about fixing up the log message?  Also I do not think
the name of the original file is given to the hook, so there is no
sufficient information to allow it to switch between two behaviours
based on .txt or .eml.

But if you are massaging the _input_ to "git am", then you can
certainly do the massaging even _before_ you feed it to "git am", no?

We could think about adding a new hook to "git am", though.  It
cannot just be an option to "git am" (or "git mailinfo") that says
"if the input is .txt, assume European date order for \d+/\d+/\d+
dates, and otherwise assume US style", as that is too specific to
your particular set-up and will not match general needs.  If we were
to add such a hook, $GIT_DIR/hooks/am-input-filter might look
something like this (it is left as an exercise to enhance it to
avoid munging a payload outside the header that happens to begin
with "Date: "):

        case "$#" in
                for i
                        case "$i" in
                                sed -e 's/^\(Date: 
\)(\d+/)(\d+/)(\d+)/\1\3\2\4/' "$i"
                                cat "$i"

and then teach "am" to use the hook, perhaps like the attached.

But at that point, wouldn't it be far simpler and cleaner if you did

        $ my-mbox-munge mail.txt | git am

in the first place? | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git i/ w/
index c682d34..42654a0 100755
--- i/
+++ w/
@@ -265,7 +265,16 @@ split_patches () {
-               git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > 
"$dotest/last" ||
+               if test -x "$GIT_DIR"/hooks/am-input-filter
+               then
+                       mif="$GIT_DIR"/hooks/am-input-filter
+               else
+                       mif=cat
+               fi
+               "$mif" "$@" |
+               git mailsplit -d"$prec" -o"$dotest" -b $keep_cr >"$dotest/last" 
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to