def ls_tree(repo, tree_ish=None, outstream=sys.stdout, recursive=False, name_only=False):
 def list_tree(store, treeid, base):
  for (name, mode, sha) in store[treeid].iteritems():
   if base:
    name = posixpath.join(base, name)
   if name_only:
    outstream.write((name + '\n'))
   else:
    outstream.write(pretty_format_tree_entry(name, mode, sha))
   if stat.S_ISDIR(mode):
    list_tree(store, sha, name)
 if (tree_ish is None):
  tree_ish = 'HEAD'
 with open_repo_closing(repo) as r:
  c = r[tree_ish]
  treeid = c.tree
  list_tree(r.object_store, treeid, '')

def ls_tree ( repo , tree_ish = None , outstream = sys . stdout , recursive = False , name_only = False ) : def list_tree ( store , treeid , base ) : for ( name , mode , sha ) in store [ treeid ] . iteritems ( ) : if base : name = posixpath . join ( base , name ) if name_only : outstream . write ( ( name + '\n' ) ) else : outstream . write ( pretty_format_tree_entry ( name , mode , sha ) ) if stat . S_ISDIR ( mode ) : list_tree ( store , sha , name ) if ( tree_ish is None ) : tree_ish = 'HEAD' with open_repo_closing ( repo ) as r : c = r [ tree_ish ] treeid = c . tree list_tree ( r . object_store , treeid , '' )
list contents of a tree .