run-command: Redirect stderr to a pipe before redirecting stdout to stderr

With this patch, in the 'start_command' function after forking
we now take care of stderr in the child process before stdout.

This way if 'start_command' is called with a 'child_process'
argument like this:

	.err = -1;
	.stdout_to_stderr = 1;

then stderr will be redirected to a pipe before stdout is
redirected to stderr. So we can now get the process' stdout
from the pipe (as well as its stderr).

Earlier such a call would have redirected stdout to stderr
before stderr was itself redirected, and therefore stdout
would not have followed stderr, which would not have been
very useful anyway.

Update documentation in 'api-run-command.txt' accordingly.

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