1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 04:49:43 +01:00
Commit graph

74722 commits

Author SHA1 Message Date
Patrick Steinhardt
ecb5c4318c unpack-trees: detect mismatching number of cache-tree/index entries
Same as the preceding commit, we unconditionally dereference the index's
cache entries depending on the number of cache-tree entries, which can
lead to a segfault when the cache-tree is corrupted. Fix this bug.

This also makes t4058 pass with the leak sanitizer enabled.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-07 15:08:11 -07:00
Patrick Steinhardt
2be7fc012e cache-tree: detect mismatching number of index entries
In t4058 we have some tests that exercise git-read-tree(1) when used
with a tree that contains duplicate entries. While the expectation is
that we fail, we ideally should fail gracefully without a segfault.

But that is not the case: we never check that the number of entries in
the cache-tree is less than or equal to the number of entries in the
index. This can lead to an out-of-bounds read as we unconditionally
access `istate->cache[idx]`, where `idx` is controlled by the number of
cache-tree entries and the current position therein. The result is a
segfault.

Fix this segfault by adding a sanity check for the number of index
entries before dereferencing them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-07 15:08:11 -07:00
Patrick Steinhardt
9f119599a6 cache-tree: refactor verification to return error codes
The function `cache_tree_verify()` will `BUG()` whenever it finds that
the cache-tree extension of the index is corrupt. The function is thus
inherently untestable because the resulting call to `abort()` will be
detected by our testing framework and labelled an error. And rightfully
so: it shouldn't ever be possible to hit bugs, as they should indicate a
programming error rather than corruption of on-disk state.

Refactor the function to instead return error codes. This also ensures
that the function can be used e.g. by git-fsck(1) without the whole
process dying. Furthermore, this refactoring plugs some memory leaks
when returning early by creating a common exit path.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-07 15:08:11 -07:00
Junio C Hamano
3969d78396 The seventeenth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16 14:22:55 -07:00
Junio C Hamano
b708e8b8c1 Merge branch 'jk/ref-filter-trailer-fixes'
Bugfixes and leak plugging in "git for-each-ref --format=..." code
paths.

* jk/ref-filter-trailer-fixes:
  ref-filter: fix leak with unterminated %(if) atoms
  ref-filter: add ref_format_clear() function
  ref-filter: fix leak when formatting %(push:remoteref)
  ref-filter: fix leak with %(describe) arguments
  ref-filter: fix leak of %(trailers) "argbuf"
  ref-filter: store ref_trailer_buf data per-atom
  ref-filter: drop useless cast in trailers_atom_parser()
  ref-filter: strip signature when parsing tag trailers
  ref-filter: avoid extra copies of payload/signature
  t6300: drop newline from wrapped test title
2024-09-16 14:22:55 -07:00
Junio C Hamano
be8ca2848a Merge branch 'jc/range-diff-lazy-setup'
Code clean-up.

* jc/range-diff-lazy-setup:
  remerge-diff: clean up temporary objdir at a central place
  remerge-diff: lazily prepare temporary objdir on demand
2024-09-16 14:22:55 -07:00
Junio C Hamano
6e2a18cb04 Merge branch 'ah/apply-3way-ours'
"git apply --3way" learned to take "--ours" and other options.

* ah/apply-3way-ours:
  apply: support --ours, --theirs, and --union for three-way merges
2024-09-16 14:22:54 -07:00
Junio C Hamano
c1f41bbe1a Merge branch 'cp/unit-test-reftable-stack'
Another reftable test migrated to the unit-test framework.

* cp/unit-test-reftable-stack:
  t-reftable-stack: add test for stack iterators
  t-reftable-stack: add test for non-default compaction factor
  t-reftable-stack: use reftable_ref_record_equal() to compare ref records
  t-reftable-stack: use Git's tempfile API instead of mkstemp()
  t: harmonize t-reftable-stack.c with coding guidelines
  t: move reftable/stack_test.c to the unit testing framework
2024-09-16 14:22:53 -07:00
Junio C Hamano
ed155187b4 Sync with Git 2.46.1 2024-09-13 15:31:57 -07:00
Junio C Hamano
9cf95c0ca0 The sixteenth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13 15:27:45 -07:00
Junio C Hamano
77cf81e988 Merge branch 'bl/trailers-and-incomplete-last-line-fix'
The interpret-trailers command failed to recognise the end of the
message when the commit log ends in an incomplete line.

* bl/trailers-and-incomplete-last-line-fix:
  interpret-trailers: handle message without trailing newline
2024-09-13 15:27:45 -07:00
Junio C Hamano
bf42b23901 Merge branch 'rj/cygwin-has-dev-tty'
Cygwin does have /dev/tty support that is needed by things like
single-key input mode.

* rj/cygwin-has-dev-tty:
  config.mak.uname: add HAVE_DEV_TTY to cygwin config section
2024-09-13 15:27:44 -07:00
Junio C Hamano
41390eb3e6 Merge branch 'rs/diff-exit-code-fix'
In a few corner cases "git diff --exit-code" failed to report
"changes" (e.g., renamed without any content change), which has
been corrected.

* rs/diff-exit-code-fix:
  diff: report dirty submodules as changes in builtin_diff()
  diff: report copies and renames as changes in run_diff_cmd()
2024-09-13 15:27:43 -07:00
Junio C Hamano
da1c402a47 Merge branch 'jc/doc-skip-fetch-all-and-prefetch'
Doc updates.

* jc/doc-skip-fetch-all-and-prefetch:
  doc: remote.*.skip{DefaultUpdate,FetchAll} stops prefetch
2024-09-13 15:27:43 -07:00
Junio C Hamano
19de221f36 Merge branch 'ds/doc-wholesale-disabling-advice-messages'
The environment GIT_ADVICE has been intentionally kept undocumented
to discourage its use by interactive users.  Add documentation to
help tool writers.

* ds/doc-wholesale-disabling-advice-messages:
  advice: recommend GIT_ADVICE=0 for tools
2024-09-13 15:27:43 -07:00
Junio C Hamano
17ae0b8249 Merge branch 'jk/sparse-fdleak-fix'
A file descriptor left open is now properly closed when "git
sparse-checkout" updates the sparse patterns.

* jk/sparse-fdleak-fix:
  sparse-checkout: use fdopen_lock_file() instead of xfdopen()
  sparse-checkout: check commit_lock_file when writing patterns
  sparse-checkout: consolidate cleanup when writing patterns
2024-09-13 15:27:43 -07:00
Junio C Hamano
0299251319 Merge branch 'ds/scalar-no-tags'
The "scalar clone" command learned the "--no-tags" option.

* ds/scalar-no-tags:
  scalar: add --no-tags option to 'scalar clone'
2024-09-13 15:27:42 -07:00
Junio C Hamano
a731929aa8 Git 2.46.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13 15:26:52 -07:00
Junio C Hamano
8ef5549b06 Merge branch 'rj/compat-terminal-unused-fix' into maint-2.46
Build fix.

* rj/compat-terminal-unused-fix:
  compat/terminal: mark parameter of git_terminal_prompt() UNUSED
2024-09-13 15:26:52 -07:00
Junio C Hamano
8b4bb65a8f Merge branch 'jc/config-doc-update' into maint-2.46
Docfix.

* jc/config-doc-update:
  git-config.1: fix description of --regexp in synopsis
  git-config.1: --get-all description update
2024-09-13 15:26:52 -07:00
Junio C Hamano
d3d7c8dfb8 Merge branch 'aa/cat-file-batch-output-doc' into maint-2.46
Docfix.

* aa/cat-file-batch-output-doc:
  docs: explain the order of output in the batched mode of git-cat-file(1)
2024-09-13 15:26:52 -07:00
Junio C Hamano
118c74d143 Merge branch 'cl/config-regexp-docfix' into maint-2.46
Docfix.

* cl/config-regexp-docfix:
  doc: replace 3 dash with correct 2 dash in git-config(1)
2024-09-13 15:26:51 -07:00
Junio C Hamano
bb57f055ae Merge branch 'jc/coding-style-c-operator-with-spaces' into maint-2.46
Write down whitespacing rules around C opeators.

* jc/coding-style-c-operator-with-spaces:
  CodingGuidelines: spaces around C operators
2024-09-13 15:26:51 -07:00
Junio C Hamano
480124470c Merge branch 'ps/stash-keep-untrack-empty-fix' into maint-2.46
A corner case bug in "git stash" was fixed.

* ps/stash-keep-untrack-empty-fix:
  builtin/stash: fix `--keep-index --include-untracked` with empty HEAD
2024-09-13 15:26:51 -07:00
Junio C Hamano
be344f3631 Merge branch 'ps/index-pack-outside-repo-fix' into maint-2.46
"git verify-pack" and "git index-pack" started dying outside a
repository, which has been corrected.

