Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the first line of git format-patch output?

when running git format-patch, the intent is to create an email representation of the code you wrote. So far so good. I'm no email expert, but it seems to me that the first line of this format-patch output isn't in a standard email header format...

 From de8d128fb520416e0b029c913b3a5ce900d0320c Mon Sep 17 00:00:00 2001 Message-Id:  From: Christopher Harvey  Date: Wed, 3 Apr 2013 10:17:52 -0400 Subject: [PATCH 0/3] *** SUBJECT HERE *** To: Christopher Harvey   *** BLURB HERE ***  Christopher Harvey (3):   commit 2   commit 3   commit 4   data | 3 +++  1 file changed, 3 insertions(+)  --  1.7.12.4 

what is From de8d128fb520416e0b029c913b3a5ce900d0320c Mon Sep 17 00:00:00 2001? what is the date for? It looks arbitrary to me, and it also prevents me from piping it to sendmail. I have to manually remove that line each time I want to send a patch.

thanks.

like image 359
Chris H Avatar asked Apr 03 '13 14:04

Chris H


People also ask

What is format patch in git?

The “git format-patch” command will check for commits that are in the branch specified but not in the current checked-out branch. As a consequence, running a “git format-patch” command on your current checkout branch won't output anything at all.

What is git patch command?

GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository. This way other people can check your changes from the GIT patch file you made and suggest the necessary corrections.

How can I see my git patch?

Git Cola includes an "Apply Patches" dialog that can be launched from the Actions menu, or via the git cola am sub-command. You can open patches in this dialog and display the contents with diff syntax highlighting. This feature is available in master by cloning the repo and will be in the upcoming v3.

What is git diff patch?

Git diff is a command used to output the changes between two sources inside the git repository. The data sources can be two different branches, commits, files, etc.


2 Answers

From git help format-patch

DISCUSSION 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, like so:

       From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001        From: Tony Luck <[email protected]>        Date: Tue, 13 Jul 2010 11:42:54 -0700        Subject: [PATCH] =?UTF-8?q?> > [IA64]=20Put=20ia64=20config=20files=20on=20the=20?=         =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20diet?=        MIME-Version: 1.0        Content-Type: text/plain; charset=UTF-8        Content-Transfer-Encoding: 8bit 
like image 143
Fredrik Pihl Avatar answered Sep 17 '22 22:09

Fredrik Pihl


As an appendix to Fredrik's answer, here are some relevant comments by Junio Hamano:

"Mon Sep 17 00:00:00 2001" 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.

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" ... on the Unix-From line and discarded that update.

The "From $SHA1 $magic_timestamp" line and other header lines are there to make it look like a mbox

Links: 1, 2, 3.

like image 23
TachyonVortex Avatar answered Sep 19 '22 22:09

TachyonVortex