lock_ref_for_update(): don't resolve symrefs

If a transaction includes a non-NODEREF update to a symbolic reference,
we don't have to look it up in lock_ref_for_update(). The reference will
be dereferenced anyway when the split-off update is processed.

This change requires that we store a backpointer from the split-off
update to its parent update, for two reasons:

* We still want to report the original reference name in error messages.
  So if an error occurs when checking the split-off update's old_sha1,
  walk the parent_update pointers back to find the original reference
  name, and report that one.

* We still need to write the old_sha1 of the symref to its reflog. So
  after we read the split-off update's reference value, walk the
  parent_update pointers back and fill in their old_sha1 fields.

Aside from eliminating unnecessary reads, this change fixes a
subtle (though not very serious) race condition: in the old code, the
old_sha1 of the symref was resolved before the reference that it pointed
at was locked. So it was possible that the old_sha1 value logged to the
symref's reflog could be wrong if another process changed the downstream
reference before it was locked.

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