]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
8 months agobundle-uri: plug leak in unbundle_from_file()
Toon Claes [Thu, 10 Oct 2024 09:12:49 +0000 (11:12 +0200)] 
bundle-uri: plug leak in unbundle_from_file()

The function `unbundle_from_file()` has two memory leaks:

  - We do not release the `struct bundle_header header` when hitting
    errors because we return early without any cleanup.

  - We do not release the `struct strbuf bundle_ref` at all.

Plug these leaks by creating a common exit path where both of these
variables are released.

While at it, refactor the code such that the variable assignments do not
happen inside the conditional statement itself according to our coding
style.

Signed-off-by: Toon Claes <toon@iotcl.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoGit 2.47 v2.47.0
Junio C Hamano [Sun, 6 Oct 2024 22:56:06 +0000 (15:56 -0700)] 
Git 2.47

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 6 Oct 2024 18:14:12 +0000 (11:14 -0700)] 
Merge tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po

l10n-2.47.0-rnd2

* tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: Update German translation
  l10n: bg.po: Updated Bulgarian translation (5772t)
  l10n: vi: Updated translation for 2.47
  l10n: zh_TW: Git 2.47
  l10n: new lead for Catalan translation
  l10n: Update Catalan translation
  l10n: fr.po: 2.47.0
  l10n: zh_CN: updated translation for 2.47
  l10n: po-id for 2.47
  l10n: tr: Update Turkish translations for 2.47.0
  l10n: sv.po: Update Swedish translation

8 months agoMerge branch 'l10n-de-2.47' of github.com:ralfth/git
Jiang Xin [Sun, 6 Oct 2024 04:06:21 +0000 (12:06 +0800)] 
Merge branch 'l10n-de-2.47' of github.com:ralfth/git

* 'l10n-de-2.47' of github.com:ralfth/git:
  l10n: Update German translation

8 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sun, 6 Oct 2024 04:04:11 +0000 (12:04 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5772t)

8 months agoMerge branch 'catalan-247' of github.com:Softcatala/git-po
Jiang Xin [Sun, 6 Oct 2024 04:03:46 +0000 (12:03 +0800)] 
Merge branch 'catalan-247' of github.com:Softcatala/git-po

* 'catalan-247' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

8 months agoMerge branch 'new-catalan-maintainer' of github.com:Softcatala/git-po
Jiang Xin [Sun, 6 Oct 2024 04:03:08 +0000 (12:03 +0800)] 
Merge branch 'new-catalan-maintainer' of github.com:Softcatala/git-po

* 'new-catalan-maintainer' of github.com:Softcatala/git-po:
  l10n: new lead for Catalan translation

8 months agoMerge branch 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po
Jiang Xin [Sun, 6 Oct 2024 03:39:29 +0000 (11:39 +0800)] 
Merge branch 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po

* 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po:
  l10n: zh_TW: Git 2.47

8 months agoMerge branch 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git
Jiang Xin [Sun, 6 Oct 2024 03:39:03 +0000 (11:39 +0800)] 
Merge branch 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git

* 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git:
  l10n: zh_CN: updated translation for 2.47

