Used by git am internally.
Parses a single email patch (the kind git format-patch produces) into a clean message + diff. It's the lower-level tool that git am uses internally.
Input: one email (mbox-ish). Output: a cleaned commit message on stdout plus a separate patch file. Headers like From:, Subject:, Date: are extracted into a key-value info file.
git mailinfo [-k|-b] [-u|--encoding=<enc>|-n] [--[no-]scissors] [--quoted-cr=<action>]
<msg> <patch>
# Reads RFC822 email from stdin, writes:
# <msg> - cleaned commit message body
# <patch> - the diff portion
# stdout: - "Author: ...", "Email: ...", "Subject: ...", "Date: ..."
cat 0001-fix.patch | git mailinfo msg.out patch.out| Flag | What it does |
|---|---|
-k | Keep subject as-is; don't strip [PATCH]/Re: prefixes |
-b | Like -k but only keep [bracketed] strings that aren't [PATCH] |
-u | Re-encode commit message to UTF-8 (default) |
-n | Disable charset re-encoding entirely |
-m | Copy the message ID into a Message-Id: trailer |
--scissors | Cut everything before a >8 scissors line; useful when reviewers paste discussion above the patch |
--no-scissors | Disable scissors handling (the default) |
mbox -> commit pipeline that diverges from what git am does.git am.-k).-- >8 -- scissors line.git mailinfo msg patch < 0001-fix.patchgit mailinfo -k msg patch < weird-subject.emlgit mailinfo --scissors msg patch < review-thread.emlgit mailinfo -n msg patch < latin1.emlgit am - mailinfo is for when you need to inspect or transform the pieces.git mailsplit for mboxes with many messages.mailinfo overwrites <msg> and <patch> without warning - watch your filenames.-k, the [PATCH v3 1/4] prefix gets stripped, which is usually what you want but surprising if you're capturing it.Hit each option, then Check answers. Score is recorded; Next is always open.