def write_and_commit_patch_head(patch_num):
    write_patch_head(patch_num)

    git.add('.PATCH_HEAD')

    # Don't create a separate commit just to bump the PATCH_HEAD
    git.commit(None, amend=True, use_commit_object="HEAD")
def generate_and_commit_to_patch_repo(patch_repo_path, start_number=None):
    # NOTE: assume we're dealing with one patch for now
    filenames = git.format_patch(1, start_number=start_number)
    for filename in filenames:
        os.rename(filename, os.path.join(patch_repo_path, filename))

    # TODO: generate a different commit message based on whether this is the
    # original patch commit, or resolving a conflict
    with utils.temporary_chdir(patch_repo_path):
        for filename in filenames:
            git.add(filename)
        git.commit("Adding or updating %d" % start_number)