write_entry: untangle symlink and regular-file cases

The write_entry() function switches on the mode of the entry
we're going to write out. The cases for S_IFLNK and S_IFREG
are lumped together. In earlier versions of the code, this
made some sense. They have a shared preamble (which reads
the blob content), a short type-specific body, and a shared
conclusion (which writes out the file contents; always for
S_IFREG and only sometimes for S_IFLNK).

But over time this has grown to make less sense. The preamble
now has conditional bits for each type, and the S_IFREG body
has grown a lot more complicated. It's hard to follow the
logic of which code is running for which mode.

Let's give each mode its own case arm. We will still share
the conclusion code, which means we now jump to it with a
goto. Ideally we'd pull that shared code into its own
function, but it touches so much internal state in the
write_entry() function that the end result is actually
harder to follow than the goto.

While we're here, we'll touch up a few bits of whitespace to
make the beginning and endings of the cases easier to read.

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