Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Mar 26, 2011

  1. jrn

    vcs-svn: remove buffer_read_string

    All previous users of buffer_read_string have already been converted
    to use the more intuitive buffer_read_binary, so remove the old API to
    avoid some confusion.
    Signed-off-by: Jonathan Nieder <>

Feb 26, 2011

  1. jrn

    vcs-svn: allow input from file descriptor

    Based-on-patch-by: David Barr <>
    Signed-off-by: Jonathan Nieder <>
  2. jrn

    vcs-svn: add binary-safe read function

    buffer_read_string works well for non line-oriented input except for
    one problem: it does not tell the caller how many bytes were actually
    written.  This means that unless one is very careful about checking
    for errors (and eof) the calling program cannot tell the difference
    between the string "foo" followed by an early end of file and the
    string "foo\0bar\0baz".
    So introduce a variant that reports the length, too, a thinner wrapper
    around strbuf_fread.  Its result is written to a strbuf so the caller
    does not need to keep track of the number of bytes read.
    Signed-off-by: Jonathan Nieder <>
  3. jrn

    t0081 (line-buffer): add buffering tests

    POSIX makes the behavior of read(2) from a pipe fairly clear: a read
    from an empty pipe will block until there is data available and any
    other read will not block, prefering to return a partial result.
    Likewise, fread(3) and fgets(3) are clearly specified to act as
    though implemented by calling fgetc(3) in a simple loop.  But the
    buffering behavior of fgetc is less clear.
    Luckily, no sane platform is going to implement fgetc by calling the
    equivalent of read(2) more than once.  fgetc has to be able to
    return without filling its buffer to preserve errno when errors are
    encountered anyway.  So let's assume the simpler behavior (trust) but
    add some tests to catch insane platforms that violate that when they
    come (verify).
    First check that fread can handle a 0-length read from an empty fifo.
    Because open(O_RDONLY) blocks until the writing end is open, open the
    writing end of the fifo in advance in a subshell.
    Next try short inputs from a pipe that is not filled all the way.
    Lastly (two tests) try very large inputs from a pipe that will not fit
    in the relevant buffers.  The first of these tests reads a little
    more than 8192 bytes, which is BUFSIZ (the size of stdio's buffers)
    on this Linux machine.  The second reads a little over 64 KiB (the
    pipe capacity on Linux) and is not run unless requested by setting
    the GIT_REMOTE_SVN_TEST_BIG_FILES environment variable.
    Signed-off-by: Jonathan Nieder <>
  4. jrn

    vcs-svn: tweak test-line-buffer to not assume line-oriented input

    Do not expect an implicit newline after each input record.
    Use a separate command to exercise buffer_skip_bytes.
    Signed-off-by: Jonathan Nieder <>
  5. jrn

    vcs-svn: make test-line-buffer input format more flexible

    Imitate the input format of test-obj-pool to support arbitrary
    sequences of commands rather than alternating read/copy.  This should
    make it easier to add tests that exercise other line_buffer functions.
    Signed-off-by: Jonathan Nieder <>
  6. jrn

    vcs-svn: teach line_buffer to handle multiple input files

    Collect the line_buffer state in a newly public line_buffer struct.
    Callers can use multiple line_buffers to manage input from multiple
    files at a time.
    svn-fe's delta applier will use this to stream a delta from svnrdump
    and the preimage it applies to from fast-import at the same time.
    The tests don't take advantage of the new features, but I think that's
    okay.  It is easier to find lingering examples of nonreentrant code by
    searching for "static" in line_buffer.c.
    Signed-off-by: Jonathan Nieder <>

Aug 15, 2010

  1. David Michael Barr

    Add stream helper library

    This library provides thread-unsafe fgets()- and fread()-like
    functions where the caller does not have to supply a buffer.  It
    maintains a couple of static buffers and provides an API to use
    [rr: allow input from files other than stdin]
    [jn: with tests, documentation, and error handling improvements]
    Signed-off-by: David Barr <>
    Signed-off-by: Ramkumar Ramachandra <>
    Signed-off-by: Jonathan Nieder <>
    Signed-off-by: Junio C Hamano <>
    authored gitster committed
Something went wrong with that request. Please try again.