test-lib: silence "-x" cleanup under bash

When the test suite's "-x" option is used with bash, we end
up seeing cleanup cruft in the output:

  $ bash t0001-init.sh -x
  [...]
  ++ diff -u expected actual
  + test_eval_ret_=0
  + want_trace
  + test t = t
  + test t = t
  + set +x
  ok 42 - re-init from a linked worktree

This ranges from mildly annoying (for a successful test) to
downright confusing (when we say "last command exited with
error", but it's really 5 commands back).

We normally are able to suppress this cleanup. As the
in-code comment explains, we can't convince the shell not to
print it, but we can redirect its stderr elsewhere.

But since d88785e424 (test-lib: set BASH_XTRACEFD
automatically, 2016-05-11), that doesn't hold for bash. It
sends the "set -x" output directly to descriptor 4, not to
stderr.

We can fix this by also redirecting descriptor 4, and
paying close attention to which commands redirected and
which are not (see the updated comment).

Two alternatives I considered and rejected:

  - unsetting and setting BASH_XTRACEFD; doing so closes the
    descriptor, which we must avoid

  - we could keep everything in a single block as before,
    redirect 4>/dev/null there, but retain 5>&4 as a copy.
    And then selectively restore 4>&5 for commands which
    should be allowed to trace. This would work, but the
    descriptor swapping seems unnecessarily confusing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: fe115d2c56ec072501f7db92b2a4bf7988d4e9f0
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. perl/
  14. po/
  15. ppc/
  16. refs/
  17. sha1dc/
  18. t/
  19. templates/
  20. vcs-svn/
  21. xdiff/
  22. .clang-format
  23. .gitattributes
  24. .gitignore
  25. .gitmodules
  26. .mailmap
  27. .travis.yml
  28. .tsan-suppressions
  29. abspath.c
  30. aclocal.m4
  31. advice.c
  32. advice.h
  33. alias.c
  34. alloc.c
  35. apply.c
  36. apply.h
  37. archive-tar.c
  38. archive-zip.c
  39. archive.c
  40. archive.h
  41. argv-array.c
  42. argv-array.h
  43. attr.c
  44. attr.h
  45. base85.c
  46. bisect.c
  47. bisect.h
  48. blame.c
  49. blame.h
  50. blob.c
  51. blob.h
  52. branch.c
  53. branch.h
  54. builtin.h
  55. bulk-checkin.c
  56. bulk-checkin.h
  57. bundle.c
  58. bundle.h
  59. cache-tree.c
  60. cache-tree.h
  61. cache.h
  62. check-builtins.sh
  63. check-racy.c
  64. check_bindir
  65. color.c
  66. color.h
  67. column.c
  68. column.h
  69. combine-diff.c
  70. command-list.txt
  71. commit-slab.h
  72. commit.c
  73. commit.h
  74. common-main.c
  75. config.c
  76. config.h
  77. config.mak.in
  78. config.mak.uname
  79. configure.ac
  80. connect.c
  81. connect.h
  82. connected.c
  83. connected.h
  84. convert.c
  85. convert.h
  86. copy.c
  87. COPYING
  88. credential-cache--daemon.c
  89. credential-cache.c
  90. credential-store.c
  91. credential.c
  92. credential.h
  93. csum-file.c
  94. csum-file.h
  95. ctype.c
  96. daemon.c
  97. date.c
  98. decorate.c
  99. decorate.h
  100. delta.h
  101. diff-delta.c
  102. diff-lib.c
  103. diff-no-index.c
  104. diff.c
  105. diff.h
  106. diffcore-break.c
  107. diffcore-delta.c
  108. diffcore-order.c
  109. diffcore-pickaxe.c
  110. diffcore-rename.c
  111. diffcore.h
  112. dir-iterator.c
  113. dir-iterator.h
  114. dir.c
  115. dir.h
  116. editor.c
  117. entry.c
  118. environment.c
  119. exec_cmd.c
  120. exec_cmd.h
  121. fast-import.c
  122. fetch-pack.c
  123. fetch-pack.h
  124. fmt-merge-msg.h
  125. fsck.c
  126. fsck.h
  127. generate-cmdlist.sh
  128. gettext.c
  129. gettext.h
  130. git-add--interactive.perl
  131. git-archimport.perl
  132. git-bisect.sh
  133. git-compat-util.h
  134. git-cvsexportcommit.perl
  135. git-cvsimport.perl
  136. git-cvsserver.perl
  137. git-difftool--helper.sh
  138. git-filter-branch.sh
  139. git-instaweb.sh
  140. git-merge-octopus.sh
  141. git-merge-one-file.sh
  142. git-merge-resolve.sh
  143. git-mergetool--lib.sh
  144. git-mergetool.sh
  145. git-p4.py
  146. git-parse-remote.sh
  147. git-quiltimport.sh
  148. git-rebase--am.sh
  149. git-rebase--interactive.sh
  150. git-rebase--merge.sh
  151. git-rebase.sh
  152. git-remote-testgit.sh
  153. git-request-pull.sh
  154. git-send-email.perl
  155. git-sh-i18n.sh
  156. git-sh-setup.sh
  157. git-stash.sh
  158. git-submodule.sh
  159. git-svn.perl
  160. GIT-VERSION-GEN
  161. git-web--browse.sh
  162. git.c
  163. git.rc
  164. gpg-interface.c
  165. gpg-interface.h
  166. graph.c
  167. graph.h
  168. grep.c
  169. grep.h
  170. hash.h
  171. hashmap.c
  172. hashmap.h
  173. help.c
  174. help.h
  175. hex.c
  176. http-backend.c
  177. http-fetch.c
  178. http-push.c
  179. http-walker.c
  180. http.c
  181. http.h
  182. ident.c
  183. imap-send.c
  184. INSTALL
  185. iterator.h
  186. khash.h
  187. kwset.c
  188. kwset.h
  189. levenshtein.c
  190. levenshtein.h
  191. LGPL-2.1
  192. line-log.c
  193. line-log.h
  194. line-range.c
  195. line-range.h
  196. list-objects.c
  197. list-objects.h
  198. list.h
  199. ll-merge.c
  200. ll-merge.h
  201. lockfile.c
  202. lockfile.h
  203. log-tree.c
  204. log-tree.h
  205. mailinfo.c
  206. mailinfo.h
  207. mailmap.c
  208. mailmap.h
  209. Makefile
  210. match-trees.c
  211. merge-blobs.c
  212. merge-blobs.h
  213. merge-recursive.c
  214. merge-recursive.h
  215. merge.c
  216. mergesort.c
  217. mergesort.h
  218. mru.c
  219. mru.h
  220. name-hash.c
  221. notes-cache.c
  222. notes-cache.h
  223. notes-merge.c
  224. notes-merge.h
  225. notes-utils.c
  226. notes-utils.h
  227. notes.c
  228. notes.h
  229. object.c
  230. object.h
  231. oidmap.c
  232. oidmap.h
  233. oidset.c
  234. oidset.h
  235. pack-bitmap-write.c
  236. pack-bitmap.c
  237. pack-bitmap.h
  238. pack-check.c
  239. pack-objects.c
  240. pack-objects.h
  241. pack-revindex.c
  242. pack-revindex.h
  243. pack-write.c
  244. pack.h
  245. packfile.c
  246. packfile.h
  247. pager.c
  248. parse-options-cb.c
  249. parse-options.c
  250. parse-options.h
  251. patch-delta.c
  252. patch-ids.c
  253. patch-ids.h
  254. path.c
  255. path.h
  256. pathspec.c
  257. pathspec.h
  258. pkt-line.c
  259. pkt-line.h
  260. preload-index.c
  261. pretty.c
  262. prio-queue.c
  263. prio-queue.h
  264. progress.c
  265. progress.h
  266. prompt.c
  267. prompt.h
  268. quote.c
  269. quote.h
  270. reachable.c
  271. reachable.h
  272. read-cache.c
  273. README.md
  274. ref-filter.c
  275. ref-filter.h
  276. reflog-walk.c
  277. reflog-walk.h
  278. refs.c
  279. refs.h
  280. remote-curl.c
  281. remote-testsvn.c
  282. remote.c
  283. remote.h
  284. replace_object.c
  285. repository.c
  286. repository.h
  287. rerere.c
  288. rerere.h
  289. resolve-undo.c
  290. resolve-undo.h
  291. revision.c
  292. revision.h
  293. run-command.c
  294. run-command.h
  295. send-pack.c
  296. send-pack.h
  297. sequencer.c
  298. sequencer.h
  299. server-info.c
  300. setup.c
  301. sh-i18n--envsubst.c
  302. sha1-array.c
  303. sha1-array.h
  304. sha1-lookup.c
  305. sha1-lookup.h
  306. sha1_file.c
  307. sha1_name.c
  308. sha1dc_git.c
  309. sha1dc_git.h
  310. shallow.c
  311. shell.c
  312. shortlog.h
  313. show-index.c
  314. sideband.c
  315. sideband.h
  316. sigchain.c
  317. sigchain.h
  318. split-index.c
  319. split-index.h
  320. strbuf.c
  321. strbuf.h
  322. streaming.c
  323. streaming.h
  324. string-list.c
  325. string-list.h
  326. sub-process.c
  327. sub-process.h
  328. submodule-config.c
  329. submodule-config.h
  330. submodule.c
  331. submodule.h
  332. symlinks.c
  333. tag.c
  334. tag.h
  335. tar.h
  336. tempfile.c
  337. tempfile.h
  338. thread-utils.c
  339. thread-utils.h
  340. tmp-objdir.c
  341. tmp-objdir.h
  342. trace.c
  343. trace.h
  344. trailer.c
  345. trailer.h
  346. transport-helper.c
  347. transport.c
  348. transport.h
  349. tree-diff.c
  350. tree-walk.c
  351. tree-walk.h
  352. tree.c
  353. tree.h
  354. unicode_width.h
  355. unimplemented.sh
  356. unix-socket.c
  357. unix-socket.h
  358. unpack-trees.c
  359. unpack-trees.h
  360. upload-pack.c
  361. url.c
  362. url.h
  363. urlmatch.c
  364. urlmatch.h
  365. usage.c
  366. userdiff.c
  367. userdiff.h
  368. utf8.c
  369. utf8.h
  370. varint.c
  371. varint.h
  372. version.c
  373. version.h
  374. versioncmp.c
  375. walker.c
  376. walker.h
  377. wildmatch.c
  378. wildmatch.h
  379. worktree.c
  380. worktree.h
  381. wrap-for-bin.sh
  382. wrapper.c
  383. write_or_die.c
  384. ws.c
  385. wt-status.c
  386. wt-status.h
  387. xdiff-interface.c
  388. xdiff-interface.h
  389. zlib.c
README.md

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks