# format-patch: "magic" mbox timestamp

4 messages from 2020-11-10 to 2020-11-10. Participants: Brandon Richardson, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/54616

## Brandon Richardson, 2020-11-10 21:54

Subject: format-patch: "magic" mbox timestamp
Message-ID: <CAETBDP6d8UwiJEF_pX0p=xLG79pwHeEtectmOnjPiUpjUCPaqw@mail.gmail.com>
URL: https://gitlist.dev/e/CAETBDP6d8UwiJEF_pX0p%3DxLG79pwHeEtectmOnjPiUpjUCPaqw%40mail.gmail.com

```
Hi all,

After submitting a patch internally within our organization today, I
was looking through the `format-patch` output and was curious to see
the strange timestamp on the "From" line. At first glance I thought
the parent commit timestamp might have been off, but that wasn't the
case. I thought it might be a bug but quickly noticed the fixed
timestamp string in `log-tree`.

Reading through the various revisions of `log-tree.c` didn't answer
many questions either, until I turned to the docs and read:

> The patch produced by git format-patch is in UNIX mailbox format, with a fixed "magic" time stamp to indicate that the file is output from format-patch rather than a real mailbox [...]

I find this pretty interesting, and would like to hear more from those
that introduced change. It looks like this was first introduced in
3eefc18917 (Tentative built-in format-patch., 2006-04-18), albeit with
a different "magic" timestamp, and then changed to its current
timestamp value in 698ce6f87e (fmt-patch: Support --attach,
2006-05-20).

Please correct me if I'm wrong, but I'm assuming the "UNIX mailbox
format" referenced in the docs refers to the mbox database format
described in appendix A of RFC-4155. If so, since we use a commit id
in place of the sender email address, would that itself be sufficient
to indicate that the output isn't from a real mailbox? A commit id
will never match the addr-spec in RFC-2822, so I figure that anyone
looking at `format-patch` output could safely assume that it did not
originate from a mailbox.

I could see this as a good opportunity to use a more relevant
timestamp, perhaps the commit timestamp of the first patch in the
series.

```

## Johannes Schindelin, 2020-11-10 23:12

Subject: Re: format-patch: "magic" mbox timestamp
Message-ID: <nycvar.QRO.7.76.6.2011102347320.18437@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.2011102347320.18437%40tvgsbejvaqbjf.bet
In-Reply-To: <CAETBDP6d8UwiJEF_pX0p=xLG79pwHeEtectmOnjPiUpjUCPaqw@mail.gmail.com>

```
Hi Brandon,

On Tue, 10 Nov 2020, Brandon Richardson wrote:

> After submitting a patch internally within our organization today, I
> was looking through the `format-patch` output and was curious to see
> the strange timestamp on the "From" line. At first glance I thought
> the parent commit timestamp might have been off, but that wasn't the
> case. I thought it might be a bug but quickly noticed the fixed
> timestamp string in `log-tree`.
>
> Reading through the various revisions of `log-tree.c` didn't answer
> many questions either, until I turned to the docs and read:
>
> > The patch produced by git format-patch is in UNIX mailbox format, with a fixed "magic" time stamp to indicate that the file is output from format-patch rather than a real mailbox [...]
>
> I find this pretty interesting, and would like to hear more from those
> that introduced change. It looks like this was first introduced in
> 3eefc18917 (Tentative built-in format-patch., 2006-04-18), albeit with
> a different "magic" timestamp, and then changed to its current
> timestamp value in 698ce6f87e (fmt-patch: Support --attach,
> 2006-05-20).
>
> Please correct me if I'm wrong, but I'm assuming the "UNIX mailbox
> format" referenced in the docs refers to the mbox database format
> described in appendix A of RFC-4155. If so, since we use a commit id
> in place of the sender email address, would that itself be sufficient
> to indicate that the output isn't from a real mailbox? A commit id
> will never match the addr-spec in RFC-2822, so I figure that anyone
> looking at `format-patch` output could safely assume that it did not
> originate from a mailbox.
>
> I could see this as a good opportunity to use a more relevant
> timestamp, perhaps the commit timestamp of the first patch in the
> series.

An interesting hike down memory lane. As to the explanation for the latter
change ("fmt-patch: Support --attach"), here is your answer:
https://lore.kernel.org/git/Pine.LNX.4.63.0605201904320.31887@wbgn013.biozentrum.uni-wuerzburg.de/

	On Sat, 20 May 2006, Jakub Narebski wrote:

	> Johannes Schindelin wrote:
	>
	> > -             printf("From %s  Thu Apr 7 15:13:13 2005\n",
	> > -                    sha1_to_hex(commit->object.sha1));
	> > +             printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
	>
	> What's with the date?

	Does not matter. This is not part of the mail header (the date is
	displayed as a "Date:" line).

	I only changed the "From " line (note the missing ":") to match the output
	from git-format-patch.sh.

As to "Tentative built-in format-patch", I can only _guess_ that the
timestamp was chosen to be identical to the first ever Git commit's
timestamp: e83c5163316 (Initial revision of "git", the information manager
from hell, 2005-04-07).

The original magic timestamp, however, was the one I reintroduced, and as
you can see from the part I quoted above, I only imitated the original
script. I do remember, even if it has been a lifetime ago, that I wondered
what kind of special date September 17th could have been for Junio, but I
felt it might have been too personal a question. That timestamp was
introduced into Git's source code in 5c2c972f474 ([PATCH] format-patch:
--mbox and --check., 2005-07-22), but the commit message is also quite mum
about the motivation between that particular timestamp.

Ciao,
Johannes

```

