Correctly report corrupted objects

The errno check added in commit 3ba7a06 "A loose object is not corrupt
if it cannot be read due to EMFILE" only checked for whether errno is
not ENOENT and thus incorrectly treated "no error" as an error
condition.

Because of that, it never reached the code path that would report that
the object is corrupted and instead caused funny errors like:

  fatal: failed to read object 333c4768ce595793fdab1ef3a036413e2a883853: Success

So we have to extend the check to cover the case in which the object
file was successfully read, but its contents are corrupted.

Reported-by: Will Palmer <wmpalmer@gmail.com>
Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: dc2ec1e79f80cbf5389654912d22ddcb66d99c75
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. perl/
  11. ppc/
  12. t/
  13. templates/
  14. vcs-svn/
  15. xdiff/
  16. .gitattributes
  17. .gitignore
  18. .mailmap
  19. abspath.c
  20. aclocal.m4
  21. advice.c
  22. advice.h
  23. alias.c
  24. alloc.c
  25. archive-tar.c
  26. archive-zip.c
  27. archive.c
  28. archive.h
  29. attr.c
  30. attr.h
  31. base85.c
  32. bisect.c
  33. bisect.h
  34. blob.c
  35. blob.h
  36. branch.c
  37. branch.h
  38. builtin.h
  39. bundle.c
  40. bundle.h
  41. cache-tree.c
  42. cache-tree.h
  43. cache.h
  44. check-builtins.sh
  45. check-racy.c
  46. check_bindir
  47. color.c
  48. color.h
  49. combine-diff.c
  50. command-list.txt
  51. commit.c
  52. commit.h
  53. config.c
  54. config.mak.in
  55. configure.ac
  56. connect.c
  57. convert.c
  58. copy.c
  59. COPYING
  60. csum-file.c
  61. csum-file.h
  62. ctype.c
  63. daemon.c
  64. date.c
  65. decorate.c
  66. decorate.h
  67. delta.h
  68. diff-delta.c
  69. diff-lib.c
  70. diff-no-index.c
  71. diff.c
  72. diff.h
  73. diffcore-break.c
  74. diffcore-delta.c
  75. diffcore-order.c
  76. diffcore-pickaxe.c
  77. diffcore-rename.c
  78. diffcore.h
  79. dir.c
  80. dir.h
  81. editor.c
  82. entry.c
  83. environment.c
  84. exec_cmd.c
  85. exec_cmd.h
  86. fast-import.c
  87. fetch-pack.h
  88. fixup-builtins
  89. fsck.c
  90. fsck.h
  91. generate-cmdlist.sh
  92. git-add--interactive.perl
  93. git-am.sh
  94. git-archimport.perl
  95. git-bisect.sh
  96. git-compat-util.h
  97. git-cvsexportcommit.perl
  98. git-cvsimport.perl
  99. git-cvsserver.perl
  100. git-difftool--helper.sh
  101. git-difftool.perl
  102. git-filter-branch.sh
  103. git-instaweb.sh
  104. git-lost-found.sh
  105. git-merge-octopus.sh
  106. git-merge-one-file.sh
  107. git-merge-resolve.sh
  108. git-mergetool--lib.sh
  109. git-mergetool.sh
  110. git-parse-remote.sh
  111. git-pull.sh
  112. git-quiltimport.sh
  113. git-rebase--interactive.sh
  114. git-rebase.sh
  115. git-relink.perl
  116. git-remote-testgit.py
  117. git-repack.sh
  118. git-request-pull.sh
  119. git-send-email.perl
  120. git-sh-setup.sh
  121. git-stash.sh
  122. git-submodule.sh
  123. git-svn.perl
  124. GIT-VERSION-GEN
  125. git-web--browse.sh
  126. git.c
  127. git.spec.in
  128. graph.c
  129. graph.h
  130. grep.c
  131. grep.h
  132. hash.c
  133. hash.h
  134. help.c
  135. help.h
  136. hex.c
  137. http-backend.c
  138. http-fetch.c
  139. http-push.c
  140. http-walker.c
  141. http.c
  142. http.h
  143. ident.c
  144. imap-send.c
  145. INSTALL
  146. levenshtein.c
  147. levenshtein.h
  148. list-objects.c
  149. list-objects.h
  150. ll-merge.c
  151. ll-merge.h
  152. lockfile.c
  153. log-tree.c
  154. log-tree.h
  155. mailmap.c
  156. mailmap.h
  157. Makefile
  158. match-trees.c
  159. merge-file.c
  160. merge-recursive.c
  161. merge-recursive.h
  162. name-hash.c
  163. notes-cache.c
  164. notes-cache.h
  165. notes-merge.c
  166. notes-merge.h
  167. notes.c
  168. notes.h
  169. object.c
  170. object.h
  171. pack-check.c
  172. pack-refs.c
  173. pack-refs.h
  174. pack-revindex.c
  175. pack-revindex.h
  176. pack-write.c
  177. pack.h
  178. pager.c
  179. parse-options.c
  180. parse-options.h
  181. patch-delta.c
  182. patch-ids.c
  183. patch-ids.h
  184. path.c
  185. pkt-line.c
  186. pkt-line.h
  187. preload-index.c
  188. pretty.c
  189. progress.c
  190. progress.h
  191. quote.c
  192. quote.h
  193. reachable.c
  194. reachable.h
  195. read-cache.c
  196. README
  197. reflog-walk.c
  198. reflog-walk.h
  199. refs.c
  200. refs.h
  201. remote-curl.c
  202. remote.c
  203. remote.h
  204. replace_object.c
  205. rerere.c
  206. rerere.h
  207. resolve-undo.c
  208. resolve-undo.h
  209. revision.c
  210. revision.h
  211. run-command.c
  212. run-command.h
  213. send-pack.h
  214. server-info.c
  215. setup.c
  216. sha1-lookup.c
  217. sha1-lookup.h
  218. sha1_file.c
  219. sha1_name.c
  220. shallow.c
  221. shell.c
  222. shortlog.h
  223. show-index.c
  224. sideband.c
  225. sideband.h
  226. sigchain.c
  227. sigchain.h
  228. strbuf.c
  229. strbuf.h
  230. string-list.c
  231. string-list.h
  232. submodule.c
  233. submodule.h
  234. symlinks.c
  235. tag.c
  236. tag.h
  237. tar.h
  238. test-chmtime.c
  239. test-ctype.c
  240. test-date.c
  241. test-delta.c
  242. test-dump-cache-tree.c
  243. test-genrandom.c
  244. test-index-version.c
  245. test-line-buffer.c
  246. test-match-trees.c
  247. test-obj-pool.c
  248. test-parse-options.c
  249. test-path-utils.c
  250. test-run-command.c
  251. test-sha1.c
  252. test-sha1.sh
  253. test-sigchain.c
  254. test-string-pool.c
  255. test-subprocess.c
  256. test-svn-fe.c
  257. test-treap.c
  258. thread-utils.c
  259. thread-utils.h
  260. trace.c
  261. transport-helper.c
  262. transport.c
  263. transport.h
  264. tree-diff.c
  265. tree-walk.c
  266. tree-walk.h
  267. tree.c
  268. tree.h
  269. unimplemented.sh
  270. unpack-trees.c
  271. unpack-trees.h
  272. upload-pack.c
  273. url.c
  274. url.h
  275. usage.c
  276. userdiff.c
  277. userdiff.h
  278. utf8.c
  279. utf8.h
  280. walker.c
  281. walker.h
  282. wrap-for-bin.sh
  283. wrapper.c
  284. write_or_die.c
  285. ws.c
  286. wt-status.c
  287. wt-status.h
  288. xdiff-interface.c
  289. xdiff-interface.h
  290. zlib.c