Commit Graph

74381 Commits

Author SHA1 Message Date
Patrick Steinhardt
82ea7e59b2 pretty: fix leaking key/value separator buffer
The `format_set_trailers_options()` function is responsible for parsing
a custom pretty format for trailers. It puts the parsed options into a
`struct process_trailer_options` structure, while the allocated memory
required for this will be put into separate caller-provided arguments.
It is thus the caller's responsibility to free the memory not via the
options structure, but via the other parameters.

While we do this alright for the separator and filter keys, we do not
free the memory associated with the key/value separator. Fix this to
plug this memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-22 09:18:04 -07:00
Patrick Steinhardt
60289b50d0 pretty: fix memory leaks when parsing pretty formats
When parsing pretty formats from the config we leak the name and user
format whenever these are set multiple times. This is because we do not
free any already-set value in case there is one.

Plugging this leak for the name is trivial. For the user format we need
to be a bit more careful, because we may end up assigning a pointer into
the allocated region when the string is prefixed with either "format" or
"tformat:". In order to make it safe to unconditionally free the user
format we thus strdup the stripped string into the field instead of a
pointer into the string.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-22 09:18:03 -07:00
Patrick Steinhardt
643c6f576c convert: fix leaks when resetting attributes
When resetting parsed gitattributes, we free the list of convert drivers
parsed from the config. We only free some of the drivers' fields though
and thus have memory leaks.

Fix this by freeing all allocated convert driver fields to plug these
memory leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-22 09:18:03 -07:00
Patrick Steinhardt
e5530f9c5c mailinfo: fix leaking header data
We populate the `mailinfo` arrays `p_hdr_data` and `s_hdr_data` with
data parsed from the mail headers. These arrays may end up being only
partially populated with gaps in case some of the headers do not parse
properly. This causes memory leaks because `strbuf_list_free()` will
stop iterating once it hits the first `NULL` pointer in the backing
array.

Fix this by open-coding a variant of `strbuf_list_free()` that knows to
iterate through all headers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-22 09:18:03 -07:00
Junio C Hamano
2df380c280 Merge branch 'ps/leakfixes-part-4' into ps/leakfixes-part-5
* ps/leakfixes-part-4: (22 commits)
  builtin/diff: free symmetric diff members
  diff: free state populated via options
  builtin/log: fix leak when showing converted blob contents
  userdiff: fix leaking memory for configured diff drivers
  builtin/format-patch: fix various trivial memory leaks
  diff: fix leak when parsing invalid ignore regex option
  unpack-trees: clear index when not propagating it
  sequencer: release todo list on error paths
  merge-ort: unconditionally release attributes index
  builtin/fast-export: plug leaking tag names
  builtin/fast-export: fix leaking diff options
  builtin/fast-import: plug trivial memory leaks
  builtin/notes: fix leaking `struct notes_tree` when merging notes
  builtin/rebase: fix leaking `commit.gpgsign` value
  config: fix leaking comment character config
  submodule-config: fix leaking name entry when traversing submodules
  read-cache: fix leaking hashfile when writing index fails
  bulk-checkin: fix leaking state TODO
  object-name: fix leaking symlink paths in object context
  object-file: fix memory leak when reading corrupted headers
  ...
2024-08-20 10:15:27 -07:00
Junio C Hamano
bb9c16bd4f The sixth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-19 11:07:38 -07:00
Junio C Hamano
ee218ee952 Merge branch 'ps/transport-leakfix-test-updates'
Test updates.

* ps/transport-leakfix-test-updates:
  transport: mark more tests leak-free
2024-08-19 11:07:38 -07:00
Junio C Hamano
b9497848df Merge branch 'tb/incremental-midx-part-1'
Incremental updates of multi-pack index files.