* ps/index-pack-outside-repo-fix:
  builtin/index-pack: fix segfaults when running outside of a repo
2024-09-13 15:26:50 -07:00
Junio C Hamano
bc79932048 Merge branch 'jk/free-commit-buffer-of-skipped-commits' into maint-2.46
The code forgot to discard unnecessary in-core commit buffer data
for commits that "git log --skip=<number>" traversed but omitted
from the output, which has been corrected.

* jk/free-commit-buffer-of-skipped-commits:
  revision: free commit buffers for skipped commits
2024-09-13 15:26:49 -07:00
Junio C Hamano
57974d46a4 Sync with 'maint' 2024-09-12 11:48:46 -07:00
Junio C Hamano
f8ca6d0064 The fifteenth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12 11:47:24 -07:00
Junio C Hamano
f286e0a01c Merge branch 'kl/cat-file-on-sparse-index'
"git cat-file" works well with the sparse-index, and gets marked as
such.

* kl/cat-file-on-sparse-index:
  builtin/cat-file: mark 'git cat-file' sparse-index compatible
  t1092: allow run_on_* functions to use standard input
2024-09-12 11:47:24 -07:00
Junio C Hamano
b64f249726 Merge branch 'jk/messages-with-excess-lf-fix'
One-line messages to "die" and other helper functions will get LF
added by these helper functions, but many existing messages had an
unnecessary LF at the end, which have been corrected.

* jk/messages-with-excess-lf-fix:
  drop trailing newline from warning/error/die messages
2024-09-12 11:47:23 -07:00
Junio C Hamano
143682ec43 Merge branch 'ps/pack-refs-auto-heuristics'
"git pack-refs --auto" for the files backend was too aggressive,
which has been a bit tamed.

* ps/pack-refs-auto-heuristics:
  refs/files: use heuristic to decide whether to repack with `--auto`
  t0601: merge tests for auto-packing of refs
  wrapper: introduce `log2u()`
2024-09-12 11:47:23 -07:00
Junio C Hamano
3bf057a0cd Merge branch 'tb/multi-pack-reuse-fix'
A data corruption bug when multi-pack-index is used and the same
objects are stored in multiple packfiles has been corrected.

* tb/multi-pack-reuse-fix:
  builtin/pack-objects.c: do not open-code `MAX_PACK_OBJECT_HEADER`
  pack-bitmap.c: avoid repeated `pack_pos_to_offset()` during reuse
  builtin/pack-objects.c: translate bit positions during pack-reuse
  pack-bitmap: tag bitmapped packs with their corresponding MIDX
  t/t5332-multi-pack-reuse.sh: verify pack generation with --strict
2024-09-12 11:47:23 -07:00
Junio C Hamano
04595eb407 Merge branch 'gt/unit-test-oid-array'
Another unit-test.

* gt/unit-test-oid-array:
  t: port helper/test-oid-array.c to unit-tests/t-oid-array.c
2024-09-12 11:47:23 -07:00
Junio C Hamano
63b5fcdde9 Merge branch 'ps/index-pack-outside-repo-fix'
"git verify-pack" and "git index-pack" started dying outside a
repository, which has been corrected.

* ps/index-pack-outside-repo-fix:
  builtin/index-pack: fix segfaults when running outside of a repo
2024-09-12 11:47:22 -07:00
Junio C Hamano
3265304f94 Merge branch 'jc/mailinfo-header-cleanup'
Code clean-up.

* jc/mailinfo-header-cleanup:
  mailinfo: we parse fixed headers
2024-09-12 11:47:22 -07:00
Junio C Hamano
6074a7d4ae Another batch of topics for 2.46.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12 11:09:46 -07:00
Junio C Hamano
d2b936f1dc Merge branch 'jc/grammo-fixes' into maint-2.46
Doc updates.

* jc/grammo-fixes:
  doc: grammofix in git-diff-tree
  tutorial: grammofix
2024-09-12 11:02:19 -07:00
Junio C Hamano
1b9a1246ef Merge branch 'jc/tests-no-useless-tee' into maint-2.46
Test fixes.

* jc/tests-no-useless-tee:
  tests: drop use of 'tee' that hides exit status
2024-09-12 11:02:18 -07:00
Junio C Hamano
9e2cb073ec Merge branch 'jc/how-to-maintain-updates' into maint-2.46
Doc updates.

* jc/how-to-maintain-updates:
  howto-maintain: mention preformatted docs
