Revision 56d7c27af1f8aa7519f165f6c022732e64db3716 authored by Jeff King on 26 May 2011, 16:30:27 UTC, committed by Junio C Hamano on 26 May 2011, 20:54:18 UTC
The read_in_full function repeatedly calls read() to fill a buffer. If the first read() returns an error, we notify the caller by returning the error. However, if we read some data and then get an error on a subsequent read, we simply return the amount of data that we did read, and the caller is unaware of the error. This makes the tradeoff that seeing the partial data is more important than the fact that an error occurred. In practice, this is generally not the case; we care more if an error occurred, and should throw away any partial data. I audited the current callers. In most cases, this will make no difference at all, as they do: if (read_in_full(fd, buf, size) != size) error("short read"); However, it will help in a few cases: 1. In sha1_file.c:index_stream, we would fail to notice errors in the incoming stream. 2. When reading symbolic refs in resolve_ref, we would fail to notice errors and potentially use a truncated ref name. 3. In various places, we will get much better error messages. For example, callers of safe_read would erroneously print "the remote end hung up unexpectedly" instead of showing the read error. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 09ffc70
File | Mode | Size |
---|---|---|
xdiff.h | -rw-r--r-- | 3.4 KB |
xdiffi.c | -rw-r--r-- | 14.6 KB |
xdiffi.h | -rw-r--r-- | 1.8 KB |
xemit.c | -rw-r--r-- | 4.9 KB |
xemit.h | -rw-r--r-- | 1.2 KB |
xinclude.h | -rw-r--r-- | 1.2 KB |
xmacros.h | -rw-r--r-- | 1.9 KB |
xmerge.c | -rw-r--r-- | 15.1 KB |
xpatience.c | -rw-r--r-- | 10.7 KB |
xprepare.c | -rw-r--r-- | 11.2 KB |
xprepare.h | -rw-r--r-- | 1.1 KB |
xtypes.h | -rw-r--r-- | 1.6 KB |
xutils.c | -rw-r--r-- | 8.1 KB |
xutils.h | -rw-r--r-- | 1.7 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...