Fix "git log -z" behaviour

For commit messages, we should really put the "line_termination" when we
output the character in between different commits, *not* between the
commit and the diff. The diff goes hand-in-hand with the commit, it
shouldn't be separated from it with the termination character.

So this:
 - uses the termination character for true inter-commit spacing
 - uses a regular newline between the commit log and the diff

We had it the other way around.

For the normal case where the termination character is '\n', this
obviously doesn't change anything at all, since we just switched two
identical characters around. So it's very safe - it doesn't change any
normal usage, but it definitely fixes "git log -z".

By fixing "git log -z", you can now also do insane things like

	git log -p -z |
		grep -z "some patch expression" |
		tr '\0' '\n' |
		less -S

and you will see only those commits that have the "some patch expression"
in their commit message _or_ their patches.

(This is slightly different from 'git log -S"some patch expression"',
since the latter requires the expression to literally *change* in the
patch, while the "git log -p -z | grep .." approach will see it if it's
just an unchanged _part_ of the patch context)

Of course, if you actually do something like the above, you're probably
insane, but hey, it works!

Try the above command line for a demonstration (of course, you need to
change the "some patch expression" to be something relevant). The old
behaviour of "git log -p -z" was useless (and got things completely wrong
for log entries without patches).

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