8 months agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Sun, 6 Oct 2024 03:38:15 +0000 (11:38 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation

8 months agoMerge branch 'fr_2.47.0_rnd1' of github.com:jnavila/git
Jiang Xin [Sun, 6 Oct 2024 03:37:56 +0000 (11:37 +0800)] 
Merge branch 'fr_2.47.0_rnd1' of github.com:jnavila/git

* 'fr_2.47.0_rnd1' of github.com:jnavila/git:
  l10n: fr.po: 2.47.0

8 months agoMerge branch 'vi-2.47' of github.com:Nekosha/git-po
Jiang Xin [Sun, 6 Oct 2024 03:35:59 +0000 (11:35 +0800)] 
Merge branch 'vi-2.47' of github.com:Nekosha/git-po

* 'vi-2.47' of github.com:Nekosha/git-po:
  l10n: vi: Updated translation for 2.47

8 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sun, 6 Oct 2024 03:35:06 +0000 (11:35 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.47

8 months agol10n: Update German translation
Ralf Thielow [Sat, 5 Oct 2024 17:28:19 +0000 (19:28 +0200)] 
l10n: Update German translation

Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
8 months agol10n: bg.po: Updated Bulgarian translation (5772t)
Alexander Shopov [Sat, 5 Oct 2024 11:16:48 +0000 (13:16 +0200)] 
l10n: bg.po: Updated Bulgarian translation (5772t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
8 months agol10n: vi: Updated translation for 2.47
Vũ Tiến Hưng [Thu, 26 Sep 2024 07:41:59 +0000 (14:41 +0700)] 
l10n: vi: Updated translation for 2.47

Signed-off-by: Vũ Tiến Hưng <newcomerminecraft@gmail.com>
8 months agol10n: zh_TW: Git 2.47
Yi-Jyun Pan [Sat, 5 Oct 2024 03:36:12 +0000 (11:36 +0800)] 
l10n: zh_TW: Git 2.47

Co-authored-by: Lumynous <lumynou5.tw@gmail.com>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
8 months agol10n: new lead for Catalan translation
Jordi Mas [Sat, 5 Oct 2024 07:26:43 +0000 (09:26 +0200)] 
l10n: new lead for Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
8 months agol10n: Update Catalan translation
Jordi Mas [Sat, 5 Oct 2024 07:19:18 +0000 (09:19 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
8 months agoMostly there for 2.47 final
Junio C Hamano [Fri, 4 Oct 2024 21:21:16 +0000 (14:21 -0700)] 
Mostly there for 2.47 final

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'kn/osx-fsmonitor-with-submodules-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:43 +0000 (14:21 -0700)] 
Merge branch 'kn/osx-fsmonitor-with-submodules-fix'

macOS with fsmonitor daemon can hang forever when a submodule is
involved, which has been corrected.

* kn/osx-fsmonitor-with-submodules-fix:
  fsmonitor OSX: fix hangs for submodules

8 months agoMerge branch 'ak/doc-typofix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:43 +0000 (14:21 -0700)] 
Merge branch 'ak/doc-typofix'

Typofixes.

* ak/doc-typofix:
  Documentation: fix typos
  Documentation/config: fix typos

8 months agoMerge branch 'tb/weak-sha1-for-tail-sum'
Junio C Hamano [Fri, 4 Oct 2024 21:21:42 +0000 (14:21 -0700)] 
Merge branch 'tb/weak-sha1-for-tail-sum'

Build fix.

* tb/weak-sha1-for-tail-sum:
  hash.h: set NEEDS_CLONE_HELPER_UNSAFE in fallback mode

8 months agoMerge branch 'ps/reftable-concurrent-writes'
Junio C Hamano [Fri, 4 Oct 2024 21:21:41 +0000 (14:21 -0700)] 
Merge branch 'ps/reftable-concurrent-writes'

Test fix.

* ps/reftable-concurrent-writes:
  t0610: work around flaky test with concurrent writers

8 months agoMerge branch 'mh/w-unused-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:41 +0000 (14:21 -0700)] 
Merge branch 'mh/w-unused-fix'

Buildfix.

* mh/w-unused-fix:
  utf8.h: squelch unused-parameter warnings with NO_ICONV

8 months agoMerge branch 'rs/archive-with-attr-pathspec-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:40 +0000 (14:21 -0700)] 
Merge branch 'rs/archive-with-attr-pathspec-fix'

Message update.

* rs/archive-with-attr-pathspec-fix:
  archive: fix misleading error message

8 months agoMerge branch 'ak/typofix-2.46-maint'
Junio C Hamano [Fri, 4 Oct 2024 21:21:40 +0000 (14:21 -0700)] 
Merge branch 'ak/typofix-2.46-maint'

Typofixes.

* ak/typofix-2.46-maint:
  perl: fix a typo
  mergetool: fix a typo
  reftable: fix a typo
  trace2: fix typos

8 months agol10n: fr.po: 2.47.0
Jean-Noël Avila [Fri, 27 Sep 2024 20:05:44 +0000 (22:05 +0200)] 
l10n: fr.po: 2.47.0

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
8 months agol10n: zh_CN: updated translation for 2.47
Teng Long [Fri, 4 Oct 2024 18:56:55 +0000 (02:56 +0800)] 
l10n: zh_CN: updated translation for 2.47

Signed-off-by: Teng Long <dyroneteng@gmail.com>
8 months agoA bit more after 2.47-rc1
Junio C Hamano [Fri, 4 Oct 2024 17:13:51 +0000 (10:13 -0700)] 
A bit more after 2.47-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ds/read-cache-mempool-leakfix'
Junio C Hamano [Fri, 4 Oct 2024 17:14:07 +0000 (10:14 -0700)] 
Merge branch 'ds/read-cache-mempool-leakfix'

Leakfix.

* ds/read-cache-mempool-leakfix:
  read-cache: free threaded memory pool

8 months agoMerge branch 'jc/doc-discarding-stalled-topics'
Junio C Hamano [Fri, 4 Oct 2024 17:14:06 +0000 (10:14 -0700)] 
Merge branch 'jc/doc-discarding-stalled-topics'

Document that inactive topics are subject to be discarded.

* jc/doc-discarding-stalled-topics:
  howto-maintain-git: discarding inactive topics

8 months agoMerge branch 'jk/test-lsan-improvements'
Junio C Hamano [Fri, 4 Oct 2024 17:14:06 +0000 (10:14 -0700)] 
Merge branch 'jk/test-lsan-improvements'

Usability improvements for running tests in leak-checking mode.

* jk/test-lsan-improvements:
  test-lib: check for leak logs after every test
  test-lib: show leak-sanitizer logs on --immediate failure
  test-lib: stop showing old leak logs

8 months agot0610: work around flaky test with concurrent writers
Patrick Steinhardt [Fri, 4 Oct 2024 15:32:16 +0000 (17:32 +0200)] 
t0610: work around flaky test with concurrent writers

In 6241ce2170 (refs/reftable: reload locked stack when preparing
transaction, 2024-09-24) we have introduced a new test that exercises
how the reftable backend behaves with many concurrent writers all racing
with each other. This test was introduced after a couple of fixes in
this context that should make concurrent writes behave gracefully. As it
turns out though, Windows systems do not yet handle concurrent writes
properly, as we've got two reports for Cygwin and MinGW failing in this
newly added test.

The root cause of this is how we update the "tables.list" file: when
writing a new stack of tables we first write the data into a lockfile
and then rename that file into place. But Windows forbids us from doing
that rename when the target path is open for reading by another process.
And as the test races both readers and writers with each other we are
quite likely to hit this edge case.

This is not a regression: the logic didn't work before the mentioned
commit, and after the commit it performs well on Linux and macOS, and
the situation on Windows should have at least improved a bit. But the
test shows that we need to put more thought into how to make this work
properly there.

Work around the issue by disabling the test on Windows for now. While at
it, increase the locking timeout to address reported timeouts when using
either the address or memory sanitizer, which also tend to significantly
extend the runtime of this test.

This should be revisited after Git v2.47 is out.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofsmonitor OSX: fix hangs for submodules
Koji Nakamaru [Fri, 4 Oct 2024 00:07:13 +0000 (00:07 +0000)] 
fsmonitor OSX: fix hangs for submodules

fsmonitor_classify_path_absolute() expects state->path_gitdir_watch.buf
has no trailing '/' or '.' For a submodule, fsmonitor_run_daemon() sets
the value with trailing "/." (as repo_get_git_dir(the_repository) on
Darwin returns ".") so that fsmonitor_classify_path_absolute() returns
IS_OUTSIDE_CONE.

In this case, fsevent_callback() doesn't update cookie_list so that
fsmonitor_publish() does nothing and with_lock__mark_cookies_seen() is
not invoked.

As with_lock__wait_for_cookie() infinitely waits for state->cookies_cond
that with_lock__mark_cookies_seen() should unlock, the whole daemon
hangs.

Remove trailing "/." from state->path_gitdir_watch.buf for submodules
and add a corresponding test in t7527-builtin-fsmonitor.sh. The test is
disabled for MINGW because hangs treated with this patch occur only for
Darwin and there is no simple way to terminate the win32 fsmonitor
daemon that hangs.

Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agol10n: po-id for 2.47
Bagas Sanjaya [Tue, 24 Sep 2024 02:52:25 +0000 (09:52 +0700)] 
l10n: po-id for 2.47

Update following components:

  * add-patch.c
  * apply.c
  * builtin/check-mailmap.c
  * builtin/checkout.c
  * builtin/commit.c
  * builtin/config.c
  * builtin/fetch.c
  * builtin/gc.c
  * builtin/multi-pack-index.c
  * builtin/refs.c
  * builtin/show-refs.c
  * builtin/sparse-checkout.c
  * builtin/submodule--helper.c
  * loose.c
  * midx-write.c
  * midx.c
  * object-file.c
  * ref-filter.c
  * refs/file-backend.c
  * scalar.c
  * setup.c
  * git-send-email.perl

Translate following new components:

  * t/unit-tests/unit-tests.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
8 months agoperl: fix a typo
Andrew Kreimer [Wed, 2 Oct 2024 22:38:16 +0000 (01:38 +0300)] 
perl: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agomergetool: fix a typo
Andrew Kreimer [Wed, 2 Oct 2024 22:38:14 +0000 (01:38 +0300)] 
mergetool: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoreftable: fix a typo
Andrew Kreimer [Wed, 2 Oct 2024 22:38:13 +0000 (01:38 +0300)] 
reftable: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotrace2: fix typos
Andrew Kreimer [Wed, 2 Oct 2024 22:38:12 +0000 (01:38 +0300)] 
trace2: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agohash.h: set NEEDS_CLONE_HELPER_UNSAFE in fallback mode
Jeff King [Wed, 2 Oct 2024 23:26:18 +0000 (19:26 -0400)] 
hash.h: set NEEDS_CLONE_HELPER_UNSAFE in fallback mode

Commit 253ed9ecff (hash.h: scaffolding for _unsafe hashing variants,
2024-09-26) introduced the concept of having two hash algorithms: a safe
and an unsafe one. When the Makefile knobs do not explicitly request an
unsafe one, we fall back to using the safe algorithm.

However, the fallback to do so forgot one case: we should inherit the
NEEDS_CLONE_HELPER flag from the safe variant. Failing to do so means
that we'll end up defining two clone functions (the algorithm specific
one, and the generic one that just calls memcpy). You'll see an error
like this:

  $ make OPENSSL_SHA1=1
  [...]
  sha1/openssl.h:46:29: error: redefinition of ‘openssl_SHA1_Clone’
     46 | #define platform_SHA1_Clone openssl_SHA1_Clone
        |                             ^~~~~~~~~~~~~~~~~~
  hash.h:83:40: note: in expansion of macro ‘platform_SHA1_Clone’
     83 | #    define platform_SHA1_Clone_unsafe platform_SHA1_Clone
        |                                        ^~~~~~~~~~~~~~~~~~~
  hash.h:101:33: note: in expansion of macro ‘platform_SHA1_Clone_unsafe’
    101 | #  define git_SHA1_Clone_unsafe platform_SHA1_Clone_unsafe
        |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
  hash.h:133:20: note: in expansion of macro ‘git_SHA1_Clone_unsafe’
    133 | static inline void git_SHA1_Clone_unsafe(git_SHA_CTX_unsafe *dst,
        |                    ^~~~~~~~~~~~~~~~~~~~~
  sha1/openssl.h:37:20: note: previous definition of ‘openssl_SHA1_Clone’ with type ‘void(struct openssl_SHA1_CTX *, const struct openssl_SHA1_CTX *)’
     37 | static inline void openssl_SHA1_Clone(struct openssl_SHA1_CTX *dst,
        |                    ^~~~~~~~~~~~~~~~~~

This only matters when compiling with openssl as the "safe" variant,
since it's the only algorithm that requires a clone helper (and even
then, only if you are using openssl 3.0+). And you should never do that,
because it's not safe. But still, the invocation above used to work and
should continue to do so until we decide to require a
collision-detecting variant for the safe algorithm entirely.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoarchive: fix misleading error message
René Scharfe [Thu, 3 Oct 2024 15:51:01 +0000 (17:51 +0200)] 
archive: fix misleading error message

The error message added by 296743a7ca (archive: load index before
pathspec checks, 2024-09-21) is misleading: unpack_trees() is not
touching the working tree at all here, but just loading a tree into
the index.  Correct it.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agol10n: tr: Update Turkish translations for 2.47.0
Emir SARI [Tue, 24 Sep 2024 06:55:47 +0000 (09:55 +0300)] 
l10n: tr: Update Turkish translations for 2.47.0

Signed-off-by: Emir SARI <emir_sari@icloud.com>
8 months agoutf8.h: squelch unused-parameter warnings with NO_ICONV
Mike Hommey [Wed, 2 Oct 2024 20:01:40 +0000 (05:01 +0900)] 
utf8.h: squelch unused-parameter warnings with NO_ICONV

Since DEVELOPER=YesPlease build enables -Wunused-parameter warnings
these days, the fallback definition for reencode_string_len() that
did not touch any of its parameters but one needs to be annotated
properly.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoGit 2.47-rc1 v2.47.0-rc1
Junio C Hamano [Wed, 2 Oct 2024 14:45:44 +0000 (07:45 -0700)] 
Git 2.47-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'tb/weak-sha1-for-tail-sum'
Junio C Hamano [Wed, 2 Oct 2024 14:46:27 +0000 (07:46 -0700)] 
Merge branch 'tb/weak-sha1-for-tail-sum'

The checksum at the tail of files are now computed without
collision detection protection.  This is safe as the consumer of
the information to protect itself from replay attacks checks for
hash collisions independently.

* tb/weak-sha1-for-tail-sum:
  csum-file.c: use unsafe SHA-1 implementation when available
  Makefile: allow specifying a SHA-1 for non-cryptographic uses
  hash.h: scaffolding for _unsafe hashing variants
  sha1: do not redefine `platform_SHA_CTX` and friends
  pack-objects: use finalize_object_file() to rename pack/idx/etc
  finalize_object_file(): implement collision check
  finalize_object_file(): refactor unlink_or_warn() placement
  finalize_object_file(): check for name collision before renaming

8 months agoMerge branch 'jk/http-leakfixes'
Junio C Hamano [Wed, 2 Oct 2024 14:46:26 +0000 (07:46 -0700)] 
Merge branch 'jk/http-leakfixes'

Leakfixes.

* jk/http-leakfixes: (28 commits)
  http-push: clean up local_refs at exit
  http-push: clean up loose request when falling back to packed
  http-push: clean up objects list
  http-push: free xml_ctx.cdata after use
  http-push: free remote_ls_ctx.dentry_name
  http-push: free transfer_request strbuf
  http-push: free transfer_request dest field
  http-push: free curl header lists
  http-push: free repo->url string
  http-push: clear refspecs before exiting
  http-walker: free fake packed_git list
  remote-curl: free HEAD ref with free_one_ref()
  http: stop leaking buffer in http_get_info_packs()
  http: call git_inflate_end() when releasing http_object_request
  http: fix leak of http_object_request struct
  http: fix leak when redacting cookies from curl trace
  transport-helper: fix leak of dummy refs_list
  fetch-pack: clear pack lockfiles list
  fetch: free "raw" string when shrinking refspec
  transport-helper: fix strbuf leak in push_refs_with_push()
  ...

8 months agoMerge branch 'ps/leakfixes-part-7'
Junio C Hamano [Wed, 2 Oct 2024 14:46:25 +0000 (07:46 -0700)] 
Merge branch 'ps/leakfixes-part-7'

More leak-fixes.

* ps/leakfixes-part-7: (23 commits)
  diffcore-break: fix leaking filespecs when merging broken pairs
  revision: fix leaking parents when simplifying commits
  builtin/maintenance: fix leak in `get_schedule_cmd()`
  builtin/maintenance: fix leaking config string
  promisor-remote: fix leaking partial clone filter
  grep: fix leaking grep pattern
  submodule: fix leaking submodule ODB paths
  trace2: destroy context stored in thread-local storage
  builtin/difftool: plug several trivial memory leaks
  builtin/repack: fix leaking configuration
  diffcore-order: fix leaking buffer when parsing orderfiles
  parse-options: free previous value of `OPTION_FILENAME`
  diff: fix leaking orderfile option
  builtin/pull: fix leaking "ff" option
  dir: fix off by one errors for ignored and untracked entries
  builtin/submodule--helper: fix leaking remote ref on errors
  t/helper: fix leaking subrepo in nested submodule config helper
  builtin/submodule--helper: fix leaking error buffer
  builtin/submodule--helper: clear child process when not running it
  submodule: fix leaking update strategy
  ...

8 months agoMerge branch 'ds/sparse-checkout-expansion-advice'
Junio C Hamano [Wed, 2 Oct 2024 14:46:24 +0000 (07:46 -0700)] 
Merge branch 'ds/sparse-checkout-expansion-advice'

When "git sparse-checkout disable" turns a sparse checkout into a
regular checkout, the index is fully expanded.  This totally
expected behaviour however had an "oops, we are expanding the
index" advice message, which has been corrected.

* ds/sparse-checkout-expansion-advice:
  sparse-checkout: disable advice in 'disable'

8 months agoread-cache: free threaded memory pool
Derrick Stolee [Tue, 1 Oct 2024 17:37:44 +0000 (17:37 +0000)] 
read-cache: free threaded memory pool

In load_cache_entries_threaded(), each thread allocates its own memory
pool. This pool needs to be cleaned up while closing the threads down,
or it will be leaked.

This ce_mem_pool pointer could theoretically be converted to an inline
copy of the struct, but the use of a pointer helps with existing lazy-
initialization logic. Adjusting that behavior only to avoid this pointer
would be a much bigger change.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoanother batch after 2.47-rc0
Junio C Hamano [Mon, 30 Sep 2024 23:15:33 +0000 (16:15 -0700)] 
another batch after 2.47-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ps/includeif-onbranch-cornercase-fix'
Junio C Hamano [Mon, 30 Sep 2024 23:16:17 +0000 (16:16 -0700)] 
Merge branch 'ps/includeif-onbranch-cornercase-fix'

"git --git-dir=nowhere cmd" failed to properly notice that it
wasn't in any repository while processing includeIf.onbranch
configuration and instead crashed.

* ps/includeif-onbranch-cornercase-fix:
  config: fix evaluating "onbranch" with nonexistent git dir
  t1305: exercise edge cases of "onbranch" includes

8 months agoMerge branch 'ds/background-maintenance-with-credential'
Junio C Hamano [Mon, 30 Sep 2024 23:16:16 +0000 (16:16 -0700)] 
Merge branch 'ds/background-maintenance-with-credential'

Background tasks "git maintenance" runs may need to use credential
information when going over the network, but a credential helper
may work only in an interactive environment, and end up blocking a
scheduled task waiting for UI.  Credential helpers can now behave
differently when they are not running interactively.

* ds/background-maintenance-with-credential:
  scalar: configure maintenance during 'reconfigure'
  maintenance: add custom config to background jobs
  credential: add new interactive config option

8 months agoMerge branch 'rs/archive-with-attr-pathspec-fix'
Junio C Hamano [Mon, 30 Sep 2024 23:16:15 +0000 (16:16 -0700)] 
Merge branch 'rs/archive-with-attr-pathspec-fix'

"git archive" with pathspec magic that uses the attribute
information did not work well, which has been corrected.

* rs/archive-with-attr-pathspec-fix:
  archive: load index before pathspec checks

8 months agoMerge branch 'rs/commit-graph-ununleak'
Junio C Hamano [Mon, 30 Sep 2024 23:16:15 +0000 (16:16 -0700)] 
Merge branch 'rs/commit-graph-ununleak'

Code clean-up.

* rs/commit-graph-ununleak:
  commit-graph: remove unnecessary UNLEAK

8 months agoMerge branch 'pw/submodule-process-sigpipe'
Junio C Hamano [Mon, 30 Sep 2024 23:16:14 +0000 (16:16 -0700)] 
Merge branch 'pw/submodule-process-sigpipe'

When a subprocess to work in a submodule spawned by "git submodule"
fails with SIGPIPE, the parent Git process caught the death of it,
but gave a generic "failed to work in that submodule", which was
misleading.  We now behave as if the parent got SIGPIPE and die.

* pw/submodule-process-sigpipe:
  submodule status: propagate SIGPIPE

8 months agoMerge branch 'ps/reftable-concurrent-writes'
Junio C Hamano [Mon, 30 Sep 2024 23:16:14 +0000 (16:16 -0700)] 
Merge branch 'ps/reftable-concurrent-writes'

Give timeout to the locking code to write to reftable.

* ps/reftable-concurrent-writes:
  refs/reftable: reload locked stack when preparing transaction
  reftable/stack: allow locking of outdated stacks
  refs/reftable: introduce "reftable.lockTimeout"

8 months agol10n: sv.po: Update Swedish translation
Peter Krefting [Sat, 28 Sep 2024 14:45:19 +0000 (15:45 +0100)] 
l10n: sv.po: Update Swedish translation

Also fix issue reported by Anders Jonsson
<anders.jonsson@norsjovallen.se>.

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
8 months agocsum-file.c: use unsafe SHA-1 implementation when available
Taylor Blau [Thu, 26 Sep 2024 15:22:53 +0000 (11:22 -0400)] 
csum-file.c: use unsafe SHA-1 implementation when available

Update hashwrite() and friends to use the unsafe_-variants of hashing
functions, calling for e.g., "the_hash_algo->unsafe_update_fn()" instead
of "the_hash_algo->update_fn()".

These callers only use the_hash_algo to produce a checksum, which we
depend on for data integrity, but not for cryptographic purposes, so
these callers are safe to use the unsafe (non-collision detecting) SHA-1
implementation.

To time this, I took a freshly packed copy of linux.git, and ran the
following with and without the OPENSSL_SHA1_UNSAFE=1 build-knob. Both
versions were compiled with -O3:

    $ git for-each-ref --format='%(objectname)' refs/heads refs/tags >in
    $ valgrind --tool=callgrind ~/src/git/git-pack-objects \
        --revs --stdout --all-progress --use-bitmap-index <in >/dev/null

Without OPENSSL_SHA1_UNSAFE=1 (that is, using the collision-detecting
SHA-1 implementation for both cryptographic and non-cryptographic
purposes), we spend a significant amount of our instruction count in
hashwrite():

    $ callgrind_annotate --inclusive=yes | grep hashwrite | head -n1
    159,998,868,413 (79.42%)  /home/ttaylorr/src/git/csum-file.c:hashwrite [/home/ttaylorr/src/git/git-pack-objects]

, and the resulting "clone" takes 19.219 seconds of wall clock time,
18.94 seconds of user time and 0.28 seconds of system time.

Compiling with OPENSSL_SHA1_UNSAFE=1, we spend ~60% fewer instructions
in hashwrite():

    $ callgrind_annotate --inclusive=yes | grep hashwrite | head -n1
     59,164,001,176 (58.79%)  /home/ttaylorr/src/git/csum-file.c:hashwrite [/home/ttaylorr/src/git/git-pack-objects]

, and generate the resulting "clone" much faster, in only 11.597 seconds
of wall time, 11.37 seconds of user time, and 0.23 seconds of system
time, for a ~40% speed-up.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMakefile: allow specifying a SHA-1 for non-cryptographic uses
Taylor Blau [Thu, 26 Sep 2024 15:22:50 +0000 (11:22 -0400)] 
Makefile: allow specifying a SHA-1 for non-cryptographic uses

Introduce _UNSAFE variants of the OPENSSL_SHA1, BLK_SHA1, and
APPLE_COMMON_CRYPTO_SHA1 compile-time knobs which indicate which SHA-1
implementation is to be used for non-cryptographic uses.

There are a couple of small implementation notes worth mentioning:

  - There is no way to select the collision detecting SHA-1 as the
    "fast" fallback, since the fast fallback is only for
    non-cryptographic uses, and is meant to be faster than our
    collision-detecting implementation.

  - There are no similar knobs for SHA-256, since no collision attacks
    are presently known and thus no collision-detecting implementations
    actually exist.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agohash.h: scaffolding for _unsafe hashing variants
Taylor Blau [Thu, 26 Sep 2024 15:22:47 +0000 (11:22 -0400)] 
hash.h: scaffolding for _unsafe hashing variants

Git's default SHA-1 implementation is collision-detecting, which hardens
us against known SHA-1 attacks against Git objects. This makes Git
object writes safer at the expense of some speed when hashing through
the collision-detecting implementation, which is slower than
non-collision detecting alternatives.

Prepare for loading a separate "unsafe" SHA-1 implementation that can be
used for non-cryptographic purposes, like computing the checksum of
files that use the hashwrite() API.

This commit does not actually introduce any new compile-time knobs to
control which implementation is used as the unsafe SHA-1 variant, but
does add scaffolding so that the "git_hash_algo" structure has five new
function pointers which are "unsafe" variants of the five existing
hashing-related function pointers:

  - git_hash_init_fn unsafe_init_fn
  - git_hash_clone_fn unsafe_clone_fn
  - git_hash_update_fn unsafe_update_fn
  - git_hash_final_fn unsafe_final_fn
  - git_hash_final_oid_fn unsafe_final_oid_fn

The following commit will introduce compile-time knobs to specify which
SHA-1 implementation is used for non-cryptographic uses.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosha1: do not redefine `platform_SHA_CTX` and friends
Taylor Blau [Thu, 26 Sep 2024 15:22:44 +0000 (11:22 -0400)] 
sha1: do not redefine `platform_SHA_CTX` and friends

Our in-tree SHA-1 wrappers all define platform_SHA_CTX and related
macros to point at the opaque "context" type, init, update, and similar
functions for each specific implementation.

In hash.h, we use these platform_ variables to set up the function
pointers for, e.g., the_hash_algo->init_fn(), etc.

But while these header files have a header-specific macro that prevents
them declaring their structs / functions multiple times, they
unconditionally define the platform variables, making it impossible to
load multiple SHA-1 implementations at once.

As a prerequisite for loading a separate SHA-1 implementation for
non-cryptographic uses, only define the platform_ variables if they have
not already been defined.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agopack-objects: use finalize_object_file() to rename pack/idx/etc
Taylor Blau [Thu, 26 Sep 2024 15:22:41 +0000 (11:22 -0400)] 
pack-objects: use finalize_object_file() to rename pack/idx/etc

In most places that write files to the object database (even packfiles
via index-pack or fast-import), we use finalize_object_file(). This
prefers link()/unlink() over rename(), because it means we will prefer
data that is already in the repository to data that we are newly
writing.

We should do the same thing in pack-objects. Even though we don't think
of it as accepting outside data (and thus not being susceptible to
collision attacks), in theory a determined attacker could present just
the right set of objects to cause an incremental repack to generate
a pack with their desired hash.

This has some test and real-world fallout, as seen in the adjustment to
t5303 below. That test script assumes that we can "fix" corruption by
repacking into a good state, including when the pack generated by that
repack operation collides with a (corrupted) pack with the same hash.
This violates our assumption from the previous adjustments to
finalize_object_file() that if we're moving a new file over an existing
one, that since their checksums match, so too must their contents.

This makes "fixing" corruption like this a more explicit operation,
since the test (and users, who may fix real-life corruption using a
similar technique) must first move the broken contents out of the way.

Note also that we now call adjust_shared_perm() twice. We already call
adjust_shared_perm() in stage_tmp_packfiles(), and now call it again in
finalize_object_file(). This is somewhat wasteful, but cleaning up the
existing calls to adjust_shared_perm() is tricky (because sometimes
we're writing to a tmpfile, and sometimes we're writing directly into
the final destination), so let's tolerate some minor waste until we can
more carefully clean up the now-redundant calls.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofinalize_object_file(): implement collision check
Taylor Blau [Thu, 26 Sep 2024 15:22:38 +0000 (11:22 -0400)] 
finalize_object_file(): implement collision check

We've had "FIXME!!! Collision check here ?" in finalize_object_file()
since aac1794132 (Improve sha1 object file writing., 2005-05-03). That
is, when we try to write a file with the same name, we assume the
on-disk contents are the same and blindly throw away the new copy.

One of the reasons we never implemented this is because the files it
moves are all named after the cryptographic hash of their contents
(either loose objects, or packs which have their hash in the name these
days). So we are unlikely to see such a collision by accident. And even
though there are weaknesses in sha1, we assume they are mitigated by our
use of sha1dc.

So while it's a theoretical concern now, it hasn't been a priority.
However, if we start using weaker hashes for pack checksums and names,
this will become a practical concern. So in preparation, let's actually
implement a byte-for-byte collision check.

The new check will cause the write of new differing content to be a
failure, rather than a silent noop, and we'll retain the temporary file
on disk. If there's no collision present, we'll clean up the temporary
file as usual after either rename()-ing or link()-ing it into place.

Note that this may cause some extra computation when the files are in
fact identical, but this should happen rarely.

Loose objects are exempt from this check, and the collision check may be
skipped by calling the _flags variant of this function with the
FOF_SKIP_COLLISION_CHECK bit set. This is done for a couple of reasons:

  - We don't treat the hash of the loose object file's contents as a
    checksum, since the same loose object can be stored using different
    bytes on disk (e.g., when adjusting core.compression, using a
    different version of zlib, etc.).

    This is fundamentally different from cases where
    finalize_object_file() is operating over a file which uses the hash
    value as a checksum of the contents. In other words, a pair of
    identical loose objects can be stored using different bytes on disk,
    and that should not be treated as a collision.

  - We already use the path of the loose object as its hash value /
    object name, so checking for collisions at the content level doesn't
    add anything.

    Adding a content-level collision check would have to happen at a
    higher level than in finalize_object_file(), since (avoiding race
    conditions) writing an object loose which already exists in the
    repository will prevent us from even reaching finalize_object_file()
    via the object freshening code.

    There is a collision check in index-pack via its `check_collision()`
    function, but there isn't an analogous function in unpack-objects,
    which just feeds the result to write_object_file().

    So skipping the collision check here does not change for better or
    worse the hardness of loose object writes.

As a small note related to the latter bullet point above, we must teach
the tmp-objdir routines to similarly skip the content-level collision
checks when calling migrate_one() on a loose object file, which we do by
setting the FOF_SKIP_COLLISION_CHECK bit when we are inside of a loose
object shard.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofinalize_object_file(): refactor unlink_or_warn() placement
Taylor Blau [Thu, 26 Sep 2024 15:22:35 +0000 (11:22 -0400)] 
finalize_object_file(): refactor unlink_or_warn() placement

As soon as we've tried to link() a temporary object into place, we then
unlink() the tempfile immediately, whether we were successful or not.

For the success case, this is because we no longer need the old file
(it's now linked into place).

For the error case, there are two outcomes. Either we got EEXIST, in
which case we consider the collision to be a noop. Or we got a system
error, in which we case we are just cleaning up after ourselves.

Using a single line for all of these cases has some problems:

  - in the error case, our unlink() may clobber errno, which we use in
    the error message

  - for the collision case, there's a FIXME that indicates we should do
    a collision check. In preparation for implementing that, we'll need
    to actually hold on to the file.

Split these three cases into their own calls to unlink_or_warn(). This
is more verbose, but lets us do the right thing in each case.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofinalize_object_file(): check for name collision before renaming
Taylor Blau [Thu, 26 Sep 2024 15:22:32 +0000 (11:22 -0400)] 
finalize_object_file(): check for name collision before renaming

We prefer link()/unlink() to rename() for object files, with the idea
that we should prefer the data that is already on disk to what is
incoming. But we may fall back to rename() if the user has configured us
to do so, or if the filesystem seems not to support cross-directory
links. This loses the "prefer what is on disk" property.

We can mitigate this somewhat by trying to stat() the destination
filename before doing the rename. This is racy, since the object could
be created between the stat() and rename() calls. But in practice it is
expanding the definition of "what is already on disk" to be the point
that the function is called. That is enough to deal with any potential
attacks where an attacker is trying to collide hashes with what's
already in the repository.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiffcore-break: fix leaking filespecs when merging broken pairs
Patrick Steinhardt [Thu, 26 Sep 2024 11:47:08 +0000 (13:47 +0200)] 
diffcore-break: fix leaking filespecs when merging broken pairs

When merging file pairs after they have been broken up we queue a new
file pair and discard the broken-up ones. The newly-queued file pair
reuses one filespec of the broken up pairs each, where the respective
other filespec gets discarded. But we only end up freeing the filespec's
data, not the filespec itself, and thus leak memory.

Fix these leaks by using `free_filespec()` instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorevision: fix leaking parents when simplifying commits
Patrick Steinhardt [Thu, 26 Sep 2024 11:47:05 +0000 (13:47 +0200)] 
revision: fix leaking parents when simplifying commits

When simplifying commits, e.g. because they are treesame with their
parents, we unset the commit's parent pointers but never free them. Plug
the resulting memory leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/maintenance: fix leak in `get_schedule_cmd()`
Patrick Steinhardt [Thu, 26 Sep 2024 11:47:02 +0000 (13:47 +0200)] 
builtin/maintenance: fix leak in `get_schedule_cmd()`

The `get_schedule_cmd()` function allows us to override the schedule
command with a specific test command such that we can verify the
underlying logic in a platform-independent way. Its memory management is
somewhat wild though, because it basically gives up and assigns an
allocated string to the string constant output pointer. While this part
is marked with `UNLEAK()` to mask this, we also leak the local string
lists.

Rework the function such that it has a separate out parameter. If set,
we will assign it the final allocated command. Plug the other memory
leaks and create a common exit path.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/maintenance: fix leaking config string
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:59 +0000 (13:46 +0200)] 
builtin/maintenance: fix leaking config string

When parsing the maintenance strategy from config we allocate a config
string, but do not free it after parsing it. Plug this leak by instead
using `git_config_get_string_tmp()`, which does not allocate any memory.

This leak is exposed by t7900, but plugging it alone does not make the
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agopromisor-remote: fix leaking partial clone filter
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:57 +0000 (13:46 +0200)] 
promisor-remote: fix leaking partial clone filter

The partial clone filter of a promisor remote is never free'd, causing
memory leaks. Furthermore, in case multiple partial clone filters are
defined for the same remote, we'd overwrite previous values without
freeing them.

Fix these leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agogrep: fix leaking grep pattern
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:54 +0000 (13:46 +0200)] 
grep: fix leaking grep pattern

When creating a pattern via `create_grep_pat()` we allocate the pattern
member of the structure regardless of the token type. But later, when we
try to free the structure, we free the pattern member conditionally on
the token type and thus leak memory.

Plug this leak. The leak is exposed by t7814, but plugging it alone does
not make the whole test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosubmodule: fix leaking submodule ODB paths
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:48 +0000 (13:46 +0200)] 
submodule: fix leaking submodule ODB paths

In `add_submodule_odb_by_path()` we add a path into a global string
list. The list is initialized with `NODUP`, which means that we do not
pass ownership of strings to the list. But we use `xstrdup()` when we
insert a path, with the consequence that the string will never get
free'd.

Plug the leak by marking the list as `DUP`. There is only a single
callsite where we insert paths anyway, and as explained above that
callsite was mishandling the allocation.

This leak is exposed by t7814, but plugging it does not make the whole
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotrace2: destroy context stored in thread-local storage
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:45 +0000 (13:46 +0200)] 
trace2: destroy context stored in thread-local storage

Each thread may have a specific context in the trace2 subsystem that we
set up via thread-local storage. We do not set up a destructor for this
data though, which means that the context data will leak.

Plug this leak by installing a destructor. This leak is exposed by
t7814, but plugging it alone does not make the whole test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/difftool: plug several trivial memory leaks
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:43 +0000 (13:46 +0200)] 
builtin/difftool: plug several trivial memory leaks

