Re: Ambiguous date handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Packham <judge.packham@xxxxxxxxx> 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.

Yuck.

> 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: "):

	#!/bin/sh
        case "$#" in
	0)
		cat
        	;;
	*)
        	for i
                do
                	case "$i" in
		        *.txt)
				sed -e 's/^\(Date: \)(\d+/)(\d+/)(\d+)/\1\3\2\4/' "$i"
				;;
			*)
                        	cat "$i"
				;;
			esac
		done
                ;;
	esac

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?

 git-am.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git i/git-am.sh w/git-am.sh
index c682d34..42654a0 100755
--- i/git-am.sh
+++ w/git-am.sh
@@ -265,7 +265,16 @@ split_patches () {
 		else
 		    keep_cr=
 		fi
-		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" ||
 		clean_abort
 		;;
 	stgit-series)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]