2024-09-12 11:02:17 -07:00
Junio C Hamano
b4e826a720 Merge branch 'ps/bundle-outside-repo-fix' into maint-2.46
"git bundle unbundle" outside a repository triggered a BUG()
unnecessarily, which has been corrected.

* ps/bundle-outside-repo-fix:
  bundle: default to SHA1 when reading bundle headers
  builtin/bundle: have unbundle check for repo before opening its bundle
2024-09-12 11:02:16 -07:00
Junio C Hamano
41c952ebac Merge branch 'jc/patch-id' into maint-2.46
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.
cf. <Zqh2T_2RLt0SeKF7@tanuki>

* 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-09-12 11:02:16 -07:00
Junio C Hamano
712d970c01 Merge branch 'jk/apply-patch-mode-check-fix' into maint-2.46
Test fix.

* jk/apply-patch-mode-check-fix:
  t4129: fix racy index when calling chmod after git-add
  apply: canonicalize modes read from patches
2024-09-12 11:02:15 -07:00
Junio C Hamano
c5ee8f2d1c The fourteenth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10 13:16:43 -07:00
Junio C Hamano
2e0808ca0e Merge branch 'sp/mailmap'
Update to a mailmap entry.

* sp/mailmap:
  .mailmap document current address.
2024-09-10 13:16:43 -07:00
Junio C Hamano
48642ec7ab Merge branch 'ps/declare-pack-redundamt-dead'
"git pack-redundant" has been marked for removal in Git 3.0.

* ps/declare-pack-redundamt-dead:
  Documentation/BreakingChanges: announce removal of git-pack-redundant(1)
2024-09-10 13:16:43 -07:00
Junio C Hamano
d1ea0f70cb Merge branch 'ah/mergetols-vscode'
"git mergetool" learned to use VSCode as a merge backend.

* ah/mergetols-vscode:
  mergetools: vscode: new tool
2024-09-10 13:16:42 -07:00
Junio C Hamano
f4806a9a3e Merge branch 'rj/compat-terminal-unused-fix'
Build fix.

* rj/compat-terminal-unused-fix:
  compat/terminal: mark parameter of git_terminal_prompt() UNUSED
2024-09-10 13:16:42 -07:00
Junio C Hamano
a6dce0afc3 Merge branch 'jk/free-commit-buffer-of-skipped-commits'
The code forgot to discard unnecessary in-core commit buffer data
for commits that "git log --skip=<number>" traversed but omitted
from the output, which has been corrected.

* jk/free-commit-buffer-of-skipped-commits:
  revision: free commit buffers for skipped commits
2024-09-10 13:16:41 -07:00
Patrick Steinhardt
04d9744f83 ref-filter: fix leak with unterminated %(if) atoms
When parsing `%(if)` atoms we expect a few other atoms to exist to
complete it, like `%(then)` and `%(end)`. Whether or not we have seen
these other atoms is tracked in an allocated `if_then_else` structure,
which gets free'd by the `if_then_else_handler()` once we have parsed
the complete conditional expression.

This results in a memory leak when the `%(if)` atom is not terminated
correctly and thus incomplete. We never end up executing its handler and
thus don't end up freeing the structure.

Plug this memory leak by introducing a new `at_end_data_free` callback
function. If set, we'll execute it in `pop_stack_element()` and pass it
the `at_end_data` variable with the intent to free its state. Wire it up
for the `%(if)` atom accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10 09:26:13 -07:00
Jeff King
db629c61f0 ref-filter: add ref_format_clear() function
After using the ref-filter API, callers should use ref_filter_clear() to
free any used memory. However, there's not a matching function to clear
the ref_format struct.

Traditionally this did not need to be cleaned up, as it was just a way
for the caller to store and pass format options as a single unit. Even
though the parsing step of some placeholders may allocate data, that's
usually inside their "used_atom" structs, which are part of the
ref_filter itself.

But a few placeholders keep data outside of there. The %(ahead-behind)
and %(is-base) parsers both keep a master list of bases, because they
perform a single filtering pass outside of the use of any particular
atom. And since the format parser does not have access to the ref_filter
struct, they store their cross-atom data in the ref_format struct
itself.

And thus when they are finished, the ref_format also needs to be cleaned
up. So let's add a function to do so, and call it from all of the users
of the ref-filter API.

The %(is-base) case is found by running LSan on t6300. After this patch,
the script can now be marked leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09 16:26:11 -07:00