There are several leaking data structures in git-difftool(1). Plug them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/repack: fix leaking configuration
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:40 +0000 (13:46 +0200)] 
builtin/repack: fix leaking configuration

When repacking, we assemble git-pack-objects(1) arguments both for the
"normal" pack and for the cruft pack. This configuration gets populated
with a bunch of `OPT_PASSTHRU` options that we end up passing to the
child process. These options are allocated, but never free'd.

Create a new `pack_objects_args_release()` function that releases the
memory for us and call it for both sets of options.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiffcore-order: fix leaking buffer when parsing orderfiles
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:37 +0000 (13:46 +0200)] 
diffcore-order: fix leaking buffer when parsing orderfiles

In `prepare_order()` we parse an orderfile and assign it to a global
array. In order to save on some allocations, we replace newlines with
NUL characters and then assign pointers into the allocated buffer to
that array. This can cause the buffer to be completely unreferenced
though in some cases, e.g. because the order file is empty or because we
had to use `xmemdupz()` to copy the lines instead of NUL-terminating
them.

Refactor the code to always `xmemdupz()` the strings. This is a bit
simpler, and it is rather unlikely that saving a handful of allocations
really matters. This allows us to release the string buffer and thus
plug the memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoparse-options: free previous value of `OPTION_FILENAME`
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:32 +0000 (13:46 +0200)] 
parse-options: free previous value of `OPTION_FILENAME`

The `OPTION_FILENAME` option always assigns either an allocated string
or `NULL` to the value. In case it is passed multiple times it does not
know to free the previous value though, which causes a memory leak.

Refactor the function to always free the previous value. None of the
sites where this option is used pass a string constant, so this change
is safe.

While at it, fix the argument of `fix_filename()` to be a string
constant. The only reason why it's not is because we use it as an
in-out-parameter, where the input is a constant and the output is not.
This is weird and unnecessary, as we can just return the result instead
of using the parameter for this.

This leak is being hit in t7621, but plugging it alone does not make the
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiff: fix leaking orderfile option
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:29 +0000 (13:46 +0200)] 
diff: fix leaking orderfile option

The `orderfile` diff option is being assigned via `OPT_FILENAME()`,
which assigns an allocated string to the variable. We never free it
though, causing a memory leak.

Change the type of the string to `char *` and free it to plug the leak.
This also requires us to use `xstrdup()` to assign the global config to
it in case it is set.

This leak is being hit in t7621, but plugging it alone does not make the
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/pull: fix leaking "ff" option
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:26 +0000 (13:46 +0200)] 
builtin/pull: fix leaking "ff" option

The `opt_ff` field gets populated either via `OPT_PASSTHRU` via
`config_get_ff()` or when `--rebase` is passed. So we sometimes end up
overriding the value in `opt_ff` with another value, but we do not free
the old value, causing a memory leak.

Adapt the type of the variable to be `char *` and consistently assign
allocated strings to it such that we can easily free it when it is being
overridden.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodir: fix off by one errors for ignored and untracked entries
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:24 +0000 (13:46 +0200)] 
dir: fix off by one errors for ignored and untracked entries

In `treat_directory()` we perform some logic to handle ignored and
untracked entries. When populating a directory with entries we first
save the current number of ignored/untracked entries and then populate
new entries at the end of our arrays that keep track of those entries.
When we figure out that all entries have been ignored/are untracked we
then remove this tail of entries from those vectors again. But there is
an off by one error in both paths that causes us to not free the first
ignored and untracked entries, respectively.

Fix these off-by-one errors to plug the resulting leak. While at it,
massage the code a bit to match our modern code style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/submodule--helper: fix leaking remote ref on errors
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:21 +0000 (13:46 +0200)] 
builtin/submodule--helper: fix leaking remote ref on errors

When `update_submodule()` fails we return with `die_message()`, which
only causes us to print the same message as `die()` would without
actually causing the process to die. We don't free memory in that case
and thus leak memory.

Fix the leak by freeing the remote ref.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot/helper: fix leaking subrepo in nested submodule config helper
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:18 +0000 (13:46 +0200)] 
t/helper: fix leaking subrepo in nested submodule config helper

