merge-recursive: improve add_cacheinfo error handling

Four closely related changes all with the purpose of fixing error handling
in this function:
  - fix reported function name in add_cacheinfo error messages
  - differentiate between the two error messages
  - abort early when we hit the error (stop ignoring return code)
  - mark a test which was hitting this error as failing until we get the
    right fix

In more detail...

In commit 0424138d5715 ("Fix bogus error message from merge-recursive
error path", 2007-04-01), it was noted that the name of the function which
the error message claimed it was reported from did not match the actual
function name.  This was changed to something closer to the real function
name, but it still didn't match the actual function name.  Fix the
reported name to match.

Second, the two errors in this function had identical messages, preventing
us from knowing which error had been triggered.  Add a couple words to the
second error message to differentiate the two.

Next, make sure callers do not ignore the return code so that it will stop
processing further entries (processing further entries could result in
more output which could cause the error to scroll off the screen, or at
least be missed by the user) and make it clear the error is the cause of
the early abort.  These errors should never be triggered in production; if
either one is, it represents a bug in the calling path somewhere and is
likely to have resulted in mis-merged content.  The combination of
ignoring of the return code and continuing to print other standard
messages after hitting the error resulted in the following bug report from
Junio: "...the command pretends that everything went well and merged
cleanly in that path...[Behaving] in a buggy and unexplainable way is bad
enough, doing so silently is unexcusable."  Fix this.

Finally, there was one test in the testsuite that did hit this error path,
but was passing anyway.  This would have been easy to miss since it had a
test_must_fail and thus could have failed for the wrong reason, but in a
separate testing step I added an intentional NULL-dereference to the
codepath where these error messages are printed in order to flush out such
cases.  I could modify that test to explicitly check for this error and
fail the test if it is hit, but since this test operates in a bit of a
gray area and needed other changes, I went for a different fix.  The gray
area this test operates in is the following: If the merge of a certain
file results in the same version of the file that existed in HEAD, but
there are dirty modifications to the file, is that an error with a
"Refusing to overwrite existing file" expected, or a case where the merge
should succeed since we shouldn't have to touch the dirty file anyway?
Recent discussion on the list leaned towards saying it should be a
success.  Therefore, change the expected behavior of this test to match.
As a side effect, this makes the failed-due-to-hitting-add_cacheinfo-error
very clear, and we can mark the test as test_expect_failure.  A subsequent
commit will implement the necessary changes to get this test to pass
again.

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

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks