diff: plug memory leak from regcomp() on {log,diff} -I

Fix a memory leak in 296d4a94e7 (diff: add -I<regex> that ignores
matching changes, 2020-10-20) by freeing the memory it allocates in
the newly introduced diff_free(). See the previous commit for details
on that.

This memory leak was intentionally introduced in 296d4a94e7, see the
discussion on a previous iteration of it in
https://lore.kernel.org/git/xmqqeelycajx.fsf@gitster.c.googlers.com/

At that time freeing the memory was somewhat tedious, but since it
isn't anymore with the newly introduced diff_free() let's use it.

Let's retain the pattern for diff_free_file() and add a
diff_free_ignore_regex(), even though (unlike "diff_free_file") we
don't need to call it elsewhere. I think this'll make for more
readable code than gradually accumulating a giant diff_free()
function, sharing "int i" across unrelated code etc.

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