In the "submodule-nested-repo-config" helper we create a submodule
repository and print its configuration. We do not clear the repo,
causing a memory leak. Plug it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/submodule--helper: fix leaking error buffer
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:14 +0000 (13:46 +0200)] 
builtin/submodule--helper: fix leaking error buffer

Fix leaking error buffer when `compute_alternate_path()` fails.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/submodule--helper: clear child process when not running it
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:11 +0000 (13:46 +0200)] 
builtin/submodule--helper: clear child process when not running it

In `runcommand_in_submodule_cb()` we may end up not executing the child
command when `argv` is empty. But we still populate the command with
environment variables and other things, which needs cleanup. This leads
to a memory leak because we do not call `finish_command()`.

Fix this by clearing the child process when we don't execute it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosubmodule: fix leaking update strategy
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:08 +0000 (13:46 +0200)] 
submodule: fix leaking update strategy

We're not freeing the submodule update strategy command. Provide a
helper function that does this for us and call it in
`update_data_release()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agogit: fix leaking argv when handling builtins
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:06 +0000 (13:46 +0200)] 
git: fix leaking argv when handling builtins

In `handle_builtin()` we may end up creating an ad-hoc argv array in
case we see that the command line contains the "--help" parameter. In
this case we observe two memory leaks though:

  - We leak the `struct strvec` itself because we directly exit after
    calling `run_builtin()`, without bothering about any cleanups.

  - Even if we free'd that vector we'd end up leaking some of its
    strings because `run_builtin()` will modify the array.

Plug both of these leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/help: fix leaking `html_path` when reading config multiple times
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:03 +0000 (13:46 +0200)] 
builtin/help: fix leaking `html_path` when reading config multiple times

The `html_path` variable gets populated via `git_help_config()`, which
puts an allocated string into it if its value has been configured. We do
not clear the old value though, which causes a memory leak in case the
config exists multiple times.

Plug this leak. The leak is exposed by t0012, but plugging it alone is
not sufficient to make the test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/help: fix dangling reference to `html_path`
Patrick Steinhardt [Thu, 26 Sep 2024 11:46:00 +0000 (13:46 +0200)] 
builtin/help: fix dangling reference to `html_path`

In `get_html_page_path()` we may end up assigning the return value of
`system_path()` to the global `html_path` variable. But as we also
assign the returned value to `to_free`, we will deallocate its memory
upon returning from the function. Consequently, `html_path` will now
point to deallocated memory.

Fix this issue by instead assigning the value to a separate local
variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agohowto-maintain-git: discarding inactive topics
Junio C Hamano [Thu, 26 Sep 2024 19:12:05 +0000 (12:12 -0700)] 
howto-maintain-git: discarding inactive topics

When a patch series happened to look interesting to the maintainer
but is not ready for 'next', it is applied on a topic branch and
merged to the 'seen' branch to keep an eye on it.  In an ideal
world, the participants give reviews and the original author
responds to the reviews, and such iterations may produce newer
versions of the patch series, and at some point, a concensus is
formed that the latest round is good enough for 'next'.  Then the
topic is merged to 'next' for inclusion in a future release.

In a much less ideal world we live in, however, a topic sometimes
get stalled.  The original author may not respond to hanging review
comments, may promise an update will be sent but does not manage to
do so, nobody talks about the topic on the list and nobody builds
upon it, etc.

Following the recent trend to document and give more transparency to
the decision making process, let's set a deadline to keep a topic
still alive, and actively discard those that are inactive for a long
period of time.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoGit 2.47-rc0 v2.47.0-rc0
Junio C Hamano [Thu, 26 Sep 2024 01:23:49 +0000 (18:23 -0700)] 
Git 2.47-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'jk/sendemail-mailmap-doc'
Junio C Hamano [Thu, 26 Sep 2024 01:24:52 +0000 (18:24 -0700)] 
Merge branch 'jk/sendemail-mailmap-doc'

Docfix.

* jk/sendemail-mailmap-doc:
  send-email: document --mailmap and associated configuration

8 months agoMerge branch 'rs/diff-exit-code-binary'
Junio C Hamano [Thu, 26 Sep 2024 01:24:51 +0000 (18:24 -0700)] 
Merge branch 'rs/diff-exit-code-binary'

"git diff --exit-code" ignored modified binary files, which has
been corrected.

* rs/diff-exit-code-binary:
  diff: report modified binary files as changes in builtin_diff()

8 months agoMerge branch 'cb/ci-freebsd-13-4'
Junio C Hamano [Thu, 26 Sep 2024 01:24:51 +0000 (18:24 -0700)] 
Merge branch 'cb/ci-freebsd-13-4'

CI updates.

* cb/ci-freebsd-13-4:
  ci: update FreeBSD image to 13.4

8 months agoMerge branch 'ak/doc-sparse-co-typofix'
Junio C Hamano [Thu, 26 Sep 2024 01:24:50 +0000 (18:24 -0700)] 
Merge branch 'ak/doc-sparse-co-typofix'

Docfix.

* ak/doc-sparse-co-typofix:
  Documentation/technical: fix a typo

8 months agoMerge branch 'ak/typofix-builtins'
Junio C Hamano [Thu, 26 Sep 2024 01:24:50 +0000 (18:24 -0700)] 
Merge branch 'ak/typofix-builtins'

Typofix.

* ak/typofix-builtins:
  builtin: fix typos

8 months agoThe 21st batch
Junio C Hamano [Wed, 25 Sep 2024 17:33:15 +0000 (10:33 -0700)] 
The 21st batch

This pretty much should match what we would have in the upcoming
preview of 2.47.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'jc/cmake-unit-test-updates'
Junio C Hamano [Wed, 25 Sep 2024 17:37:13 +0000 (10:37 -0700)] 
Merge branch 'jc/cmake-unit-test-updates'

CMake adjustments for recent changes around unit tests.

* jc/cmake-unit-test-updates:
  cmake: generalize the handling of the `UNIT_TEST_OBJS` list
  cmake: stop looking for `REFTABLE_TEST_OBJS` in the Makefile
  cmake: rename clar-related variables to avoid confusion

8 months agoMerge branch 'ps/ci-gitlab-upgrade'
Junio C Hamano [Wed, 25 Sep 2024 17:37:12 +0000 (10:37 -0700)] 
Merge branch 'ps/ci-gitlab-upgrade'

CI updates.

* ps/ci-gitlab-upgrade:
  gitlab-ci: upgrade machine type of Linux runners

8 months agoMerge branch 'ak/refs-symref-referent-typofix'
Junio C Hamano [Wed, 25 Sep 2024 17:37:12 +0000 (10:37 -0700)] 
Merge branch 'ak/refs-symref-referent-typofix'

Typofix.

* ak/refs-symref-referent-typofix:
  ref-filter: fix a typo