'Reads a pkt-line from the remote git process.
This method may read from the readahead buffer; see unread_pkt_line.
:return: The next string from the stream, without the length prefix, or
None for a flush-pkt (\'0000\').'

def read_pkt_line(self):

    if (self._readahead is None):
        read = self.read
    else:
        read = self._readahead.read
        self._readahead = None
    try:
        sizestr = read(4)
        if (not sizestr):
            raise HangupException()
        size = int(sizestr, 16)
        if (size == 0):
            if self.report_activity:
                self.report_activity(4, 'read')
            return None
        if self.report_activity:
            self.report_activity(size, 'read')
        pkt_contents = read((size - 4))
    except socket.error as e:
        raise GitProtocolError(e)
    else:
        if ((len(pkt_contents) + 4) != size):
            raise GitProtocolError(('Length    of    pkt    read    %04x    does    not    match    length    prefix    %04x' % ((len(pkt_contents) + 4), size)))
        return pkt_contents
