Merge branch 'mh/for-each-string-list-item-empty-fix'
[gitweb.git] / sha1_file.c
index 5f71bbac3ea9a11a4369ec0353e2e1258979ba19..dd7cbe52ef73754f30dfc61379549bc2fbd5e86c 100644 (file)
@@ -1820,6 +1820,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
 {
        int fd;
        struct strbuf sb = STRBUF_INIT;
+       int rc = 0;
 
        switch (st->st_mode & S_IFMT) {
        case S_IFREG:
@@ -1836,8 +1837,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
                if (!(flags & HASH_WRITE_OBJECT))
                        hash_sha1_file(sb.buf, sb.len, blob_type, oid->hash);
                else if (write_sha1_file(sb.buf, sb.len, blob_type, oid->hash))
-                       return error("%s: failed to insert into database",
-                                    path);
+                       rc = error("%s: failed to insert into database", path);
                strbuf_release(&sb);
                break;
        case S_IFDIR:
@@ -1845,12 +1845,12 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
        default:
                return error("%s: unsupported file type", path);
        }
-       return 0;
+       return rc;
 }
 
 int read_pack_header(int fd, struct pack_header *header)
 {
-       if (read_in_full(fd, header, sizeof(*header)) < sizeof(*header))
+       if (read_in_full(fd, header, sizeof(*header)) != sizeof(*header))
                /* "eof before pack header was fully read" */
                return PH_ERROR_EOF;