threads / discuss / 6926

strange date generated by git-format-patch

Subject: strange date generated by git-format-patch

## tl;dr

7 messages between Feb 23, 2007 and Feb 24, 2007.

replies: 6people: 5as markdown or json

johan defries· Feb 23, 2007, 08:55 UTC · lore
When I do

#git-format-patch --stdout HEAD^|head -1 | grep --color "Mon Sep 17 00:00:00 2001"

I really get a hit. "Sept 17 2001"?? It's strange, because the repository is so much younger.

Can someone explain?
Thank you.
Junio C Hamano· Feb 23, 2007, 09:04 UTC · re: johan defries · lore

Re: strange date generated by git-format-patch

"johan defries" <johandefries@gmail.com> writes:
Show 7 quoted lines
> When I do
>
> #git-format-patch --stdout HEAD^|head -1 | grep --color "Mon Sep 17
> 00:00:00 2001"
>
> I really get a hit. "Sept 17 2001"?? It's strange, because the
> repository is so much younger.

That is just a fake random date to make the Unix-From line recognizable by common MUA and does not have anything to do with your commit objects.

The real date is on Date: header.
Johannes Schindelin· Feb 23, 2007, 14:59 UTC · re: Junio C Hamano · lore

Re: strange date generated by git-format-patch

Hi,
On Fri, 23 Feb 2007, Junio C Hamano wrote:
Show 12 quoted lines
> "johan defries" <johandefries@gmail.com> writes:
> 
> > When I do
> >
> > #git-format-patch --stdout HEAD^|head -1 | grep --color "Mon Sep 17
> > 00:00:00 2001"
> >
> > I really get a hit. "Sept 17 2001"?? It's strange, because the
> > repository is so much younger.
> 
> That is just a fake random date to make the Unix-From line recognizable 
> by common MUA and does not have anything to do with your commit objects.

So how about this: -- snipsnap -- [PATCH] pretty=email: use current date for "From <sha1>" lines

To keep MUAs happy, we have to provide a date in mbox files. These dates are supposed to mark the date of arrival, so take "now" instead of some made-up date.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 log-tree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index ac86194..b6e1ad2 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -174,7 +174,7 @@ void show_log(struct rev_info *opt, const char *sep)
 		else
 			subject = "Subject: ";
 
-		printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
+		printf("From %s %s\n", sha1, show_date(time(NULL), 0, 0));
 		if (opt->message_id)
 			printf("Message-Id: <%s>\n", opt->message_id);
 		if (opt->ref_message_id)
Junio C Hamano· Feb 24, 2007, 09:30 UTC · re: Johannes Schindelin · lore

Re: strange date generated by git-format-patch

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> That is just a fake random date to make the Unix-From line recognizable 
>> by common MUA and does not have anything to do with your commit objects.
>
> So how about this:
Show 6 quoted lines
> @@ -174,7 +174,7 @@ void show_log(struct rev_info *opt, const char *sep)
>  		else
>  			subject = "Subject: ";
>  
> -		printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
> +		printf("From %s %s\n", sha1, show_date(time(NULL), 0, 0));

I actually once tried to change it to git's birthday (Thu Apr 7 15:13:13 2005 -0700) and I recall that it turned out that some people's scripts (or perhaps MUA) were broken and cared what was before "7" (nothing, as show_date() does, " " to align to two columns per date, "0" to zero-pad align) on the Unix-From line and discarded that update.

I do not think it is worth changing it. Who's hurting with the current behaviour? In other words, is it broken? Unix-From lines are there only to separate each piece of e-mail in the mbox and otherwise is not used. send-email, am, nor imap-send should care anything beyond the leading "From ", and mailsplit validates only that what's around the last colon near the end of line looks like time and year.

Theodore Tso· Feb 24, 2007, 13:08 UTC · re: Junio C Hamano · lore

Re: strange date generated by git-format-patch

On Sat, Feb 24, 2007 at 01:30:17AM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> That is just a fake random date to make the Unix-From line recognizable 
> >> by common MUA and does not have anything to do with your commit objects.
> >
> I do not think it is worth changing it.  Who's hurting with the
> current behaviour?  In other words, is it broken?  Unix-From
> lines are there only to separate each piece of e-mail in the
> mbox and otherwise is not used.  send-email, am, nor imap-send
> should care anything beyond the leading "From ", and mailsplit
> validates only that what's around the last colon near the end of
> line looks like time and year.

The only potential problem with it is that some MUA's (like mutt for example) sort by the From date by default. You can force it to list the patches in an unsorted order (via 'Ou'), but it might be nice if the patches date in the From field was the date that the patches were generated, with the seconds field bumped so that the patches in a series were guaranteed to have monotonically increasing dates. It's only a minor point, though.

						- Ted
Jeff King· Feb 24, 2007, 18:51 UTC · re: Theodore Tso · lore

Re: strange date generated by git-format-patch

On Sat, Feb 24, 2007 at 08:08:39AM -0500, Theodore Tso wrote:
> The only potential problem with it is that some MUA's (like mutt for
> example) sort by the From date by default.  You can force it to list
> the patches in an unsorted order (via 'Ou'), but it might be nice if

That's not true; mutt sorts by date by default, but it pulls the default from the "Date" header, which git correctly sets to the author timestamp. You can convince mutt to look at the date in the 'From' line using a 'date-received' sort, but I don't know that it was ever the default.

-Peff
Johannes Schindelin· Feb 24, 2007, 23:19 UTC · re: Junio C Hamano · lore

Re: strange date generated by git-format-patch

Hi,
On Sat, 24 Feb 2007, Junio C Hamano wrote:
Show 21 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> That is just a fake random date to make the Unix-From line 
> >> recognizable by common MUA and does not have anything to do with your 
> >> commit objects.
> >
> > So how about this:
> 
> > @@ -174,7 +174,7 @@ void show_log(struct rev_info *opt, const char *sep)
> >  		else
> >  			subject = "Subject: ";
> >  
> > -		printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
> > +		printf("From %s %s\n", sha1, show_date(time(NULL), 0, 0));
> 
> I actually once tried to change it to git's birthday (Thu Apr 7
> 15:13:13 2005 -0700) and I recall that it turned out that some
> people's scripts (or perhaps MUA) were broken and cared what was
> before "7" (nothing, as show_date() does, " " to align to two
> columns per date, "0" to zero-pad align) on the Unix-From line
> and discarded that update.

I only found out now (after some Googling, instigated by your reply) that the mbox format is _borked_. There seem to be so many variants, and I erroneously assumed that if it works in pine, it works everywhere...

> I do not think it is worth changing it.  Who's hurting with the
> current behaviour?  In other words, is it broken?

You can order by arrived-date. But that is such a minor issue that I agree nothing needs to be changed.

Ciao, Dscho

← back to recent threads