module documentation

Classes for dealing with git am-style patches.

These patches are basically unified diffs with some extra metadata tacked on.

Function gen_diff_header Write a blob diff header.
Function get_summary Determine the summary line for use in a filename.
Function git_am_patch_split Parse a git-am-style patch and split it up into bits.
Function is_binary See if the first few bytes contain any null characters.
Function parse_patch_message Extract a Commit object and patch from an e-mail message.
Function patch_filename Undocumented
Function shortid Undocumented
Function unified_diff difflib.unified_diff that can detect "No newline at end of file" as original "git diff" does.
Function write_blob_diff Write blob diff.
Function write_commit_patch Write a individual file patch.
Function write_object_diff Write the diff for an object.
Function write_tree_diff Write tree diff.
Constant FIRST_FEW_BYTES Undocumented
Function _format_range_unified Convert range to the "ed" format
def gen_diff_header(paths, modes, shas):

Write a blob diff header.

Parameters
pathsTuple with old and new path
modesTuple with old and new modes
shasTuple with old and new shas
def get_summary(commit):

Determine the summary line for use in a filename.

Returns: Summary string

Parameters
commitCommit
def git_am_patch_split(f, encoding=None):

Parse a git-am-style patch and split it up into bits.

Returns: Tuple with commit object, diff contents and git version

Parameters
fFile-like object to parse
encodingEncoding to use when creating Git objects
def is_binary(content):

See if the first few bytes contain any null characters.

Parameters
contentBytestring to check for binary content
def parse_patch_message(msg, encoding=None):

Extract a Commit object and patch from an e-mail message.

Returns: Tuple with commit object, diff contents and git version

Parameters
msgAn email message (email.message.Message)
encodingEncoding to use to encode Git commits
def patch_filename(p, root):

Undocumented

def shortid(hexsha):

Undocumented

def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', tree_encoding='utf-8', output_encoding='utf-8'):

difflib.unified_diff that can detect "No newline at end of file" as original "git diff" does.

Based on the same function in Python2.7 difflib.py

def write_blob_diff(f, old_file, new_file):

Write blob diff.

Note: The use of write_object_diff is recommended over this function.

Parameters
fFile-like object to write to
old_file(path, mode, hexsha) tuple (None if nonexisting)
new_file(path, mode, hexsha) tuple (None if nonexisting)
def write_commit_patch(f, commit, contents, progress, version=None, encoding=None):

Write a individual file patch.

Parameters
fUndocumented
commitCommit object
contentsUndocumented
progressTuple with current patch number and total.
versionUndocumented
encodingUndocumented
Returns
tuple with filename and contents
def write_object_diff(f, store, old_file, new_file, diff_binary=False):

Write the diff for an object.

Note: the tuple elements should be None for nonexistent files

Parameters
fFile-like object to write to
storeStore to retrieve objects from, if necessary
old_file(path, mode, hexsha) tuple
new_file(path, mode, hexsha) tuple
diff_binaryWhether to diff files even if they are considered binary files by is_binary().
def write_tree_diff(f, store, old_tree, new_tree, diff_binary=False):

Write tree diff.

Parameters
fFile-like object to write to.
storeUndocumented
old_treeOld tree id
new_treeNew tree id
diff_binaryWhether to diff files even if they are considered binary files by is_binary().
FIRST_FEW_BYTES: int =

Undocumented

Value
8000
def _format_range_unified(start, stop):

Convert range to the "ed" format