send-pack: check remote ref status on pack-objects failure

When we're pushing a pack and our local pack-objects fails, we enter an
error code path that does a few things:

  1. Set the status of every ref to REF_STATUS_NONE

  2. Call receive_unpack_status() to try to get an error report from
     the other side

  3. Return an error to the caller

If pack-objects failed because the connection to the server dropped,
there's not much more we can do than report the hangup. And indeed, step
2 will try to read a packet from the other side, which will die() in the
packet-reading code with "the remote end hung up unexpectedly".

But if the connection _didn't_ die, then the most common issue is that
the remote index-pack or unpack-objects complained about our pack (we
could also have a local pack-objects error, but this ends up being the
same; we'd send an incomplete pack and the remote side would complain).

In that case we do report the error from the other side (because of step
2), but we fail to say anything further about the refs. The issue is
two-fold:

  - in step 1, the "NONE" status is not "we saw an error, so we have no
    status". It generally means "this ref did not match our refspecs, so
    we didn't try to push it". So when we print out the push status
    table, we won't mention any refs at all!

    But even if we had a status enum for "pack-objects error", we
    wouldn't want to blindly set it for every ref. For example, in a
    non-atomic push we might have rejected some refs already on the
    client side (e.g., REF_STATUS_REJECT_NODELETE) and we'd want to
    report that.

  - in step 2, we read just the unpack status. But receive-pack will
    also tell us about each ref (usually that it rejected them because
    of the unpacker error).

So a much better strategy is to leave the ref status fields as they are
(usually EXPECTING_REPORT) and then actually receive (and print) the
full per-ref status.

This case is actually covered in the test suite, as t5504.8, which
writes a pack that will be rejected by the remote unpack-objects. But
it's racy. Because our pack is small, most of the time pack-objects
manages to write the whole thing before the remote rejects it, and so it
returns success and we print out the errors from the remote. But very
occasionally (or when run under --stress) it goes slow enough to see a
failure in writing, and git-push reports nothing for the refs.

With this patch, the test should behave consistently.

There shouldn't be any downside to this approach. If we really did see
the connection drop, we'd already die in receive_unpack_status(), and
we'll continue to do so. If the connection drops _after_ we get the
unpack status but before we see any ref status, we'll still print the
remote unpacker error, but will now say "remote end hung up" instead of
returning the error up the call-stack. But as discussed, we weren't
showing anything more useful than that with the current code. And
anyway, that case is quite unlikely (the connection dropping at that
point would have to be unrelated to the pack-objects error, because of
the ordering of events).

In the future we might want to handle packet-read errors ourself instead
of dying, which would print a full ref status table even for hangups.
But in the meantime, this patch should be a strict improvement.

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

Build Status

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-<commandname>.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.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

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