* tb/incremental-midx-part-1:
  midx: implement support for writing incremental MIDX chains
  t/t5313-pack-bounds-checks.sh: prepare for sub-directories
  t: retire 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'
  midx: implement verification support for incremental MIDXs
  midx: support reading incremental MIDX chains
  midx: teach `midx_fanout_add_midx_fanout()` about incremental MIDXs
  midx: teach `midx_preferred_pack()` about incremental MIDXs
  midx: teach `midx_contains_pack()` about incremental MIDXs
  midx: remove unused `midx_locate_pack()`
  midx: teach `fill_midx_entry()` about incremental MIDXs
  midx: teach `nth_midxed_offset()` about incremental MIDXs
  midx: teach `bsearch_midx()` about incremental MIDXs
  midx: introduce `bsearch_one_midx()`
  midx: teach `nth_bitmapped_pack()` about incremental MIDXs
  midx: teach `nth_midxed_object_oid()` about incremental MIDXs
  midx: teach `prepare_midx_pack()` about incremental MIDXs
  midx: teach `nth_midxed_pack_int_id()` about incremental MIDXs
  midx: add new fields for incremental MIDX chains
  Documentation: describe incremental MIDX format
2024-08-19 11:07:37 -07:00
Junio C Hamano
53129a0680 Merge branch 'jc/tests-no-useless-tee'
Test fixes.

* jc/tests-no-useless-tee:
  tests: drop use of 'tee' that hides exit status
2024-08-19 11:07:37 -07:00
Junio C Hamano
4dbca805e0 Merge branch 'rs/unit-tests-test-run'
Unit-test framework has learned a simple control structure to allow
embedding test statements in-line instead of having to create a new
function to contain them.

* rs/unit-tests-test-run:
  t-strvec: use if_test
  t-reftable-basics: use if_test
  t-ctype: use if_test
  unit-tests: add if_test
  unit-tests: show location of checks outside of tests
  t0080: use here-doc test body
2024-08-19 11:07:36 -07:00
Junio C Hamano
b9849e4f76 Sync with 'maint'
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-16 12:57:37 -07:00
Junio C Hamano
fa3b914457 Prepare for 2.46.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-16 12:52:53 -07:00
Junio C Hamano
b3d175409d Merge branch 'sj/ref-fsck'
"git fsck" infrastructure has been taught to also check the sanity
of the ref database, in addition to the object database.

* sj/ref-fsck:
  fsck: add ref name check for files backend
  files-backend: add unified interface for refs scanning
  builtin/refs: add verify subcommand
  refs: set up ref consistency check infrastructure
  fsck: add refs report function
  fsck: add a unified interface for reporting fsck messages
  fsck: make "fsck_error" callback generic
  fsck: rename objects-related fsck error functions
  fsck: rename "skiplist" to "skip_oids"
2024-08-16 12:51:51 -07:00
Junio C Hamano
d07bb0cd2a Merge branch 'ps/p4-tests-updates' into maint-2.46
Perforce tests have been updated.
cf. <na5mwletzpnacietbc7pzqcgb622mvrwgrkjgjosysz3gvjcso@gzxxi7d7icr7>

* ps/p4-tests-updates:
  t98xx: mark Perforce tests as memory-leak free
  ci: update Perforce version to r23.2
  t98xx: fix Perforce tests with p4d r23 and newer
2024-08-16 12:50:56 -07:00
Junio C Hamano
e6698fbfa9 Merge branch 'ks/unit-test-comment-typofix' into maint-2.46
Typofix.

* ks/unit-test-comment-typofix:
  unit-tests/test-lib: fix typo in check_pointer_eq() description
2024-08-16 12:50:56 -07:00
Junio C Hamano
2ad2f2f751 Merge branch 'dh/encoding-trace-optim' into maint-2.46
An expensive operation to prepare tracing was done in re-encoding
code path even when the tracing was not requested, which has been
corrected.

* dh/encoding-trace-optim:
  convert: return early when not tracing
2024-08-16 12:50:55 -07:00
Junio C Hamano
c09721cb63 Merge branch 'dd/notes-empty-no-edit-by-default' into maint-2.46
"git notes add -m '' --allow-empty" and friends that take prepared
data to create notes should not invoke an editor, but it started
doing so since Git 2.42, which has been corrected.

* dd/notes-empty-no-edit-by-default:
  notes: do not trigger editor when adding an empty note
2024-08-16 12:50:55 -07:00
Junio C Hamano
9dd837e64f Merge branch 'jc/doc-rebase-fuzz-vs-offset-fix' into maint-2.46
"git rebase --help" referred to "offset" (the difference between
the location a change was taken from and the change gets replaced)
incorrectly and called it "fuzz", which has been corrected.

* jc/doc-rebase-fuzz-vs-offset-fix:
  doc: difference in location to apply is "offset", not "fuzz"
2024-08-16 12:50:55 -07:00
Junio C Hamano
b74d885b11 Merge branch 'tn/doc-commit-fix' into maint-2.46
Docfix.

* tn/doc-commit-fix:
  doc: remove dangling closing parenthesis
2024-08-16 12:50:54 -07:00
Junio C Hamano
72a50fa03b Merge branch 'pw/add-patch-with-suppress-blank-empty' into maint-2.46
"git add -p" by users with diff.suppressBlankEmpty set to true
failed to parse the patch that represents an unmodified empty line
with an empty line (not a line with a single space on it), which
has been corrected.

* pw/add-patch-with-suppress-blank-empty:
  add-patch: use normalize_marker() when recounting edited hunk
  add-patch: handle splitting hunks with diff.suppressBlankEmpty
2024-08-16 12:50:54 -07:00
Junio C Hamano
fca5ece278 Merge branch 'jt/doc-post-receive-hook-update' into maint-2.46
Doc update.

* jt/doc-post-receive-hook-update:
  doc: clarify post-receive hook behavior
2024-08-16 12:50:53 -07:00
Junio C Hamano
8ad56325e9 Merge branch 'jc/how-to-maintain-updates' (early part) into maint-2.46
* 'jc/how-to-maintain-updates' (early part):
  howto-maintain: update daily tasks
  howto-maintain: cover a whole development cycle
2024-08-16 12:50:52 -07:00
Junio C Hamano
cb9c47ca2b Merge branch 'jc/doc-one-shot-export-with-shell-func' into maint-2.46
It has been documented that we avoid "VAR=VAL shell_func" and why.

* jc/doc-one-shot-export-with-shell-func:
  CodingGuidelines: document a shell that "fails" "VAR=VAL shell_func"
2024-08-16 12:50:52 -07:00
Junio C Hamano
bb250b5378 Merge branch 'jc/checkout-no-op-switch-errors' into maint-2.46
"git checkout --ours" (no other arguments) complained that the
option is incompatible with branch switching, which is technically
correct, but found confusing by some users.  It now says that the
user needs to give pathspec to specify what paths to checkout.

* jc/checkout-no-op-switch-errors:
  checkout: special case error messages during noop switching
2024-08-16 12:50:51 -07:00
Junio C Hamano
87a1768b93 The fifth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-15 13:22:16 -07:00
Junio C Hamano
0da7673a51 Merge branch 'xx/diff-tree-remerge-diff-fix'
"git rev-list ... | git diff-tree -p --remerge-diff --stdin" should
behave more or less like "git log -p --remerge-diff" but instead it
crashed, forgetting to prepare a temporary object store needed.

* xx/diff-tree-remerge-diff-fix:
  diff-tree: fix crash when used with --remerge-diff
2024-08-15 13:22:16 -07:00
Junio C Hamano
e7f86cb69d Merge branch 'jc/refs-symref-referent'
The refs API has been taught to give symref target information to
the users of ref iterators, allowing for-each-ref and friends to
avoid an extra ref_resolve_* API call per a symbolic ref.

* jc/refs-symref-referent:
  ref-filter: populate symref from iterator
  refs: add referent to each_ref_fn
  refs: keep track of unresolved reference value in iterators
2024-08-15 13:22:15 -07:00
Junio C Hamano
88457a6151 Merge branch 'ps/submodule-ref-format'
Support to specify ref backend for submodules has been enhanced.

* ps/submodule-ref-format:
  object: fix leaking packfiles when closing object store
  submodule: fix leaking seen submodule names
  submodule: fix leaking fetch tasks
  builtin/submodule: allow "add" to use different ref storage format
  refs: fix ref storage format for submodule ref stores
  builtin/clone: propagate ref storage format to submodules
  builtin/submodule: allow cloning with different ref storage format
  git-submodule.sh: break overly long command lines
2024-08-15 13:22:14 -07:00
Junio C Hamano
6891103f72 Merge branch 'ag/t7004-modernize'
Coding style fixes to a test script.

* ag/t7004-modernize:
  t7004: make use of write_script
  t7004: use single quotes instead of double quotes
  t7004: begin the test body on the same line as test_expect_success
  t7004: description on the same line as test_expect_success
  t7004: do not prepare things outside test_expect_success
  t7004: use indented here-doc
  t7004: one command per line
  t7004: remove space after redirect operators
2024-08-15 13:22:14 -07:00
Junio C Hamano
69b737999c Merge branch 'ps/reftable-stack-compaction'
The code paths to compact multiple reftable files have been updated
to correctly deal with multiple compaction triggering at the same
time.

* ps/reftable-stack-compaction:
  reftable/stack: handle locked tables during auto-compaction
  reftable/stack: fix corruption on concurrent compaction
  reftable/stack: use lock_file when adding table to "tables.list"
  reftable/stack: do not die when fsyncing lock file files
  reftable/stack: simplify tracking of table locks
  reftable/stack: update stats on failed full compaction
  reftable/stack: test compaction with already-locked tables
  reftable/stack: extract function to setup stack with N tables
  reftable/stack: refactor function to gather table sizes
2024-08-15 13:22:13 -07:00
Junio C Hamano
2b9b229cb4 Merge branch 'es/doc-platform-support-policy'
A policy document that describes platform support levels and
expectation on platform stakeholders has been introduced.

* es/doc-platform-support-policy:
  Documentation: add platform support policy
2024-08-15 13:22:13 -07:00
Junio C Hamano
a3d71f2076 Merge branch 'gt/unit-test-hashmap'
An existing test of hashmap API has been rewritten with the
unit-test framework.

* gt/unit-test-hashmap:
  t: port helper/test-hashmap.c to unit-tests/t-hashmap.c
2024-08-15 13:22:12 -07:00
Junio C Hamano
f6df5e2d05 Merge branch 'jc/t3206-test-when-finished-fix'
Test clean-up.

* jc/t3206-test-when-finished-fix:
  t3206: test_when_finished before dirtying operations, not after
2024-08-15 13:22:12 -07:00
Junio C Hamano
402f36f33e Merge branch 'rs/t-example-simplify'
Unit test simplification.

* rs/t-example-simplify:
  t-example-decorate: remove test messages
2024-08-15 13:22:11 -07:00
Junio C Hamano
0ed3dde067 Merge branch 'jc/safe-directory'
Follow-up on 2.45.1 regression fix.

* jc/safe-directory:
  safe.directory: setting safe.directory="." allows the "current" directory
  safe.directory: normalize the configured path
  safe.directory: normalize the checked path
  safe.directory: preliminary clean-up
2024-08-15 13:22:11 -07:00
Junio C Hamano
477ce5ccd6 The fourth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-14 14:54:58 -07:00
Junio C Hamano
d639123742 Merge branch 'tb/t7704-deflake'
A test that fails on an unusually slow machine was found, and made
less likely to cause trouble by lengthening the expiry value it
uses.

* tb/t7704-deflake:
  t/t7704-repack-cruft.sh: avoid failures during long-running tests
2024-08-14 14:54:58 -07:00
Junio C Hamano
dd59778f76 Merge branch 'jc/document-use-of-local'
Doc update.

* jc/document-use-of-local:
  doc: note that AT&T ksh does not work with our test suite
2024-08-14 14:54:58 -07:00
Junio C Hamano
4a443f00c4 Merge branch 'rs/use-decimal-width'
Code clean-up.

* rs/use-decimal-width:
  log-tree: use decimal_width()
