apply: move lockfile into `apply_state`

We have two users of `struct apply_state` and the related functionality
in apply.c. Each user sets up its `apply_state` by handing over a
pointer to its static `lock_file`. (Before 076aa2cbd (tempfile:
auto-allocate tempfiles on heap, 2017-09-05), we could never free
lockfiles, so making them static was a reasonable approach.)

Other than that, they never directly access their `lock_file`s, which
are instead handled by the functionality in apply.c.

To make life easier for the caller and to make it less tempting for a
future caller to mess with the lock, make apply.c fully responsible for
setting up the `lock_file`. As mentioned above, it is now safe to free a
`lock_file`, so we can make the `struct apply_state` contain an actual
`struct lock_file` instead of a pointer to one.

The user in builtin/apply.c is rather simple. For builtin/am.c, we might
worry that the lock state is actually meant to be inherited across
calls. But the lock is only taken as `apply_all_patches()` executes, and
code inspection shows that it will always be released.

Alternatively, we can observe that the lock itself is never queried
directly. When we decide whether we should lock, we check a related
variable `newfd`. That variable is not inherited, so from the point of
view of apply.c, the state machine really is reset with each call to
`init_apply_state()`. (It would be a bug if `newfd` and the lock status
were not in sync. The duplication of information in `newfd` and the lock
will be addressed in the next patch.)

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 files changed
tree: 7eca9465676f0f7289ea492f92f69f2a028cc908
  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. oidset.c
  232. oidset.h
  233. pack-bitmap-write.c
  234. pack-bitmap.c
  235. pack-bitmap.h
  236. pack-check.c
  237. pack-objects.c
  238. pack-objects.h
  239. pack-revindex.c
  240. pack-revindex.h
  241. pack-write.c
  242. pack.h
  243. packfile.c
  244. packfile.h
  245. pager.c
  246. parse-options-cb.c
  247. parse-options.c
  248. parse-options.h
  249. patch-delta.c
  250. patch-ids.c
  251. patch-ids.h
  252. path.c
  253. path.h
  254. pathspec.c
  255. pathspec.h
  256. pkt-line.c
  257. pkt-line.h
  258. preload-index.c
  259. pretty.c
  260. prio-queue.c
  261. prio-queue.h
  262. progress.c
  263. progress.h
  264. prompt.c
  265. prompt.h
  266. quote.c
  267. quote.h
  268. reachable.c
  269. reachable.h
  270. read-cache.c
  271. README.md
  272. ref-filter.c
  273. ref-filter.h
  274. reflog-walk.c
  275. reflog-walk.h
  276. refs.c
  277. refs.h
  278. remote-curl.c
  279. remote-testsvn.c
  280. remote.c
  281. remote.h
  282. replace_object.c
  283. repository.c
  284. repository.h
  285. rerere.c
  286. rerere.h
  287. resolve-undo.c
  288. resolve-undo.h
  289. revision.c
  290. revision.h
  291. run-command.c
  292. run-command.h
  293. send-pack.c
  294. send-pack.h
  295. sequencer.c
  296. sequencer.h
  297. server-info.c
  298. setup.c
  299. sh-i18n--envsubst.c
  300. sha1-array.c
  301. sha1-array.h
  302. sha1-lookup.c
  303. sha1-lookup.h
  304. sha1_file.c
  305. sha1_name.c
  306. sha1dc_git.c
  307. sha1dc_git.h
  308. shallow.c
  309. shell.c
  310. shortlog.h
  311. show-index.c
  312. sideband.c
  313. sideband.h
  314. sigchain.c
  315. sigchain.h
  316. split-index.c
  317. split-index.h
  318. strbuf.c
  319. strbuf.h
  320. streaming.c
  321. streaming.h
  322. string-list.c
  323. string-list.h
  324. sub-process.c
  325. sub-process.h
  326. submodule-config.c
  327. submodule-config.h
  328. submodule.c
  329. submodule.h
  330. symlinks.c
  331. tag.c
  332. tag.h
  333. tar.h
  334. tempfile.c
  335. tempfile.h
  336. thread-utils.c
  337. thread-utils.h
  338. tmp-objdir.c
  339. tmp-objdir.h
  340. trace.c
  341. trace.h
  342. trailer.c
  343. trailer.h
  344. transport-helper.c
  345. transport.c
  346. transport.h
  347. tree-diff.c
  348. tree-walk.c
  349. tree-walk.h
  350. tree.c
  351. tree.h
  352. unicode_width.h
  353. unimplemented.sh
  354. unix-socket.c
  355. unix-socket.h
  356. unpack-trees.c
  357. unpack-trees.h
  358. upload-pack.c
  359. url.c
  360. url.h
  361. urlmatch.c
  362. urlmatch.h
  363. usage.c
  364. userdiff.c
  365. userdiff.h
  366. utf8.c
  367. utf8.h
  368. varint.c
  369. varint.h
  370. version.c
  371. version.h
  372. versioncmp.c
  373. walker.c
  374. walker.h
  375. wildmatch.c
  376. wildmatch.h
  377. worktree.c
  378. worktree.h
  379. wrap-for-bin.sh
  380. wrapper.c
  381. write_or_die.c
  382. ws.c
  383. wt-status.c
  384. wt-status.h
  385. xdiff-interface.c
  386. xdiff-interface.h
  387. 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