Re: git-format-patch should include a checksum
- From
Sverre Rabbelier <srabbelier@gmail.com>
- Date
- Jan 26, 2010, 23:15 UTC
- Message-ID
- <fabb9a1e1001261515w44ccf7a4le6a49724164e902c@mail.gmail.com>
- In-Reply-To
- <871vhcmr5b.fsf@trurl.pps.jussieu.fr>
Heya,
On Tue, Jan 26, 2010 at 23:34, Juliusz Chroboczek <jch@pps.jussieu.fr> wrote:
Show 5 quoted lines
> I'm seeing Git patches being corrupted by mailers and still apply > correctly. It would be great if git-format-patch could include a hash > of the patch body (and commit message); git-am should check the hash, > and refuse to commit if the patch was corrupted (--force should override > that, of course).
Sounds like a good idea, have a look at cmd_format_patch in builtin-log.c. Assuming you want to add the hash as a X- mail header (e.g. X-Git-Message-Hash), you should probably add it before line 1019 (where rev.extra_headers is set to the current contents of 'buf'). For the hash itself have a look at git_SHA1_{Init,Update,Final} in various files, csum-file.c would seem like an excellent candidate, as it writes a sha1-summed file, which is sortof what you want to do.
For the git-am part look at 'git-am.sh', you should have checking logic warn only at first, and add a configuration option that allows enforcing it and warn when the option isn't set, instructing the user how to configure the option, see warn_unconfigured_deny_msg in builtin-receive-pack.c. A few releases from now we can set it from warn to abort (or deny, whatever the enforcing option is called).
Good luck!
-- Cheers, Sverre Rabbelier