fsck: return non-zero status on missing ref tips

Fsck tries hard to detect missing objects, and will complain
(and exit non-zero) about any inter-object links that are
missing. However, it will not exit non-zero for any missing
ref tips, meaning that a severely broken repository may
still pass "git fsck && echo ok".

The problem is that we use for_each_ref to iterate over the
ref tips, which hides broken tips. It does at least print an
error from the refs.c code, but fsck does not ever see the
ref and cannot note the problem in its exit code. We can solve
this by using for_each_rawref and noting the error ourselves.

In addition to adding tests for this case, we add tests for
all types of missing-object links (all of which worked, but
which we were not testing).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: bcac4b82fce1c7ba24cf71bea861e98c110ab41c
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. gitk-git/
  8. gitweb/
  9. mergetools/
  10. perl/
  11. po/
  12. ppc/
  13. t/
  14. templates/
  15. vcs-svn/
  16. xdiff/
  17. .gitattributes
  18. .gitignore
  19. .mailmap
  20. abspath.c
  21. aclocal.m4
  22. advice.c
  23. advice.h
  24. alias.c
  25. alloc.c
  26. archive-tar.c
  27. archive-zip.c
  28. archive.c
  29. archive.h
  30. argv-array.c
  31. argv-array.h
  32. attr.c
  33. attr.h
  34. base85.c
  35. bisect.c
  36. bisect.h
  37. blob.c
  38. blob.h
  39. branch.c
  40. branch.h
  41. builtin.h
  42. bulk-checkin.c
  43. bulk-checkin.h
  44. bundle.c
  45. bundle.h
  46. cache-tree.c
  47. cache-tree.h
  48. cache.h
  49. check-builtins.sh
  50. check-racy.c
  51. check_bindir
  52. color.c
  53. color.h
  54. column.c
  55. column.h
  56. combine-diff.c
  57. command-list.txt
  58. commit-slab.h
  59. commit.c
  60. commit.h
  61. config.c
  62. config.mak.in
  63. config.mak.uname
  64. configure.ac
  65. connect.c
  66. connect.h
  67. connected.c
  68. connected.h
  69. convert.c
  70. convert.h
  71. copy.c
  72. COPYING
  73. credential-cache--daemon.c
  74. credential-cache.c
  75. credential-store.c
  76. credential.c
  77. credential.h
  78. csum-file.c
  79. csum-file.h
  80. ctype.c
  81. daemon.c
  82. date.c
  83. decorate.c
  84. decorate.h
  85. delta.h
  86. diff-delta.c
  87. diff-lib.c
  88. diff-no-index.c
  89. diff.c
  90. diff.h
  91. diffcore-break.c
  92. diffcore-delta.c
  93. diffcore-order.c
  94. diffcore-pickaxe.c
  95. diffcore-rename.c
  96. diffcore.h
  97. dir.c
  98. dir.h
  99. editor.c
  100. entry.c
  101. environment.c
  102. exec_cmd.c
  103. exec_cmd.h
  104. fast-import.c
  105. fetch-pack.c
  106. fetch-pack.h
  107. fmt-merge-msg.h
  108. fsck.c
  109. fsck.h
  110. generate-cmdlist.sh
  111. gettext.c
  112. gettext.h
  113. git-add--interactive.perl
  114. git-am.sh
  115. git-archimport.perl
  116. git-bisect.sh
  117. git-compat-util.h
  118. git-cvsexportcommit.perl
  119. git-cvsimport.perl
  120. git-cvsserver.perl
  121. git-difftool--helper.sh
  122. git-difftool.perl
  123. git-filter-branch.sh
  124. git-instaweb.sh
  125. git-merge-octopus.sh
  126. git-merge-one-file.sh
  127. git-merge-resolve.sh
  128. git-mergetool--lib.sh
  129. git-mergetool.sh
  130. git-p4.py
  131. git-parse-remote.sh
  132. git-pull.sh
  133. git-quiltimport.sh
  134. git-rebase--am.sh
  135. git-rebase--interactive.sh
  136. git-rebase--merge.sh
  137. git-rebase.sh
  138. git-relink.perl
  139. git-remote-testgit.sh
  140. git-request-pull.sh
  141. git-send-email.perl
  142. git-sh-i18n.sh
  143. git-sh-setup.sh
  144. git-stash.sh
  145. git-submodule.sh
  146. git-svn.perl
  147. GIT-VERSION-GEN
  148. git-web--browse.sh
  149. git.c
  150. git.rc
  151. git.spec.in
  152. gpg-interface.c
  153. gpg-interface.h
  154. graph.c
  155. graph.h
  156. grep.c
  157. grep.h
  158. hash.c
  159. hash.h
  160. help.c
  161. help.h
  162. hex.c
  163. http-backend.c
  164. http-fetch.c
  165. http-push.c
  166. http-walker.c
  167. http.c
  168. http.h
  169. ident.c
  170. imap-send.c
  171. INSTALL
  172. kwset.c
  173. kwset.h
  174. levenshtein.c
  175. levenshtein.h
  176. LGPL-2.1
  177. line-log.c
  178. line-log.h
  179. line-range.c
  180. line-range.h
  181. list-objects.c
  182. list-objects.h
  183. ll-merge.c
  184. ll-merge.h
  185. lockfile.c
  186. log-tree.c
  187. log-tree.h
  188. mailmap.c
  189. mailmap.h
  190. Makefile
  191. match-trees.c
  192. merge-blobs.c
  193. merge-blobs.h
  194. merge-recursive.c
  195. merge-recursive.h
  196. merge.c
  197. mergesort.c
  198. mergesort.h
  199. name-hash.c
  200. notes-cache.c
  201. notes-cache.h
  202. notes-merge.c
  203. notes-merge.h
  204. notes-utils.c
  205. notes-utils.h
  206. notes.c
  207. notes.h
  208. object.c
  209. object.h
  210. pack-check.c
  211. pack-revindex.c
  212. pack-revindex.h
  213. pack-write.c
  214. pack.h
  215. pager.c
  216. parse-options-cb.c
  217. parse-options.c
  218. parse-options.h
  219. patch-delta.c
  220. patch-ids.c
  221. patch-ids.h
  222. path.c
  223. pathspec.c
  224. pathspec.h
  225. pkt-line.c
  226. pkt-line.h
  227. preload-index.c
  228. pretty.c
  229. prio-queue.c
  230. prio-queue.h
  231. progress.c
  232. progress.h
  233. prompt.c
  234. prompt.h
  235. quote.c
  236. quote.h
  237. reachable.c
  238. reachable.h
  239. read-cache.c
  240. README
  241. reflog-walk.c
  242. reflog-walk.h
  243. refs.c
  244. refs.h
  245. remote-curl.c
  246. remote-testsvn.c
  247. remote.c
  248. remote.h
  249. replace_object.c
  250. rerere.c
  251. rerere.h
  252. resolve-undo.c
  253. resolve-undo.h
  254. revision.c
  255. revision.h
  256. run-command.c
  257. run-command.h
  258. send-pack.c
  259. send-pack.h
  260. sequencer.c
  261. sequencer.h
  262. server-info.c
  263. setup.c
  264. sh-i18n--envsubst.c
  265. sha1-array.c
  266. sha1-array.h
  267. sha1-lookup.c
  268. sha1-lookup.h
  269. sha1_file.c
  270. sha1_name.c
  271. shallow.c
  272. shell.c
  273. shortlog.h
  274. show-index.c
  275. sideband.c
  276. sideband.h
  277. sigchain.c
  278. sigchain.h
  279. strbuf.c
  280. strbuf.h
  281. streaming.c
  282. streaming.h
  283. string-list.c
  284. string-list.h
  285. submodule.c
  286. submodule.h
  287. symlinks.c
  288. tag.c
  289. tag.h
  290. tar.h
  291. test-chmtime.c
  292. test-ctype.c
  293. test-date.c
  294. test-delta.c
  295. test-dump-cache-tree.c
  296. test-genrandom.c
  297. test-index-version.c
  298. test-line-buffer.c
  299. test-match-trees.c
  300. test-mergesort.c
  301. test-mktemp.c
  302. test-parse-options.c
  303. test-path-utils.c
  304. test-prio-queue.c
  305. test-read-cache.c
  306. test-regex.c
  307. test-revision-walking.c
  308. test-run-command.c
  309. test-scrap-cache-tree.c
  310. test-sha1.c
  311. test-sha1.sh
  312. test-sigchain.c
  313. test-string-list.c
  314. test-subprocess.c
  315. test-svn-fe.c
  316. test-urlmatch-normalization.c
  317. test-wildmatch.c
  318. thread-utils.c
  319. thread-utils.h
  320. trace.c
  321. transport-helper.c
  322. transport.c
  323. transport.h
  324. tree-diff.c
  325. tree-walk.c
  326. tree-walk.h
  327. tree.c
  328. tree.h
  329. unimplemented.sh
  330. unix-socket.c
  331. unix-socket.h
  332. unpack-trees.c
  333. unpack-trees.h
  334. upload-pack.c
  335. url.c
  336. url.h
  337. urlmatch.c
  338. urlmatch.h
  339. usage.c
  340. userdiff.c
  341. userdiff.h
  342. utf8.c
  343. utf8.h
  344. varint.c
  345. varint.h
  346. version.c
  347. version.h
  348. walker.c
  349. walker.h
  350. wildmatch.c
  351. wildmatch.h
  352. wrap-for-bin.sh
  353. wrapper.c
  354. write_or_die.c
  355. ws.c
  356. wt-status.c
  357. wt-status.h
  358. xdiff-interface.c
  359. xdiff-interface.h
  360. zlib.c