def read_packed_refs_with_peeled(f):
 last = None
 for l in f:
  if (l[0] == '#'):
   continue
  l = l.rstrip('\r\n')
  if l.startswith('^'):
   if (not last):
    raise PackedRefsException('unexpected peeled ref line')
   if (not valid_hexsha(l[1:])):
    raise PackedRefsException(('Invalid hex sha %r' % l[1:]))
   (sha, name) = _split_ref_line(last)
   last = None
   (yield (sha, name, l[1:]))
  else:
   if last:
    (sha, name) = _split_ref_line(last)
    (yield (sha, name, None))
   last = l
 if last:
  (sha, name) = _split_ref_line(last)
  (yield (sha, name, None))

def read_packed_refs_with_peeled ( f ) : last = None for l in f : if ( l [ 0 ] == '#' ) : continue l = l . rstrip ( '\r\n' ) if l . startswith ( '^' ) : if ( not last ) : raise PackedRefsException ( 'unexpected peeled ref line' ) if ( not valid_hexsha ( l [ 1 : ] ) ) : raise PackedRefsException ( ( 'Invalid hex sha %r' % l [ 1 : ] ) ) ( sha , name ) = _split_ref_line ( last ) last = None ( yield ( sha , name , l [ 1 : ] ) ) else : if last : ( sha , name ) = _split_ref_line ( last ) ( yield ( sha , name , None ) ) last = l if last : ( sha , name ) = _split_ref_line ( last ) ( yield ( sha , name , None ) )
read a packed refs file including peeled refs .