def tree_entries_from_data(data):
 ord_zero = ord('0')
 space_ord = ord(' ')
 len_data = len(data)
 i = 0
 out = list()
 while (i < len_data):
  mode = 0
  while (byte_ord(data[i]) != space_ord):
   mode = ((mode << 3) + (byte_ord(data[i]) - ord_zero))
   i += 1
  i += 1
  ns = i
  while (byte_ord(data[i]) != 0):
   i += 1
  name = data[ns:i]
  name = safe_decode(name)
  i += 1
  sha = data[i:(i + 20)]
  i = (i + 20)
  out.append((sha, mode, name))
 return out

def tree_entries_from_data ( data ) : ord_zero = ord ( '0' ) space_ord = ord ( ' ' ) len_data = len ( data ) i = 0 out = list ( ) while ( i < len_data ) : mode = 0 while ( byte_ord ( data [ i ] ) != space_ord ) : mode = ( ( mode << 3 ) + ( byte_ord ( data [ i ] ) - ord_zero ) ) i += 1 i += 1 ns = i while ( byte_ord ( data [ i ] ) != 0 ) : i += 1 name = data [ ns : i ] name = safe_decode ( name ) i += 1 sha = data [ i : ( i + 20 ) ] i = ( i + 20 ) out . append ( ( sha , mode , name ) ) return out
reads the binary representation of a tree and returns tuples of tree items .