def tree_encode(shalist):
 shalist = sorted(shalist, key=shalist_item_sort_key)
 l = []
 for (mode, name, bin) in shalist:
  assert mode
  assert ((mode + 0) == mode)
  assert name
  assert (len(bin) == 20)
  s = ('%o %s\x00%s' % (mode, name, bin))
  assert (s[0] != '0')
  l.append(s)
 return ''.join(l)

def tree_encode ( shalist ) : shalist = sorted ( shalist , key = shalist_item_sort_key ) l = [ ] for ( mode , name , bin ) in shalist : assert mode assert ( ( mode + 0 ) == mode ) assert name assert ( len ( bin ) == 20 ) s = ( '%o %s\x00%s' % ( mode , name , bin ) ) assert ( s [ 0 ] != '0' ) l . append ( s ) return '' . join ( l )
generate a git tree object from tuples .