> @@ -448,26 +454,28 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, > } > strbuf_reset(&sb_contents); > if (strbuf_read(&sb_contents, fd, 256) < 0) { > - int save_errno = errno; > close(fd); > - errno = save_errno; > goto out; > } [snip unrelated code] > out: > - *failure_errno = errno; > + if (ret && !myerr) > + BUG("returning non-zero %d, should have set myerr!", ret); At $DAYJOB, some people have observed this BUG triggering. Right now I don't have a consistent reproduction recipe, but we noticed that the block starting with "if (strbuf_read" quoted above does not set myerr upon an error, and instead immediately jumps to "out" with ret being -1.