## Junio C Hamano, 2020-11-10 23:13

Subject: Re: format-patch: "magic" mbox timestamp
Message-ID: <xmqqmtzo6c0d.fsf@gitster.c.googlers.com>
URL: https://gitlist.dev/e/xmqqmtzo6c0d.fsf%40gitster.c.googlers.com
In-Reply-To: <CAETBDP6d8UwiJEF_pX0p=xLG79pwHeEtectmOnjPiUpjUCPaqw@mail.gmail.com>

```
Brandon Richardson <brandon1024.br@gmail.com> writes:

> Please correct me if I'm wrong, but I'm assuming the "UNIX mailbox
> format" referenced in the docs refers to the mbox database format
> described in appendix A of RFC-4155. If so, since we use a commit id
> in place of the sender email address, would that itself be sufficient
> to indicate that the output isn't from a real mailbox? A commit id
> will never match the addr-spec in RFC-2822, so I figure that anyone
> looking at `format-patch` output could safely assume that it did not
> originate from a mailbox.

I vaguely recall that it was possible for the "From" line that
begins each message in a UNIX mbox had a local sender without "@",
so it would be a bit wider than addr-spec and a string of raw
hexadecimal digits would not sufficiently "strange" enough to serve
as a "magic" identifier.


```

## Junio C Hamano, 2020-11-10 23:22

Subject: Re: format-patch: "magic" mbox timestamp
Message-ID: <xmqqimac6bld.fsf@gitster.c.googlers.com>
URL: https://gitlist.dev/e/xmqqimac6bld.fsf%40gitster.c.googlers.com
In-Reply-To: <nycvar.QRO.7.76.6.2011102347320.18437@tvgsbejvaqbjf.bet>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> The original magic timestamp, however, was the one I reintroduced, and as
> you can see from the part I quoted above, I only imitated the original
> script.

That's almost a lifetime ago that I totally forgot that it was
original a shell script.  

It indeed does this:

+	case "$mbox" in
+	t)
+	    echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line
+	    mailScript="$mailScript"'
+	    s|^|Subject: [PATCH'"$num"'] |'
+	    ;;

which clearly shows that "nobody" was chosen to mimic a real mailbox
(i.e. unlike what Brandon said in the other message, the <mailbox>
may not have "@" <domain> after <local-part>).

In any case, I think what's more important is after 15 years, if any
implementation of the /etc/magic database actually take advantage of
that magic date as the "magic" signal to identify a format-patch
output.  Despite the wishes of original authors and designers of Git
and its format-patch output, perhaps no /etc/magic author noticed it,
in which case it is safe to use other randomly picked dates, or the
timestamp of underlying commits.  Otherwise, changing the "magic"
timestamp would introduce a needless regression.


```
