LinuxCommandLibrary

git-mailsplit

Split mbox or maildir format into files

SYNOPSIS

git mailsplit [-b] [-d] [-f] [-n] [-p[]] [-s] [-v[]] [--mboxrd] [--no-mboxrd] []

PARAMETERS

-b
    Treat the input as a binary file, passing the raw data through without modification.

-d
    Specify the directory to save the split messages. Defaults to the current directory.

-f
    Use to store the list of file names generated by the split operation. If not specified, the file names are printed to standard output.

-n
    Do not actually create any files. This can be used with -v to preview the split without modifying the file system.

-p[]
    Strip leading pathname components from the filename found in the Subject line (or From line if no Subject line is present) of each message. If is not specified, it defaults to 1. If the message does not have a filename, strip nothing.

-s
    Treat the input as a series of individual mail messages concatenated together, rather than as an mbox-formatted file.

-v[]
    Be more verbose. The higher the level, the more information is printed to standard error. Without a level, equivalent to -v1. Can be useful for debugging parsing problems.

--mboxrd
    Force interpretation of the input as mboxrd format even if it doesn't look like one.

--no-mboxrd
    Disable mboxrd format handling.


    Read from rather than standard input.

DESCRIPTION

git-mailsplit takes a mailbox format file (mbox, maildir, or raw) on standard input, splits it into individual email messages, and optionally strips the headers from each message to produce a patch file suitable for applying with git-am.

It's primarily used to prepare email contributions for import into a Git repository. It automatically extracts the commit message and patch content. The splitting logic is designed to handle various email formats and encodings commonly encountered in email archives. The extracted patches are saved as individual files in the current directory (or a specified directory) with sequentially numbered filenames.

CAVEATS

git-mailsplit relies on the structure of the input mailbox file. Mal-formatted or unusual mailbox files might not be parsed correctly, leading to incorrect patch splitting.

MAILBOX FORMATS

The command supports several mailbox formats:
mbox: Traditional mailbox format where messages are concatenated with 'From ' lines as separators.
maildir: A directory structure with individual files for each message.
Raw: A series of individual mail messages concatenated together. Use the -s option.

FILENAME GENERATION

By default, git-mailsplit generates filenames sequentially, starting with '0001'. The -d option allows specifying an alternative directory for the output files. The -f option allows saving the filenames to the specified file.

HISTORY

git-mailsplit was created as part of the Git project to facilitate the process of importing patches received via email. It addresses the common need to convert email archives into individual patch files suitable for use with git-am.

Over time, it has been refined to handle different mailbox formats (mbox, maildir, raw) and various encoding scenarios commonly encountered in email contributions. The options have been added to handle edge cases and malformed patch sets.

SEE ALSO

git am(1), git apply(1)

Copied to clipboard