format-patch: Produce better output with --inline or --attach

This patch makes two small changes to improve the output of --inline
and --attach.

The first is to write a newline preceding the boundary. This is needed because
MIME defines the encapsulation boundary as including the preceding CRLF (or in
this case, just LF), so we should be writing one. Without this, the last
newline in the pre-diff content is consumed instead.

The second change is to always write the line termination character
(default: newline) even when using --inline or --attach. This is simply to
improve the aesthetics of the resulting message. When using --inline an email
client should render the resulting message identically to the non-inline
version. And when using --attach this adds a blank line preceding the
attachment in the email, which is visually attractive.

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