Make git-cherry handle root trees

This patch on top of 'next' makes built-in git-cherry handle root
commits.

It moves the static function log-tree.c::diff_root_tree() to
tree-diff.c and makes it more similar to diff_tree_sha1() by
shuffling around arguments and factoring out the call to
log_tree_diff_flush().  Consequently the name is changed to
diff_root_tree_sha1().  It is a version of diff_tree_sha1() that
compares the empty tree (= root tree) against a single 'real' tree.

This function is then used in get_patch_id() to compute patch IDs
for initial commits instead of SEGFAULTing, as the current code
does if confronted with parentless commits.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
4 files changed
tree: cbbdf8cbe6ef081f5e2d48c5d24d7fe283f443c4
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. gitweb/
  6. mozilla-sha1/
  7. perl/
  8. ppc/
  9. t/
  10. templates/
  11. xdiff/
  12. .gitignore
  13. alloc.c
  14. archive-tar.c
  15. archive-zip.c
  16. archive.h
  17. base85.c
  18. blame.c
  19. blob.c
  20. blob.h
  21. builtin-add.c
  22. builtin-apply.c
  23. builtin-archive.c
  24. builtin-cat-file.c
  25. builtin-check-ref-format.c
  26. builtin-checkout-index.c
  27. builtin-commit-tree.c
  28. builtin-count-objects.c
  29. builtin-diff-files.c
  30. builtin-diff-index.c
  31. builtin-diff-stages.c
  32. builtin-diff-tree.c
  33. builtin-diff.c
  34. builtin-fmt-merge-msg.c
  35. builtin-grep.c
  36. builtin-init-db.c
  37. builtin-log.c
  38. builtin-ls-files.c
  39. builtin-ls-tree.c
  40. builtin-mailinfo.c
  41. builtin-mailsplit.c
  42. builtin-mv.c
  43. builtin-name-rev.c
  44. builtin-pack-objects.c
  45. builtin-prune-packed.c
  46. builtin-prune.c
  47. builtin-push.c
  48. builtin-read-tree.c
  49. builtin-repo-config.c
  50. builtin-rev-list.c
  51. builtin-rev-parse.c
  52. builtin-rm.c
  53. builtin-runstatus.c
  54. builtin-show-branch.c
  55. builtin-stripspace.c
  56. builtin-symbolic-ref.c
  57. builtin-tar-tree.c
  58. builtin-unpack-objects.c
  59. builtin-update-index.c
  60. builtin-update-ref.c
  61. builtin-upload-archive.c
  62. builtin-verify-pack.c
  63. builtin-write-tree.c
  64. builtin.h
  65. cache-tree.c
  66. cache-tree.h
  67. cache.h
  68. check-racy.c
  69. color.c
  70. color.h
  71. combine-diff.c
  72. commit.c
  73. commit.h
  74. config.c
  75. config.mak.in
  76. configure.ac
  77. connect.c
  78. convert-objects.c
  79. copy.c
  80. COPYING
  81. csum-file.c
  82. csum-file.h
  83. ctype.c
  84. daemon.c
  85. date.c
  86. delta.h
  87. describe.c
  88. diff-delta.c
  89. diff-lib.c
  90. diff.c
  91. diff.h
  92. diffcore-break.c
  93. diffcore-delta.c
  94. diffcore-order.c
  95. diffcore-pickaxe.c
  96. diffcore-rename.c
  97. diffcore.h
  98. dir.c
  99. dir.h
  100. dump-cache-tree.c
  101. entry.c
  102. environment.c
  103. exec_cmd.c
  104. exec_cmd.h
  105. fetch-clone.c
  106. fetch-pack.c
  107. fetch.c
  108. fetch.h
  109. fsck-objects.c
  110. generate-cmdlist.sh
  111. git-am.sh
  112. git-annotate.perl
  113. git-applymbox.sh
  114. git-applypatch.sh
  115. git-archimport.perl
  116. git-bisect.sh
  117. git-branch.sh
  118. git-checkout.sh
  119. git-clean.sh
  120. git-clone.sh
  121. git-commit.sh
  122. git-compat-util.h
  123. git-cvsexportcommit.perl
  124. git-cvsimport.perl
  125. git-cvsserver.perl
  126. git-fetch.sh
  127. git-instaweb.sh
  128. git-lost-found.sh
  129. git-ls-remote.sh
  130. git-merge-octopus.sh
  131. git-merge-one-file.sh
  132. git-merge-ours.sh
  133. git-merge-recursive-old.py
  134. git-merge-resolve.sh
  135. git-merge-stupid.sh
  136. git-merge.sh
  137. git-p4import.py
  138. git-parse-remote.sh
  139. git-pull.sh
  140. git-quiltimport.sh
  141. git-rebase.sh
  142. git-relink.perl
  143. git-repack.sh
  144. git-request-pull.sh
  145. git-rerere.perl
  146. git-reset.sh
  147. git-resolve.sh
  148. git-revert.sh
  149. git-send-email.perl
  150. git-sh-setup.sh
  151. git-shortlog.perl
  152. git-svn.perl
  153. git-svnimport.perl
  154. git-tag.sh
  155. git-verify-tag.sh
  156. GIT-VERSION-GEN
  157. git.c
  158. git.spec.in
  159. gitk
  160. gitMergeCommon.py
  161. grep.c
  162. grep.h
  163. hash-object.c
  164. help.c
  165. http-fetch.c
  166. http-push.c
  167. http.c
  168. http.h
  169. ident.c
  170. imap-send.c
  171. index-pack.c
  172. INSTALL
  173. interpolate.c
  174. interpolate.h
  175. list-objects.c
  176. list-objects.h
  177. local-fetch.c
  178. lockfile.c
  179. log-tree.c
  180. log-tree.h
  181. Makefile
  182. merge-base.c
  183. merge-file.c
  184. merge-index.c
  185. merge-recursive.c
  186. merge-tree.c
  187. mktag.c
  188. mktree.c
  189. object-refs.c
  190. object.c
  191. object.h
  192. pack-check.c
  193. pack-redundant.c
  194. pack.h
  195. pager.c
  196. patch-delta.c
  197. patch-id.c
  198. path-list.c
  199. path-list.h
  200. path.c
  201. peek-remote.c
  202. pkt-line.c
  203. pkt-line.h
  204. quote.c
  205. quote.h
  206. read-cache.c
  207. README
  208. receive-pack.c
  209. refs.c
  210. refs.h
  211. revision.c
  212. revision.h
  213. rsh.c
  214. rsh.h
  215. run-command.c
  216. run-command.h
  217. send-pack.c
  218. server-info.c
  219. setup.c
  220. sha1_file.c
  221. sha1_name.c
  222. shell.c
  223. show-index.c
  224. sideband.c
  225. sideband.h
  226. ssh-fetch.c
  227. ssh-pull.c
  228. ssh-push.c
  229. ssh-upload.c
  230. strbuf.c
  231. strbuf.h
  232. tag.c
  233. tag.h
  234. tar.h
  235. test-date.c
  236. test-delta.c
  237. test-sha1.c
  238. test-sha1.sh
  239. trace.c
  240. tree-diff.c
  241. tree-walk.c
  242. tree-walk.h
  243. tree.c
  244. tree.h
  245. unpack-file.c
  246. unpack-trees.c
  247. unpack-trees.h
  248. update-server-info.c
  249. upload-pack.c
  250. usage.c
  251. var.c
  252. write_or_die.c
  253. wt-status.c
  254. wt-status.h
  255. xdiff-interface.c
  256. xdiff-interface.h