read-cache: fix an -Wmaybe-uninitialized warning

The function ce_write_entry() uses a 'self-initialised' variable
construct, for the symbol 'saved_namelen', to suppress a gcc
'-Wmaybe-uninitialized' warning, given that the warning is a false
positive.

For the purposes of this discussion, the ce_write_entry() function has
three code blocks of interest, that look like so:

        /* block #1 */
        if (ce->ce_flags & CE_STRIP_NAME) {
                saved_namelen = ce_namelen(ce);
                ce->ce_namelen = 0;
        }

        /* block #2 */
        /*
	 * several code blocks that contain, among others, calls
         * to copy_cache_entry_to_ondisk(ondisk, ce);
         */

        /* block #3 */
        if (ce->ce_flags & CE_STRIP_NAME) {
                ce->ce_namelen = saved_namelen;
                ce->ce_flags &= ~CE_STRIP_NAME;
        }

The warning implies that gcc thinks it is possible that the first
block is not entered, the calls to copy_cache_entry_to_ondisk()
could toggle the CE_STRIP_NAME flag on, thereby entering block #3
with saved_namelen unset. However, the copy_cache_entry_to_ondisk()
function does not write to ce->ce_flags (it only reads). gcc could
easily determine this, since that function is local to this file,
but it obviously doesn't.

In order to suppress this warning, we make it clear to the reader
(human and compiler), that block #3 will only be entered when the
first block has been entered, by introducing a new 'stripped_name'
boolean variable. We also take the opportunity to change the type
of 'saved_namelen' to 'unsigned int' to match ce->ce_namelen.

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