2024-08-14 14:54:57 -07:00
Junio C Hamano
81903d0472 Merge branch 'ss/packed-ref-store-leakfix'
Leakfix.

* ss/packed-ref-store-leakfix:
  refs/files: prevent memory leak by freeing packed_ref_store
2024-08-14 14:54:57 -07:00
Junio C Hamano
7b11e20bff Merge branch 'cp/unit-test-reftable-tree'
A test in reftable library has been rewritten using the unit test
framework.

* cp/unit-test-reftable-tree:
  t-reftable-tree: improve the test for infix_walk()
  t-reftable-tree: add test for non-existent key
  t-reftable-tree: split test_tree() into two sub-test functions
  t: move reftable/tree_test.c to the unit testing framework
  reftable: remove unnecessary curly braces in reftable/tree.c
2024-08-14 14:54:56 -07:00
Junio C Hamano
61fd5de05f Merge branch 'kl/test-fixes'
A flakey test and incorrect calls to strtoX() functions have been
fixed.

* kl/test-fixes:
  t6421: fix test to work when repo dir contains d0
  set errno=0 before strtoX calls
2024-08-14 14:54:55 -07:00
Junio C Hamano
494c9788e4 Merge branch 'jc/reflog-expire-lookup-commit-fix'
"git reflog expire" failed to honor annotated tags when computing
reachable commits.

* jc/reflog-expire-lookup-commit-fix:
  Revert "reflog expire: don't use lookup_commit_reference_gently()"
2024-08-14 14:54:55 -07:00
Junio C Hamano
7a95eceb6b Merge branch 'jr/ls-files-expand-literal-doc'
Docfix.

* jr/ls-files-expand-literal-doc:
  doc: fix hex code escapes in git-ls-files
2024-08-14 14:54:54 -07:00
Junio C Hamano
c147b41f4c Merge branch 'jc/leakfix-mailmap'
Leakfix.

* jc/leakfix-mailmap:
  mailmap: plug memory leak in read_mailmap_blob()
2024-08-14 14:54:54 -07:00
Junio C Hamano
dfaa04f3c6 Merge branch 'jc/leakfix-hashfile'
Leakfix.

* jc/leakfix-hashfile:
  csum-file: introduce discard_hashfile()
2024-08-14 14:54:53 -07:00
Junio C Hamano
44773b9f70 Merge branch 'jc/patch-id'
The patch parser in "git patch-id" has been tightened to avoid
getting confused by lines that look like a patch header in the log
message.

* jc/patch-id:
  patch-id: tighten code to detect the patch header
  patch-id: rewrite code that detects the beginning of a patch
  patch-id: make get_one_patchid() more extensible
  patch-id: call flush_current_id() only when needed
  t4204: patch-id supports various input format
2024-08-14 14:54:53 -07:00
Junio C Hamano
c7ca437d9f Merge branch 'ps/refs-wo-the-repository'
In the refs subsystem, implicit reliance of the_repository has been
eliminated; the repository associated with the ref store object is
used instead.

* ps/refs-wo-the-repository:
  refs/reftable: stop using `the_repository`
  refs/packed: stop using `the_repository`
  refs/files: stop using `the_repository`
  refs/files: stop using `the_repository` in `parse_loose_ref_contents()`
  refs: stop using `the_repository`
2024-08-14 14:54:52 -07:00
Junio C Hamano
5a74eb07ca Merge branch 'jc/jl-git-no-advice-fix'
Remove leftover debugging cruft from a test script.

* jc/jl-git-no-advice-fix:
  t0018: remove leftover debugging cruft
2024-08-14 14:54:51 -07:00
Junio C Hamano
4cf2f1be56 Merge branch 'tb/config-fixed-value-with-valueless-true'
"git config --value=foo --fixed-value section.key newvalue" barfed
when the existing value in the configuration file used the
valueless true syntax, which has been corrected.

* tb/config-fixed-value-with-valueless-true:
  config.c: avoid segfault with --fixed-value and valueless config
2024-08-14 14:54:51 -07:00