Build in checkout

The only differences in behavior should be:

 - git checkout -m with non-trivial merging won't print out
   merge-recursive messages (see the change in t7201-co.sh)

 - git checkout -- paths... will give a sensible error message if
   HEAD is invalid as a commit.

 - some intermediate states which were written to disk in the shell
   version (in particular, index states) are only kept in memory in
   this version, and therefore these can no longer be revealed by
   later write operations becoming impossible.

 - when we change branches, we discard MERGE_MSG, SQUASH_MSG, and
   rr-cache/MERGE_RR, like reset always has.

I'm not 100% sure I got the merge recursive setup exactly right; the
base for a non-trivial merge in the shell code doesn't seem
theoretically justified to me, but I tried to match it anyway, and the
tests all pass this way.

Other than these items, the results should be identical to the shell
version, so far as I can tell.

[jc: squashed lock-file fix from Dscho in]

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 files changed
tree: 41b91bb0a0f1a5461ca7efd46f0976951a38be65
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. git-gui/
  6. gitk-git/
  7. gitweb/
  8. mozilla-sha1/
  9. perl/
  10. ppc/
  11. t/
  12. templates/
  13. xdiff/
  14. .gitignore
  15. .mailmap
  16. alloc.c
  17. archive-tar.c
  18. archive-zip.c
  19. archive.c
  20. archive.h
  21. attr.c
  22. attr.h
  23. base85.c
  24. blob.c
  25. blob.h
  26. branch.c
  27. branch.h
  28. builtin-add.c
  29. builtin-annotate.c
  30. builtin-apply.c
  31. builtin-archive.c
  32. builtin-blame.c
  33. builtin-branch.c
  34. builtin-bundle.c
  35. builtin-cat-file.c
  36. builtin-check-attr.c
  37. builtin-check-ref-format.c
  38. builtin-checkout-index.c
  39. builtin-checkout.c
  40. builtin-clean.c
  41. builtin-commit-tree.c
  42. builtin-commit.c
  43. builtin-config.c
  44. builtin-count-objects.c
  45. builtin-describe.c
  46. builtin-diff-files.c
  47. builtin-diff-index.c
  48. builtin-diff-tree.c
  49. builtin-diff.c
  50. builtin-fast-export.c
  51. builtin-fetch--tool.c
  52. builtin-fetch-pack.c
  53. builtin-fetch.c
  54. builtin-fmt-merge-msg.c
  55. builtin-for-each-ref.c
  56. builtin-fsck.c
  57. builtin-gc.c
  58. builtin-grep.c
  59. builtin-http-fetch.c
  60. builtin-init-db.c
  61. builtin-log.c
  62. builtin-ls-files.c
  63. builtin-ls-remote.c
  64. builtin-ls-tree.c
  65. builtin-mailinfo.c
  66. builtin-mailsplit.c
  67. builtin-merge-base.c
  68. builtin-merge-file.c
  69. builtin-merge-ours.c
  70. builtin-merge-recursive.c
  71. builtin-mv.c
  72. builtin-name-rev.c
  73. builtin-pack-objects.c
  74. builtin-pack-refs.c
  75. builtin-prune-packed.c
  76. builtin-prune.c
  77. builtin-push.c
  78. builtin-read-tree.c
  79. builtin-reflog.c
  80. builtin-rerere.c
  81. builtin-reset.c
  82. builtin-rev-list.c
  83. builtin-rev-parse.c
  84. builtin-revert.c
  85. builtin-rm.c
  86. builtin-send-pack.c
  87. builtin-shortlog.c
  88. builtin-show-branch.c
  89. builtin-show-ref.c
  90. builtin-stripspace.c
  91. builtin-symbolic-ref.c
  92. builtin-tag.c
  93. builtin-tar-tree.c
  94. builtin-unpack-objects.c
  95. builtin-update-index.c
  96. builtin-update-ref.c
  97. builtin-upload-archive.c
  98. builtin-verify-pack.c
  99. builtin-verify-tag.c
  100. builtin-write-tree.c
  101. builtin.h
  102. bundle.c
  103. bundle.h
  104. cache-tree.c
  105. cache-tree.h
  106. cache.h
  107. check-builtins.sh
  108. check-racy.c
  109. color.c
  110. color.h
  111. combine-diff.c
  112. command-list.txt
  113. commit.c
  114. commit.h
  115. config.c
  116. config.mak.in
  117. configure.ac
  118. connect.c
  119. convert.c
  120. copy.c
  121. COPYING
  122. csum-file.c
  123. csum-file.h
  124. ctype.c
  125. daemon.c
  126. date.c
  127. decorate.c
  128. decorate.h
  129. delta.h
  130. diff-delta.c
  131. diff-lib.c
  132. diff.c
  133. diff.h
  134. diffcore-break.c
  135. diffcore-delta.c
  136. diffcore-order.c
  137. diffcore-pickaxe.c
  138. diffcore-rename.c
  139. diffcore.h
  140. dir.c
  141. dir.h
  142. dump-cache-tree.c
  143. entry.c
  144. environment.c
  145. exec_cmd.c
  146. exec_cmd.h
  147. fast-import.c
  148. fetch-pack.h
  149. fixup-builtins
  150. generate-cmdlist.sh
  151. git-add--interactive.perl
  152. git-am.sh
  153. git-archimport.perl
  154. git-bisect.sh
  155. git-clone.sh
  156. git-compat-util.h
  157. git-cvsexportcommit.perl
  158. git-cvsimport.perl
  159. git-cvsserver.perl
  160. git-filter-branch.sh
  161. git-help--browse.sh
  162. git-instaweb.sh
  163. git-lost-found.sh
  164. git-merge-octopus.sh
  165. git-merge-one-file.sh
  166. git-merge-resolve.sh
  167. git-merge-stupid.sh
  168. git-merge.sh
  169. git-mergetool.sh
  170. git-parse-remote.sh
  171. git-pull.sh
  172. git-quiltimport.sh
  173. git-rebase--interactive.sh
  174. git-rebase.sh
  175. git-relink.perl
  176. git-remote.perl
  177. git-repack.sh
  178. git-request-pull.sh
  179. git-send-email.perl
  180. git-sh-setup.sh
  181. git-stash.sh
  182. git-submodule.sh
  183. git-svn.perl
  184. GIT-VERSION-GEN
  185. git.c
  186. git.spec.in
  187. grep.c
  188. grep.h
  189. hash-object.c
  190. hash.c
  191. hash.h
  192. help.c
  193. http-push.c
  194. http-walker.c
  195. http.c
  196. http.h
  197. ident.c
  198. imap-send.c
  199. index-pack.c
  200. INSTALL
  201. interpolate.c
  202. interpolate.h
  203. list-objects.c
  204. list-objects.h
  205. lockfile.c
  206. log-tree.c
  207. log-tree.h
  208. mailmap.c
  209. mailmap.h
  210. Makefile
  211. match-trees.c
  212. merge-file.c
  213. merge-index.c
  214. merge-recursive.h
  215. merge-tree.c
  216. mktag.c
  217. mktree.c
  218. object-refs.c
  219. object.c
  220. object.h
  221. pack-check.c
  222. pack-redundant.c
  223. pack-write.c
  224. pack.h
  225. pager.c
  226. parse-options.c
  227. parse-options.h
  228. patch-delta.c
  229. patch-id.c
  230. patch-ids.c
  231. patch-ids.h
  232. path-list.c
  233. path-list.h
  234. path.c
  235. pkt-line.c
  236. pkt-line.h
  237. pretty.c
  238. progress.c
  239. progress.h
  240. quote.c
  241. quote.h
  242. reachable.c
  243. reachable.h
  244. read-cache.c
  245. README
  246. receive-pack.c
  247. reflog-walk.c
  248. reflog-walk.h
  249. refs.c
  250. refs.h
  251. remote.c
  252. remote.h
  253. revision.c
  254. revision.h
  255. run-command.c
  256. run-command.h
  257. send-pack.h
  258. server-info.c
  259. setup.c
  260. sha1_file.c
  261. sha1_name.c
  262. shallow.c
  263. shell.c
  264. show-index.c
  265. sideband.c
  266. sideband.h
  267. strbuf.c
  268. strbuf.h
  269. symlinks.c
  270. tag.c
  271. tag.h
  272. tar.h
  273. test-absolute-path.c
  274. test-chmtime.c
  275. test-date.c
  276. test-delta.c
  277. test-genrandom.c
  278. test-match-trees.c
  279. test-parse-options.c
  280. test-sha1.c
  281. test-sha1.sh
  282. trace.c
  283. transport.c
  284. transport.h
  285. tree-diff.c
  286. tree-walk.c
  287. tree-walk.h
  288. tree.c
  289. tree.h
  290. unpack-file.c
  291. unpack-trees.c
  292. unpack-trees.h
  293. update-server-info.c
  294. upload-pack.c
  295. usage.c
  296. utf8.c
  297. utf8.h
  298. var.c
  299. walker.c
  300. walker.h
  301. write_or_die.c
  302. ws.c
  303. wt-status.c
  304. wt-status.h
  305. xdiff-interface.c
  306. xdiff-interface.h