parameters: (changed_lines, revision=None,
                                        binary='clang-format', style=None)
return_statement: return create_tree(index_info_generator(), '--index-info')
docstring: Run clang-format on each file and save the result to a git tree.
  
    Returns the object ID (SHA-1) of the created tree.
docstring_summary: Run clang-format on each file and save the result to a git tree.
docstring_tokens: Run clang - format on each file and save the result to a git tree .
function: def run_clang_format_and_save_to_tree(changed_lines, revision=None,
                                        binary='clang-format', style=None):
    """Run clang-format on each file and save the result to a git tree.
  
    Returns the object ID (SHA-1) of the created tree."""
    def iteritems(container):
        try:
            return container.iteritems() # Python 2
        except AttributeError:
            return container.items() # Python 3
    def index_info_generator():
      for filename, line_ranges in iteritems(changed_lines):
        if revision:
          git_metadata_cmd = ['git', 'ls-tree',
                              '%s:%s' % (revision, os.path.dirname(filename)),
                              os.path.basename(filename)]
          git_metadata = subprocess.Popen(git_metadata_cmd, stdin=subprocess.PIPE,
                                          stdout=subprocess.PIPE)
          stdout = git_metadata.communicate()[0]
          mode = oct(int(stdout.split()[0], 8))
        else:
          mode = oct(os.stat(filename).st_mode)
        # Adjust python3 octal format so that it matches what git expects
        if mode.startswith('0o'):
            mode = '0' + mode[2:]
        blob_id = clang_format_to_blob(filename, line_ranges,
                                       revision=revision,
                                       binary=binary,
                                       style=style)
        yield '%s %s\t%s' % (mode, blob_id, filename)
    return create_tree(index_info_generator(), '--index-info')
function_tokens: def run_clang_format_and_save_to_tree ( changed_lines , revision = None , binary = 'clang-format' , style = None ) : def iteritems ( container ) : try : return container . iteritems ( ) # Python 2 except AttributeError : return container . items ( ) # Python 3 def index_info_generator ( ) : for filename , line_ranges in iteritems ( changed_lines ) : if revision : git_metadata_cmd = [ 'git' , 'ls-tree' , '%s:%s' % ( revision , os . path . dirname ( filename ) ) , os . path . basename ( filename ) ] git_metadata = subprocess . Popen ( git_metadata_cmd , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) stdout = git_metadata . communicate ( ) [ 0 ] mode = oct ( int ( stdout . split ( ) [ 0 ] , 8 ) ) else : mode = oct ( os . stat ( filename ) . st_mode ) # Adjust python3 octal format so that it matches what git expects if mode . startswith ( '0o' ) : mode = '0' + mode [ 2 : ] blob_id = clang_format_to_blob ( filename , line_ranges , revision = revision , binary = binary , style = style ) yield '%s %s\t%s' % ( mode , blob_id , filename ) return create_tree ( index_info_generator ( ) , '--index-info' )