aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2024-09-30Merge branch 'ps/reftable-concurrent-writes'Junio C Hamano7-19/+189
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"
2024-09-25Git 2.47-rc0v2.47.0-rc0Junio C Hamano2-1/+8
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-25Merge branch 'jk/sendemail-mailmap-doc'Junio C Hamano2-0/+21
Docfix. * jk/sendemail-mailmap-doc: send-email: document --mailmap and associated configuration
2024-09-25Merge branch 'rs/diff-exit-code-binary'Junio C Hamano2-0/+9
"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()
2024-09-25Merge branch 'cb/ci-freebsd-13-4'Junio C Hamano1-1/+1
CI updates. * cb/ci-freebsd-13-4: ci: update FreeBSD image to 13.4
2024-09-25Merge branch 'ak/doc-sparse-co-typofix'Junio C Hamano1-1/+1
Docfix. * ak/doc-sparse-co-typofix: Documentation/technical: fix a typo
2024-09-25Merge branch 'ak/typofix-builtins'Junio C Hamano4-4/+4
Typofix. * ak/typofix-builtins: builtin: fix typos
2024-09-25The 21st batchJunio C Hamano1-0/+9
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>
2024-09-25Merge branch 'jc/cmake-unit-test-updates'Junio C Hamano1-14/+11
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
2024-09-25Merge branch 'ps/ci-gitlab-upgrade'Junio C Hamano1-0/+2
CI updates. * ps/ci-gitlab-upgrade: gitlab-ci: upgrade machine type of Linux runners
2024-09-25Merge branch 'ak/refs-symref-referent-typofix'Junio C Hamano1-1/+1
Typofix. * ak/refs-symref-referent-typofix: ref-filter: fix a typo
2024-09-25Merge branch 'ak/typofix-2.46-maint'Junio C Hamano19-24/+24
Typofix. * ak/typofix-2.46-maint: upload-pack: fix a typo sideband: fix a typo setup: fix a typo run-command: fix a typo revision: fix a typo refs: fix typos rebase: fix a typo read-cache-ll: fix a typo pretty: fix a typo object-file: fix a typo merge-ort: fix typos merge-ll: fix a typo http: fix a typo gpg-interface: fix a typo git-p4: fix typos git-instaweb: fix a typo fsmonitor-settings: fix a typo diffcore-rename: fix typos config.mak.dev: fix a typo
2024-09-25Merge branch 'ps/reftable-exclude'Junio C Hamano16-201/+594
The reftable backend learned to more efficiently handle exclude patterns while enumerating the refs. * ps/reftable-exclude: refs/reftable: wire up support for exclude patterns reftable/reader: make table iterator reseekable t/unit-tests: introduce reftable library Makefile: stop listing test library objects twice builtin/receive-pack: fix exclude patterns when announcing refs refs: properly apply exclude patterns to namespaced refs
2024-09-25Merge branch 'ps/apply-leakfix'Junio C Hamano6-251/+206
"git apply" had custom buffer management code that predated before use of strbuf got widespread, which has been updated to use strbuf, which also plugged some memory leaks. * ps/apply-leakfix: apply: refactor `struct image` to use a `struct strbuf` apply: rename members that track line count and allocation length apply: refactor code to drop `line_allocated` apply: introduce macro and function to init images apply: rename functions operating on `struct image` apply: reorder functions to move image-related things together
2024-09-25send-email: document --mailmap and associated configurationJacob Keller2-0/+21
241499aba007 ("send-email: add mailmap support via sendemail.mailmap and --mailmap", 2024-08-27) added support for --mailmap, and the associated sendemail.mailmap.* configuration variables. Add documentation to reflect this feature. Fixes: 241499aba007 ("send-email: add mailmap support via sendemail.mailmap and --mailmap") Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-24builtin: fix typosAndrew Kreimer4-4/+4
Fix typos in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-24refs/reftable: reload locked stack when preparing transactionPatrick Steinhardt2-1/+33
When starting a reftable transaction we lock all stacks we are about to modify. While it may happen that the stack is out-of-date at this point in time we don't really care: transactional updates encode the expected state of a certain reference, so all that we really want to verify is that the _current_ value matches that expected state. Pass `REFTABLE_STACK_NEW_ADDITION_RELOAD` when locking the stack such that an out-of-date stack will be reloaded after having been locked. This change is safe because all verifications of the expected state happen after this step anyway. Add a testcase that verifies that many writers are now able to write to the stack concurrently without failures and with a deterministic end result. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-24reftable/stack: allow locking of outdated stacksPatrick Steinhardt4-13/+91
In `reftable_stack_new_addition()` we first lock the stack and then check whether it is still up-to-date. If it is not we return an error to the caller indicating that the stack is outdated. This is overly restrictive in our ref transaction interface though: we lock the stack right before we start to verify the transaction, so we do not really care whether it is outdated or not. What we really want is that the stack is up-to-date after it has been locked so that we can verify queued updates against its current state while we know that it is locked for concurrent modification. Introduce a new flag `REFTABLE_STACK_NEW_ADDITION_RELOAD` that alters the behaviour of `reftable_stack_init_addition()` in this case: when we notice that it is out-of-date we reload it instead of returning an error to the caller. This logic will be wired up in the reftable backend in the next commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-24refs/reftable: introduce "reftable.lockTimeout"Patrick Steinhardt5-6/+66
When multiple concurrent processes try to update references in a repository they may try to lock the same lockfiles. This can happen even when the updates are non-conflicting and can both be applied, so it doesn't always make sense to abort the transaction immediately. Both the "loose" and "packed" backends thus have a grace period that they wait for the lock to be released that can be controlled via the config values "core.filesRefLockTimeout" and "core.packedRefsTimeout", respectively. The reftable backend doesn't have such a setting yet and instead fails immediately when it sees such a lock. But the exact same concepts apply here as they do apply to the other backends. Introduce a new "reftable.lockTimeout" config that controls how long we may wait for a "tables.list" lock to be released. The default value of this config is 100ms, which is the same default as we have it for the "loose" backend. Note that even though we also lock individual tables, this config really only applies to the "tables.list" file. This is because individual tables are only ever locked when we already hold the "tables.list" lock during compaction. When we observe such a lock we in fact do not want to compact the table at all because it is already in the process of being compacted by a concurrent process. So applying the same timeout here would not make any sense and only delay progress. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-23Documentation/technical: fix a typoAndrew Kreimer1-1/+1
Fix a typo in documentation. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-23The 20th batchJunio C Hamano1-0/+14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-23Merge branch 'jc/pass-repo-to-builtins'Junio C Hamano128-437/+903
The convention to calling into built-in command implementation has been updated to pass the repository, if known, together with the prefix value. * jc/pass-repo-to-builtins: add: pass in repo variable instead of global the_repository builtin: remove USE_THE_REPOSITORY for those without the_repository builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h builtin: add a repository parameter for builtin functions
2024-09-23Merge branch 'jk/t9001-deflake'Junio C Hamano1-2/+2
Test fix. * jk/t9001-deflake: t9001: use a more distinct fake BugID
2024-09-23Merge branch 'jk/jump-quickfix-fixes'Junio C Hamano1-2/+2
A few usability fixes to "git jump" (in contrib/). * jk/jump-quickfix-fixes: git-jump: ignore deleted files in diff mode git-jump: always specify column 1 for diff entries
2024-09-23Merge branch 'ak/typofixes'Junio C Hamano3-3/+3
Trivial typofixes. * ak/typofixes: cbtree: fix a typo bloom: fix a typo attr: fix a typo
2024-09-23Merge branch 'jk/diag-unexpected-remote-helper-death'Junio C Hamano2-3/+24
When a remote-helper dies before Git writes to it, SIGPIPE killed Git silently. We now explain the situation a bit better to the end user in our error message. * jk/diag-unexpected-remote-helper-death: print an error when remote helpers die during capabilities
2024-09-23Merge branch 'jc/t5512-sigpipe-fix'Junio C Hamano1-0/+1
Test fix. * jc/t5512-sigpipe-fix: t5512.40 sometimes dies by SIGPIPE
2024-09-23Merge branch 'ps/environ-wo-the-repository'Junio C Hamano83-560/+698
Code clean-up. * ps/environ-wo-the-repository: (21 commits) environment: stop storing "core.notesRef" globally environment: stop storing "core.warnAmbiguousRefs" globally environment: stop storing "core.preferSymlinkRefs" globally environment: stop storing "core.logAllRefUpdates" globally refs: stop modifying global `log_all_ref_updates` variable branch: stop modifying `log_all_ref_updates` variable repo-settings: track defaults close to `struct repo_settings` repo-settings: split out declarations into a standalone header environment: guard state depending on a repository environment: reorder header to split out `the_repository`-free section environment: move `set_git_dir()` and related into setup layer environment: make `get_git_namespace()` self-contained environment: move object database functions into object layer config: make dependency on repo in `read_early_config()` explicit config: document `read_early_config()` and `read_very_early_config()` environment: make `get_git_work_tree()` accept a repository environment: make `get_graft_file()` accept a repository environment: make `get_index_file()` accept a repository environment: make `get_object_directory()` accept a repository environment: make `get_git_common_dir()` accept a repository ...
2024-09-23Sync with Git 2.46.2Junio C Hamano1-0/+12
2024-09-23Git 2.46.2v2.46.2Junio C Hamano2-1/+13
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-23Merge branch 'ma/test-libcurl-prereq' into maint-2.46Junio C Hamano2-3/+5
Test portability fix. * ma/test-libcurl-prereq: t0211: add missing LIBCURL prereq t1517: add missing LIBCURL prereq
2024-09-23Merge branch 'jc/doc-skip-fetch-all-and-prefetch' into maint-2.46Junio C Hamano3-8/+13
Doc updates. * jc/doc-skip-fetch-all-and-prefetch: doc: remote.*.skip{DefaultUpdate,FetchAll} stops prefetch
2024-09-23Merge branch 'bl/trailers-and-incomplete-last-line-fix' into maint-2.46Junio C Hamano2-0/+41
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-23Merge branch 'rj/cygwin-has-dev-tty' into maint-2.46Junio C Hamano1-0/+1
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-23Merge branch 'rs/diff-exit-code-fix' into maint-2.46Junio C Hamano2-0/+42
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-23diff: report modified binary files as changes in builtin_diff()René Scharfe2-0/+9
The diff machinery has two ways to detect changes to set the exit code: Just comparing hashes and comparing blob contents. The latter is needed if certain changes have to be ignored, e.g. with --ignore-space-change or --ignore-matching-lines. It's enabled by the diff_options flag diff_from_contents. The code for handling binary files added by 1aaf69e669 (diff: shortcut for diff'ing two binary SHA-1 objects, 2014-08-16) always uses a quick hash-only comparison, even if the slow way is taken. We need it to report a hash difference as a change for the purpose of setting the exit code, though, but it never did. Fix that. d7b97b7185 (diff: let external diffs report that changes are uninteresting, 2024-06-09) set diff_from_contents if external diff programs are allowed. This is the default e.g. for git diff, and so that change exposed the inconsistency much more widely. Reported-by: Kohei Shibata <shiba200712@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-20ci: update FreeBSD image to 13.4Carlo Marcelo Arenas Belón1-1/+1
FreeBSD 13.4 was recently released, and that means the version of the image used by this job (13.2) will be out of support soon. Update it before the job starts failing because packages are no longer compatible or the image gets retired by the provider since it is now EOL. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-20The 19th batchJunio C Hamano1-4/+20
Merge the topics that have been cooking since 2024-09-13 or so in 'next'. Let's try a new workflow to update the maintenance track by removing the "merge ... later to maint" comments from the draft release notes on the 'master' track. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-20Merge branch 'jk/git-pm-bare-repo-fix'Junio C Hamano3-9/+13
In Git 2.39, Git.pm stopped working in a bare repository, which has been corrected. * jk/git-pm-bare-repo-fix: Git.pm: use "rev-parse --absolute-git-dir" rather than perl code Git.pm: fix bare repository search with Directory option
2024-09-20Merge branch 'bb/unicode-width-table-16'Junio C Hamano1-12/+25
Update the character width table for Unicode 16. * bb/unicode-width-table-16: unicode: update the width tables to Unicode 16
2024-09-20Merge branch 'ma/test-libcurl-prereq'Junio C Hamano2-3/+5
Test portability fix. * ma/test-libcurl-prereq: t0211: add missing LIBCURL prereq t1517: add missing LIBCURL prereq
2024-09-20Merge branch 'jk/interop-test-build-options'Junio C Hamano3-3/+13
The support to customize build options to adjust for older versions and/or older systems for the interop tests has been improved. * jk/interop-test-build-options: t/interop: allow per-version make options
2024-09-20Merge branch 'jk/no-openssl-with-openssl-sha1'Junio C Hamano1-3/+4
The "imap-send" now allows to be compiled with NO_OPENSSL and OPENSSL_SHA1 defined together. * jk/no-openssl-with-openssl-sha1: imap-send: handle NO_OPENSSL even when openssl exists
2024-09-20Merge branch 'ps/leakfixes-part-6'Junio C Hamano42-72/+178
More leakfixes. * ps/leakfixes-part-6: (22 commits) builtin/repack: fix leaking keep-pack list merge-ort: fix two leaks when handling directory rename modifications match-trees: fix leaking prefixes in `shift_tree()` builtin/fmt-merge-msg: fix leaking buffers builtin/grep: fix leaking object context builtin/pack-objects: plug leaking list of keep-packs builtin/repack: fix leaking line buffer when packing promisors negotiator/skipping: fix leaking commit entries shallow: fix leaking members of `struct shallow_info` shallow: free grafts when unregistering them object: clear grafts when clearing parsed object pool gpg-interface: fix misdesigned signing key interfaces send-pack: fix leaking push cert nonce remote: fix leak in reachability check of a remote-tracking ref remote: fix leaking tracking refs builtin/submodule--helper: fix leaking refs on push-check submodule: fix leaking fetch task data upload-pack: fix leaking child process data on reachability checks builtin/push: fix leaking refspec query result send-pack: fix leaking common object IDs ...
2024-09-20Merge branch 'pw/rebase-autostash-fix'Junio C Hamano4-10/+81
"git rebase --autostash" failed to resurrect the autostashed changes when the command gets aborted after giving back control asking for hlep in conflict resolution. * pw/rebase-autostash-fix: rebase: apply and cleanup autostash when rebase fails to start
2024-09-19gitlab-ci: upgrade machine type of Linux runnersPatrick Steinhardt1-0/+2
With the recent effort to make the test suite free of memory leaks we now run a lot more of test suites with the leak-sanitizer enabled. While we were originally only executing around 23000 tests, we're now at 30000 tests. Naturally, this has a significant impact on the runtime of such a test run. Naturally, this impact can also be felt for our leak-checking CI jobs. While macOS used to be the slowest-executing job on GitLab CI with ~15 minutes of runtime, nowadays it is our leak checks which take around 45 to 55 minutes. Our Linux runners for GitLab CI are untagged, which means that they default to the "small" machine type with two CPU cores [1]. Upgrade these to the "medium" runner, which provide four CPU cores and which should thus provide a noticeable speedup. In theory, we could upgrade to an ever larger machine than that. The official mirror [2] has an Ultimate license, so we could get up to 128 cores. But anybody running a fork of the Git project without such a license wouldn't be able to use those beefier machines and thus their pipelines would fail. [1]: https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html [2]: https://gitlab.com/git-scm/git/ Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19ref-filter: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19upload-pack: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19sideband: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19setup: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19run-command: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19revision: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19refs: fix typosAndrew Kreimer1-3/+3
Fix typos in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19rebase: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19read-cache-ll: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19pretty: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19object-file: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19merge-ort: fix typosAndrew Kreimer1-2/+2
Fix typos in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19merge-ll: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19http: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19gpg-interface: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19git-p4: fix typosAndrew Kreimer1-2/+2
Fix typos in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19git-instaweb: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19fsmonitor-settings: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19diffcore-rename: fix typosAndrew Kreimer1-2/+2
Fix typos in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-19config.mak.dev: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-18cmake: generalize the handling of the `UNIT_TEST_OBJS` listJohannes Schindelin1-3/+4
In a15d4465a991 (cmake: also build unit tests, 2023-09-25), I accommodated the CMake definition. Seeing that a `UNIT_TEST_OBJS` list was introduced that was built by transforming the `UNIT_TEST_PROGRAMS` list and then adding a single, hard-coded file ("t/unit-tests/test-lib.c"), I decided to hard-code that in the CMake definition, too. The reason why I hard-coded it instead of imitating the `parse_makefile_for_sources()` paradigm that was used elsewhere when using the `Makefile` as source of truth for given lists of files: This function expects _only_ hard-coded values, and that transformed `UNIT_TEST_PROGRAMS` list complicated everything. In 872721538c26 (cmake: fix build of `t-oidtree`, 2024-07-12), I accommodated the CMake definition again, after seeing that the `UNIT_TEST_OBJS` was still defined via that transformed list but now appending _two_ hard-coded files ("t/unit-tests/lib-oid.c" joined the fray). In 428672a3b16 (Makefile: stop listing test library objects twice, 2024-09-16), the `Makefile` was changed so that `UNIT_TEST_OBJS` is finally only constructed using hard-coded file names just like the other `*_OBJS` variables. I missed that and therefore did not adjust the CMake definition. Besides, the code was working, so there was no real need to adjust it. With a4f50bb1e9b (t/unit-tests: introduce reftable library, 2024-09-16), however, the `UNIT_TEST_OBJS` list became a trio, and the CMake definition has to be adjusted again. Now that we can use the `parse_makefile_for_sources()` function without many complications, let's do that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-18cmake: stop looking for `REFTABLE_TEST_OBJS` in the MakefileJohannes Schindelin1-5/+1
As of 15e29ea1c648 (t: move reftable/stack_test.c to the unit testing framework, 2024-09-08), the reftable tests are no longer part of `test-tool.exe`, so let's stop looking for those lines that are no longer in the `Makefile`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-18cmake: rename clar-related variables to avoid confusionJohannes Schindelin1-6/+6
In c3de556a841f (Makefile: rename clar-related variables to avoid confusion, 2024-09-10) some `Makefile` variables were renamed that were partially used by the CMake definition. Adapt the latter to the new lay of the land. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-18Merge branch 'ps/reftable-exclude' into jc/cmake-unit-test-updatesJunio C Hamano16-201/+594
* ps/reftable-exclude: refs/reftable: wire up support for exclude patterns reftable/reader: make table iterator reseekable t/unit-tests: introduce reftable library Makefile: stop listing test library objects twice builtin/receive-pack: fix exclude patterns when announcing refs refs: properly apply exclude patterns to namespaced refs
2024-09-18The eighteenth batchJunio C Hamano1-0/+5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-18Merge branch 'es/chainlint-message-updates'Junio C Hamano45-95/+113
The error messages from the test script checker have been improved. * es/chainlint-message-updates: chainlint: reduce annotation noise-factor chainlint: make error messages self-explanatory chainlint: don't be fooled by "?!...?!" in test body
2024-09-18Merge branch 'ps/clar-unit-test'Junio C Hamano31-234/+3459
Import clar unit tests framework libgit2 folks invented for our use. * ps/clar-unit-test: Makefile: rename clar-related variables to avoid confusion clar: add CMake support t/unit-tests: convert ctype tests to use clar t/unit-tests: convert strvec tests to use clar t/unit-tests: implement test driver Makefile: wire up the clar unit testing framework Makefile: do not use sparse on third-party sources Makefile: make hdr-check depend on generated headers Makefile: fix sparse dependency on GENERATED_H clar: stop including `shellapi.h` unnecessarily clar(win32): avoid compile error due to unused `fs_copy()` clar: avoid compile error with mingw-w64 t/clar: fix compatibility with NonStop t: import the clar unit testing framework t: do not pass GIT_TEST_OPTS to unit tests with prove
2024-09-17apply: refactor `struct image` to use a `struct strbuf`Patrick Steinhardt6-123/+79
The `struct image` uses a character array to track the pre- or postimage of a patch operation. This has multiple downsides: - It is somewhat hard to track memory ownership. In fact, we have several memory leaks in git-apply(1) because we do not (and cannot easily) free the buffer in all situations. - We have to reinvent the wheel and manually implement a lot of functionality that would already be provided by `struct strbuf`. - We have to carefully track whether `update_pre_post_images()` can do an in-place update of the postimage or whether it has to allocate a new buffer for it. This is all rather cumbersome, and especially `update_pre_post_images()` is really hard to understand as a consequence even though what it is doing is rather trivial. Refactor the code to use a `struct strbuf` instead, addressing all of the above. Like this we can easily perform in-place updates in all situations, the logic to perform those updates becomes way simpler and the lifetime of the buffer becomes a ton easier to track. This refactoring also plugs some leaking buffers as a side effect. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-17apply: rename members that track line count and allocation lengthPatrick Steinhardt1-46/+45
The `struct image` has two members `nr` and `alloc` that track the number of lines as well as how large its array is. It is somewhat easy to confuse these members with `len` though, which tracks the length of the `buf` member. Rename these members to `line_nr` and `line_alloc` respectively to avoid confusion. This is in line with how we typically name variables that track an array in this way. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-17apply: refactor code to drop `line_allocated`Patrick Steinhardt1-19/+14
The `struct image` has two members `line` and `line_allocated`. The former member is the one that should be used throughout the code, whereas the latter one is used to track whether the lines have been allocated or not. In practice, the array of lines is always allocated. The reason why we have `line_allocated` is that `remove_first_line()` will advance the array pointer to drop the first entry, and thus it points into the array instead of to the array header. Refactor the function to use memmove(3P) instead, which allows us to get rid of this double bookkeeping. This is less efficient, but I doubt that this matters much in practice. If this judgement call is found to be wrong at a later point in time we can likely refactor the surrounding loop such that we first calculate the number of leading context lines to remove and then remove them in a single call to memmove(3P). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-17apply: introduce macro and function to init imagesPatrick Steinhardt1-8/+14
We're about to convert the `struct image` to gain a `struct strbuf` member, which requires more careful initialization than just memsetting it to zeros. Introduce the `IMAGE_INIT` macro and `image_init()` function to prepare for this change. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-17apply: rename functions operating on `struct image`Patrick Steinhardt1-31/+30
Rename functions operating on `struct image` to have a `image_` prefix to match our modern code style. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-17apply: reorder functions to move image-related things togetherPatrick Steinhardt1-53/+53
While most of the functions relating to `struct image` are relatively close to one another, `fuzzy_matchlines()` sits in between those even though it is rather unrelated. Reorder functions such that `struct image`-related functions are next to each other. While at it, move `clear_image()` to the top such that it is close to the struct definition itself. This makes this lifecycle-related thing easy to discover. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16ci updatesJunio C Hamano1-0/+4
This batch is solely to unbreak the 32-bit CI jobs that can no longer work with Ubuntu xenial image that is too ancient. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16Sync with 'maint'Junio C Hamano3-112/+32
2024-09-16Merge branch 'jk/ci-linux32-update'Junio C Hamano6-141/+50
CI updates * jk/ci-linux32-update: ci: add Ubuntu 16.04 job to GitLab CI ci: use regular action versions for linux32 job ci: use more recent linux32 image ci: unify ubuntu and ubuntu32 dependencies ci: drop run-docker scripts
2024-09-16Merge branch 'jc/ci-upload-artifact-and-linux32'Junio C Hamano1-6/+0
CI started failing completely for linux32 jobs, as the step to upload failed test directory uses GitHub actions that is deprecated and is now disabled. Remove the step so at least we will know if the tests are passing. * jc/ci-upload-artifact-and-linux32: ci: remove 'Upload failed tests' directories' step from linux32 jobs
2024-09-16Start preparing for Git 2.46.2Junio C Hamano3-2/+13
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16Merge branch 'jk/ci-linux32-update' into maint-2.46Junio C Hamano6-141/+50
CI updates * jk/ci-linux32-update: ci: add Ubuntu 16.04 job to GitLab CI ci: use regular action versions for linux32 job ci: use more recent linux32 image ci: unify ubuntu and ubuntu32 dependencies ci: drop run-docker scripts
2024-09-16Merge branch 'jc/ci-upload-artifact-and-linux32' into maint-2.46Junio C Hamano1-6/+0
CI started failing completely for linux32 jobs, as the step to upload failed test directory uses GitHub actions that is deprecated and is now disabled. Remove the step so at least we will know if the tests are passing. * jc/ci-upload-artifact-and-linux32: ci: remove 'Upload failed tests' directories' step from linux32 jobs
2024-09-16Revert "Merge branch 'jc/patch-id' into maint-2.46"Junio C Hamano2-112/+21
This reverts commit 41c952ebacf7e3369e7bee721f768114d65e50c4, reversing changes made to 712d970c0145b95ce655773e7cd1676f09dfd215. Keeping a known breakage for now is better than introducing new regression(s).
2024-09-16The seventeenth batchJunio C Hamano1-0/+4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16Merge branch 'jk/ref-filter-trailer-fixes'Junio C Hamano10-33/+124
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-16Merge branch 'jc/range-diff-lazy-setup'Junio C Hamano13-44/+38
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-16Merge branch 'ah/apply-3way-ours'Junio C Hamano4-3/+67
"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-16Merge branch 'cp/unit-test-reftable-stack'Junio C Hamano9-415/+392
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-16refs/reftable: wire up support for exclude patternsPatrick Steinhardt4-12/+176
Exclude patterns can be used by reference backends to skip over blocks of references that are uninteresting to the caller. Reference backends do not have to wire up support for them, and all callers are expected to behave as if the backend didn't support them. In fact, the only backend that supports exclude patterns right now is the "packed" backend. Exclude patterns can be quite an important performance optimization in repositories that have loads of references. The patterns are set up in case "transfer.hideRefs" and friends are configured during a fetch, so handling these patterns becomes important once there are lots of hidden refs in a served repository. Now that we have properly re-seekable reftable iterators we can also wire up support for these patterns in the "reftable" backend. Doing so is conceptually simple: once we hit a reference whose prefix matches the current exclude pattern we re-seek the iterator to the first reference that doesn't match the pattern anymore. This schema only works for trivial patterns that do not have any globbing characters in them, but this restriction also applies do the "packed" backend. This makes t1419 work with the "reftable" backend with some slight modifications. Of course it also speeds up listing of references with hidden refs. The following benchmark prints one reference with 1 million hidden references: Benchmark 1: HEAD~ Time (mean ± σ): 93.3 ms ± 2.1 ms [User: 90.3 ms, System: 2.5 ms] Range (min … max): 89.8 ms … 97.2 ms 33 runs Benchmark 2: HEAD Time (mean ± σ): 4.2 ms ± 0.6 ms [User: 2.2 ms, System: 1.8 ms] Range (min … max): 3.1 ms … 8.1 ms 765 runs Summary HEAD ran 22.15 ± 3.19 times faster than HEAD~ Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16reftable/reader: make table iterator reseekablePatrick Steinhardt4-0/+174
In 67ce50ba26 (Merge branch 'ps/reftable-reusable-iterator', 2024-05-30) we have refactored the interface of reftable iterators such that they can be reused in theory. This patch series only landed the required changes on the interface level, but didn't yet implement the actual logic to make iterators reusable. As it turns out almost all of the infrastructure already does support re-seeking. The only exception is the table iterator, which does not reset its `is_finished` bit. Do so and add a couple of tests that verify that we can re-seek iterators. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16t/unit-tests: introduce reftable libraryPatrick Steinhardt6-179/+177
We have recently migrated all of the reftable unit tests that were part of the reftable library into our own unit testing framework. As part of that migration we have duplicated some of the functionality that was part of the reftable test framework into each of the migrated test suites. This was a sensible decision to not have all of the migrations dependent on each other, but now that the migration is done it makes sense to deduplicate the functionality again. Introduce a new reftable test library that hosts some shared code and adapt tests to use it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16Makefile: stop listing test library objects twicePatrick Steinhardt1-4/+2
Whenever one adds another test library compilation unit one has to wire it up twice in the Makefile: once to append it to `UNIT_TEST_OBJS`, and once to append it to the `UNIT_TEST_PROGS` target. Ideally, we'd just reuse the `UNIT_TEST_OBJS` variable in the target so that we can avoid the duplication. But it also contains all the objects for our test programs, each of which contains a `cmd_main()`, and thus we cannot link them all into the target executable. Refactor the code such that `UNIT_TEST_OBJS` does not contain the unit test program objects anymore, which we can instead manually append to the `OBJECTS` variable. Like this, the former variable now only contains objects for test libraries and can thus be reused. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16builtin/receive-pack: fix exclude patterns when announcing refsPatrick Steinhardt2-2/+24
In `write_head_info()` we announce references to the remote client. We need to honor "transfer.hideRefs" here so that we do not announce any references that the client shouldn't be able to learn about. This is done via two separate mechanisms: - We hand over exclude patterns to the reference backend. We can only honor "plain" exclude patterns here that do not have prefixes with special meaning such as "^" or "!". Filtering down the references is handled by `hidden_refs_to_excludes()`. - In `show_ref_cb()` we perform a second check against hidden refs. For one this is done such that we can handle those special prefixes. And second, handling exclude patterns in ref backends is optional, so we also have to handle "normal" patterns. The special-meaning "^" prefix alters whether a hidden ref applies to the namespace-stripped reference name or the full name. So while we would usually call `refs_for_each_namespaced_ref()` to only get those references in the current namespace, we can't because we'd get the already-rewritten reference names. Instead, we are forced to use `refs_for_each_fullref_in()` and then manually strip away the namespace prefix such that we have access to both names. But this also means that we do not get namespace handling for exclude patterns, which `refs_for_each_namespaced_ref()` brings for free. This results in a bug because we potentially end up hiding away references based on their namespaced name and not on the stripped name as we really should be doing. Fix this by manually rewriting the exclude patterns to their namespaced variants. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16refs: properly apply exclude patterns to namespaced refsPatrick Steinhardt3-4/+41
Reference namespaces allow commands like git-upload-pack(1) to serve different sets of references to the client depending on which namespace is enabled, which is for example useful in fork networks. Namespaced refs are stored with a `refs/namespaces/$namespace` prefix, but all the user will ultimately see is a stripped version where that prefix is removed. The way that this interacts with "transfer.hideRefs" is not immediately obvious: the hidden refs can either apply to the stripped references, or to the non-stripped ones that still have the namespace prefix. In fact, the "transfer.hideRefs" machinery does the former and applies to the stripped reference by default, but rules can have "^" prefixed to switch this behaviour to instead match against the full reference name. Namespaces are exclusively handled at the generic "refs" layer, the respective backends have no clue that such a thing even exists. This also has the consequence that they cannot handle hiding references as soon as reference namespaces come into play because they neither know whether a namespace is active, nor do they know how to strip references if they are active. Handling such exclude patterns in `refs_for_each_namespaced_ref()` and `refs_for_each_fullref_in_prefixes()` is broken though, as both support that the user passes both namespaces and exclude patterns. In the case where both are set we will exclude references with unstripped names, even though we really wanted to exclude references based on their stripped names. This only surfaces when: - A repository uses reference namespaces. - "transfer.hideRefs" is active. - The namespaced references are packed into the "packed-refs" file. None of our tests exercise this scenario, and thus we haven't ever hit it. While t5509 exercises both (1) and (2), it does not happen to hit (3). It is trivial to demonstrate the bug though by explicitly packing refs in the tests, and then we indeed surface the breakage. Fix this bug by prefixing exclude patterns with the namespace in the generic layer. The newly introduced function will be used outside of "refs.c" in the next patch, so we add a declaration to "refs.h". Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16cbtree: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16bloom: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16attr: fix a typoAndrew Kreimer1-1/+1
Fix a typo in comments. Signed-off-by: Andrew Kreimer <algonell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16t9001: use a more distinct fake BugIDJeff King1-2/+2
In the test "cc list is sanitized", we feed a commit with a variety of trailers to send-email, and then check its output to see how it handled them. For most of them, we are grepping for a specific mention of the header, but there's a "BugID" header which we expect to be ignored. We confirm this by grepping for "12345", the fake BugID, and making sure it is not present. But we can be fooled by false positives! I just tracked down a flaky test failure here that was caused by matching this unrelated line in the output: <20240914090449.612345-1-author@example.com> which will change from run to run based on the time, pid, etc. Ideally we'd tighten the regex to make this more specifically, but since the point is that it _shouldn't_ be mentioned, it's hard to say what the right match would be (e.g., would there be a leading space?). Instead, let's just choose a match that is much less likely to appear. The actual content of the header isn't important, since it's supposed to be ignored. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16git-jump: ignore deleted files in diff modeJeff King1-1/+1
If you do something like this: rm file_a echo change >file_b git jump diff then we'll generate two quickfix entries for the diff, one for each file. But the one for the deleted file is rather pointless. There's no content to show since the file is gone, and in fact we open the editor with the path /dev/null! In vim, at least, the result is a confusing annoyance: the editor opens with an empty buffer, and you have to skip past it to the useful quickfix entry (after scratching your head and figuring out that no, nothing is broken). Let's skip such entries entirely. There's nothing useful to show, since the point is that the file has been deleted. It is possible that you could be doing a diff whose post-image is not the working tree, and then you'd perhaps be jumping to the deleted content (or at least something that was in the same spot). But I don't think it's worth worrying about that case. For one thing, using git-jump for such diffs is a bad idea in general, as it's going to sometimes move you to the wrong spot. And two, a deletion is always going to have one hunk starting at line 1, which is not that interesting to jump to in the first place. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-16git-jump: always specify column 1 for diff entriesJeff King1-1/+1
When we generate a quickfix entry for a diff hunk, we provide just the filename and line number along with the content, like: file:1: contents of the line This can be a problem if the line itself looks like a quickfix header. For example (and this is adapted from a real-world case that bit me): echo 'static_lease 10:11:12:13:14:15:16 10.0.0.1' >file git add file echo change >file produces: file:1: static_lease 10:11:12:13:14:15:16 10.0.0.1 which is ambiguous. It could be line 1 of "file", or line 11 of the file "file:1: static_lease 10", and so on. In the case of vim's default config, it seems to prefer the latter (you can configure "errorformat" with a variety of patterns, but out of the box it matches some common ones). One easy way to fix this is to provide a column number, like: file:1:1: static_lease 10:11:12:13:14:15:16 10.0.0.1 which causes vim to prefer line 1 of "file" again (due to the preference order of the various patterns in the default errorformat). There are other options. For example, at least in my version of vim, wrapping the file in quotation marks like: "file":1: static_lease 10:11:12:13:14:15:16 10.0.0.1 also works. That perhaps would the right thing even if you had the silly file name "file:1:1: foo 10". But it's not clear what would happen if you had a filename with quotes in it. This feature is inherently scraping text, and there's bound to be some ambiguities. I don't think it's worth worrying too much about unlikely filenames, as its the file content that is more likely to introduce unexpected characters. So let's just go with the extra ":1" column specifier. We know this is supported everywhere, as git-jump's "grep" mode already uses it (and thus doesn't exhibit the same problem). The "merge" mode is mostly immune to this, as it only matches "<<<<<<<" conflict marker lines. It's possible of course to have a marker that says "foo 10:11" later in the line, but in practice these will only have branches and perhaps file names, so it's probably not worth worrying about (and fixing it would involve passing --column to the system grep, which may not be portable). I also gave some thought as to whether we could put something more useful than "1" in the column field for diffs. In theory we could find the first changed character of the line, but this is tricky in practice. You'd have to correlate before/after lines of the hunk to decide what changed. So: -this is a foo line +this is a bar line is easy (column 11). But: -this is a foo line +another line +this is a bar line is harder. This commit certainly doesn't preclude trying to do something more clever later, but it's a much deeper rabbit hole than just fixing the syntactic ambiguity. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-14print an error when remote helpers die during capabilitiesJeff King2-3/+24
The transport-helper code generally relies on the remote-helper to provide an informative message to the user when it encounters an error. In the rare cases where the helper does not do so, the output can be quite confusing. E.g.: $ git clone https://example.com/foo.git Cloning into 'foo'... $ echo $? 128 $ ls foo /bin/ls: cannot access foo: No such file or directory We tried to address this with 81d340d (transport-helper: report errors properly, 2013-04-10). But that makes the common case much more confusing. The remote helper protocol's method for signaling normal errors is to simply hang up. So when the helper does encounter a routine error and prints something to stderr, the extra error message is redundant and misleading. So we dropped it again in 266f1fd (transport-helper: be quiet on read errors from helpers, 2013-06-21). This puts the uncommon case right back where it started. We may be able to do a little better, though. It is common for the helper to die during a "real" command, like fetching the list of remote refs. It is not common for it to die during the initial "capabilities" negotiation, right after we start. Reporting failure here is likely to catch fundamental problems that prevent the helper from running (and reporting errors) at all. Anything after that is the responsibility of the helper itself to report. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13Sync with Git 2.46.1Junio C Hamano2-16/+9
2024-09-13The sixteenth batchJunio C Hamano1-0/+22
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13Merge branch 'bl/trailers-and-incomplete-last-line-fix'Junio C Hamano2-0/+41
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-13Merge branch 'rj/cygwin-has-dev-tty'Junio C Hamano1-0/+1
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-13Merge branch 'rs/diff-exit-code-fix'Junio C Hamano2-0/+42
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-13Merge branch 'jc/doc-skip-fetch-all-and-prefetch'Junio C Hamano3-8/+13
Doc updates. * jc/doc-skip-fetch-all-and-prefetch: doc: remote.*.skip{DefaultUpdate,FetchAll} stops prefetch
2024-09-13Merge branch 'ds/doc-wholesale-disabling-advice-messages'Junio C Hamano2-1/+18
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-13Merge branch 'jk/sparse-fdleak-fix'Junio C Hamano1-11/+10
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-13Merge branch 'ds/scalar-no-tags'Junio C Hamano3-3/+37
The "scalar clone" command learned the "--no-tags" option. * ds/scalar-no-tags: scalar: add --no-tags option to 'scalar clone'
2024-09-13Git 2.46.1v2.46.1Junio C Hamano2-1/+10
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13Merge branch 'rj/compat-terminal-unused-fix' into maint-2.46Junio C Hamano1-1/+1
Build fix. * rj/compat-terminal-unused-fix: compat/terminal: mark parameter of git_terminal_prompt() UNUSED
2024-09-13Merge branch 'jc/config-doc-update' into maint-2.46Junio C Hamano2-3/+3
Docfix. * jc/config-doc-update: git-config.1: fix description of --regexp in synopsis git-config.1: --get-all description update
2024-09-13Merge branch 'aa/cat-file-batch-output-doc' into maint-2.46Junio C Hamano1-3/+3
Docfix. * aa/cat-file-batch-output-doc: docs: explain the order of output in the batched mode of git-cat-file(1)
2024-09-13Merge branch 'cl/config-regexp-docfix' into maint-2.46Junio C Hamano1-1/+1
Docfix. * cl/config-regexp-docfix: doc: replace 3 dash with correct 2 dash in git-config(1)
2024-09-13Merge branch 'jc/coding-style-c-operator-with-spaces' into maint-2.46Junio C Hamano1-1/+10
Write down whitespacing rules around C opeators. * jc/coding-style-c-operator-with-spaces: CodingGuidelines: spaces around C operators
2024-09-13Merge branch 'ps/stash-keep-untrack-empty-fix' into maint-2.46Junio C Hamano2-1/+37
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-13Merge branch 'ps/index-pack-outside-repo-fix' into maint-2.46Junio C Hamano2-0/+48
"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-13Merge branch 'jk/free-commit-buffer-of-skipped-commits' into maint-2.46Junio C Hamano1-0/+1
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-13add: pass in repo variable instead of global the_repositoryJohn Cai3-55/+68
With the repository variable available in the builtin function as an argument, pass this down into helper functions instead of using the global the_repository. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13builtin: remove USE_THE_REPOSITORY for those without the_repositoryJohn Cai9-9/+0
For builtins that do not operate on a repository, remove the #define USE_THE_REPOSITORY. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.hJohn Cai125-92/+147
Instead of including USE_THE_REPOSITORY_VARIABLE by default on every builtin, remove it from builtin.h and add it to all the builtins that include builtin.h (by definition, that means all builtins/*.c). Also, remove the include statement for repository.h since it gets brought in through builtin.h. The next step will be to migrate each builtin from having to use the_repository. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13builtin: add a repository parameter for builtin functionsJohn Cai127-296/+703
In order to reduce the usage of the global the_repository, add a parameter to builtin functions that will get passed a repository variable. This commit uses UNUSED on most of the builtin functions, as subsequent commits will modify the actual builtins to pass the repository parameter down. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13t5512.40 sometimes dies by SIGPIPEJunio C Hamano1-0/+1
The last test in t5512 we recently added seems to be flaky. Running $ make && cd t && sh ./t5512-ls-remote.sh --stress shows that "git ls-remote foo::bar" exited with status 141, which means we got a SIGPIPE. This test piece was introduced by 9e89dcb6 (builtin/ls-remote: fall back to SHA1 outside of a repo, 2024-08-02) and is pretty much independent from all other tests in the script (it can even run standalone with everything before it removed). The transport-helper.c:get_helper() function tries to write to the helper. As we can see the helper script is very short and can exit even before it reads anything, when get_helper() tries to give the first command, "capabilities", the helper may already be gone. A trivial fix, presented here, is to make sure that the helper reads the first command it is given, as what it writes later is a response to that command. I however would wonder if the interactions with the helper initiated by get_helper() should be done on a non-blocking I/O (we do check the return value from our write(2) system calls, do we?). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13Git.pm: use "rev-parse --absolute-git-dir" rather than perl codeJeff King1-5/+5
When we open a repository with the "Directory" option, we use "rev-parse --git-dir" to get the path relative to that directory, and then use Cwd::abs_path() to make it absolute (since our process working directory may not be the same). These days we can just ask for "--absolute-git-dir" instead, which saves us a little code. That option was added in Git v2.13.0 via a2f5a87626 (rev-parse: add '--absolute-git-dir' option, 2017-02-03). I don't think we make any promises about running mismatched versions of git and Git.pm, but even if somebody tries it, that's sufficiently old that it should be OK. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13Git.pm: fix bare repository search with Directory optionJeff King3-7/+11
When opening a bare repository like: Git->repository(Directory => '/path/to/bare.git'); we will incorrectly point the repository object at the _current_ directory, not the one specified by the option. The bug was introduced by 20da61f25f (Git.pm: trust rev-parse to find bare repositories, 2022-10-22). Before then, we'd ask "rev-parse --git-dir" if it was a Git repo, and if it returned anything, we'd correctly convert that result to an absolute path using File::Spec and Cwd::abs_path(). If it didn't, we'd guess it might be a bare repository and find it ourselves, which was wrong (rev-parse should find even a bare repo, and our search circumvented some of its rules). That commit dropped most of the custom bare-repo search code in favor of using "rev-parse --is-bare-repository" and trusting the "--git-dir" it returned. But it mistakenly left some of the bare-repo code path in place, which was now broken. That code calls Cwd::abs_path($dir); prior to 20da61f25f $dir contained the "Directory" option the user passed in. But afterwards, it contains the output of "rev-parse --git-dir". And since our tentative rev-parse command is invoked after changing directory, it will always be the relative path "."! So we'll end up with the absolute path of the process's current directory, not the Directory option the caller asked for. So the non-bare case is correct, but the bare one is broken. Our tests only check the non-bare one, so we didn't notice. We can fix this by running the same absolute-path fixup code for both sides. Helped-by: Rodrigo <rodrigolive@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-13ci: add Ubuntu 16.04 job to GitLab CIPatrick Steinhardt3-1/+16
In the preceding commits we had to convert the linux32 job to be based on Ubuntu 20.04 instead of Ubuntu 16.04 due to a limitation in GitHub Workflows. This was the only job left that still tested against this old but supported Ubuntu version, and we have no other jobs that test with a comparatively old Linux distribution. Add a new job to GitLab CI that tests with Ubuntu 16.04 to cover the resulting test gap. GitLab doesn't modify Docker images in the same way GitHub does and thus doesn't fall prey to the same issue. There are two compatibility issues uncovered by this: - Ubuntu 16.04 does not support HTTP/2 in Apache. We thus cannot set `GIT_TEST_HTTPD=true`, which would otherwise cause us to fail when Apache fails to start. - Ubuntu 16.04 cannot use recent JGit versions as they depend on a more recent Java runtime than we have available. We thus disable installing any kind of optional dependencies that do not come from the package manager. These two restrictions are fine though, as we only really care about whether Git compiles and runs on such old distributions in the first place. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12unicode: update the width tables to Unicode 16Beat Bolli1-12/+25
Unicode 16 has been announced on 2024-09-10 [0], so update the character width tables to the new version. [0] https://blog.unicode.org/2024/09/announcing-unicode-standard-version-160.html Signed-off-by: Beat Bolli <dev+git@drbeat.li> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12t/interop: allow per-version make optionsJeff King3-3/+13
Building older versions of Git may require tweaking some build knobs. In particular, very old versions of Git will fail to build with recent OpenSSL, because the bignum type switched from a struct to a pointer. The i5500 interop test uses Git v1.0.0 by default, which triggers this problem. You can work around it by setting NO_OPENSSL in your GIT_TEST_MAKE_OPTS variable. But there are two downsides: 1. You have to know to do this, and it's not at all obvious. 2. That sets the options for _all_ versions of Git that we build. And it's possible for two versions to require conflicting knobs. E.g., building with "make NO_OPENSSL=Nope OPENSSL_SHA1=Yes" causes imap-send.c to barf, because it declares a fallback typedef for SSL. This is something we may want to fix, but of course many historical versions are affected, and the interop scripts should be flexible enough to build everything. So let's introduce per-version make options, along with the ability for scripts to specify knobs that match their default versions. That should make everything build out of the box, but also allow testers flexibility if they are testing interoperability between non-default versions. We'll set NO_OPENSSL by default for v1.0.0 in i5500. It doesn't have to worry about the conflict with OPENSSL_SHA1 because imap-send did not exist back then (but if it did, it could also just explicitly use a different hash implementation). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12Sync with 'maint'Junio C Hamano1-0/+7
2024-09-12The fifteenth batchJunio C Hamano1-0/+19
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12Merge branch 'kl/cat-file-on-sparse-index'Junio C Hamano2-5/+48
"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-12Merge branch 'jk/messages-with-excess-lf-fix'Junio C Hamano12-22/+22
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-12Merge branch 'ps/pack-refs-auto-heuristics'Junio C Hamano6-27/+194
"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-12Merge branch 'tb/multi-pack-reuse-fix'Junio C Hamano5-17/+78
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-12Merge branch 'gt/unit-test-oid-array'Junio C Hamano8-175/+136
Another unit-test. * gt/unit-test-oid-array: t: port helper/test-oid-array.c to unit-tests/t-oid-array.c
2024-09-12Merge branch 'ps/index-pack-outside-repo-fix'Junio C Hamano2-0/+48
"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-12Merge branch 'jc/mailinfo-header-cleanup'Junio C Hamano1-12/+11
Code clean-up. * jc/mailinfo-header-cleanup: mailinfo: we parse fixed headers
2024-09-12Another batch of topics for 2.46.1Junio C Hamano1-0/+7
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12Merge branch 'jc/grammo-fixes' into maint-2.46Junio C Hamano2-2/+2
Doc updates. * jc/grammo-fixes: doc: grammofix in git-diff-tree tutorial: grammofix
2024-09-12Merge branch 'jc/tests-no-useless-tee' into maint-2.46Junio C Hamano2-3/+3
Test fixes. * jc/tests-no-useless-tee: tests: drop use of 'tee' that hides exit status
2024-09-12Merge branch 'jc/how-to-maintain-updates' into maint-2.46Junio C Hamano1-0/+4
Doc updates. * jc/how-to-maintain-updates: howto-maintain: mention preformatted docs
2024-09-12Merge branch 'ps/bundle-outside-repo-fix' into maint-2.46Junio C Hamano3-3/+41
"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-12Merge branch 'jc/patch-id' into maint-2.46Junio C Hamano2-21/+112
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-12Merge branch 'jk/apply-patch-mode-check-fix' into maint-2.46Junio C Hamano2-0/+63
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-12imap-send: handle NO_OPENSSL even when openssl existsJeff King1-3/+4
If NO_OPENSSL is defined, then imap-send.c defines a fallback "SSL" type, which is just a void pointer that remains NULL. This works, but it has one problem: it is using the type name "SSL", which conflicts with the upstream name, if some other part of the system happens to include openssl. For example: $ make NO_OPENSSL=Nope OPENSSL_SHA1=Yes imap-send.o CC imap-send.o imap-send.c:35:15: error: conflicting types for ‘SSL’; have ‘void *’ 35 | typedef void *SSL; | ^~~ In file included from /usr/include/openssl/evp.h:26, from sha1/openssl.h:4, from hash.h:10, from object.h:4, from commit.h:4, from refs.h:4, from setup.h:4, from imap-send.c:32: /usr/include/openssl/types.h:187:23: note: previous declaration of ‘SSL’ with type ‘SSL’ {aka ‘struct ssl_st’} 187 | typedef struct ssl_st SSL; | ^~~ make: *** [Makefile:2761: imap-send.o] Error 1 This is not a terribly common combination in practice: 1. Why are we disabling openssl support but still using its sha1? The answer is that you may use the same build options across many versions, and some older versions of Git no longer build with modern versions of openssl. 2. Why are we using a totally unsafe sha1 that does not detect collisions? You're right, we shouldn't. But in preparation for using unsafe sha1 for non-cryptographic checksums, it would be nice to be able to turn it on without hassle. We can make this work by adjusting the way imap-send handles its fallback. One solution is something like this: #ifdef NO_OPENSSL #define git_SSL void * #else #define git_SSL SSL #endif But we can observe that we only need this definition in one spot: the struct which holds the variable. So rather than play around with macros that may cause unexpected effects, we can just directly use the correct type in that struct. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12ci: use regular action versions for linux32 jobJeff King1-4/+4
The linux32 job runs inside a docker container with a 32-bit libc, etc. This breaks any GitHub Actions scripts that are implemented in javascript, because they ship with their own 64-bit version of Node.js that's dynamically linked. They'll fail with a message like: exec /__e/node20/bin/node: no such file or directory because they can't find the runtime linker. This hasn't been a problem until recently because we special-case older, non-javascript versions of these actions for the linux32 job. But it recently became an issue when our old version of actions/upload-artifact was deprecated, causing the job to fail. We worked around that in 90f2c7240c (ci: remove 'Upload failed tests' directories' step from linux32 jobs, 2024-09-09), but it meant a loss of functionality for that job. And we may eventually run into the same deprecation problem with actions/checkout, which can't just be removed. We can solve the linking issue by installing the 64-bit libc and stdc++ packages before doing anything else. Coupled with the switch to a more recent image in the previous patch, that lets us remove the special-casing of the action scripts entirely. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12ci: use more recent linux32 imageJeff King2-3/+12
The Xenial image we're using was released more than 8 years ago. This is a problem for using some recent GitHub Actions scripts, as they require Node.js 20, and all of the binaries they ship need glibc 2.28 or later. We're not using them yet, but moving forward prepares us for a future patch which will. Xenial was actually the last official 32-bit Ubuntu release, but you can still find i386 images for more recent releases. This patch uses Focal, which was released in 2020 (and is the oldest one with glibc 2.28). There are two small downsides here: - while Xenial is pretty old, it is still in LTS support until April 2026. So there's probably some value in testing with such an old system, and we're losing that. - there are no i386 subversion packages in the Focal repository. So we won't be able to test that (OTOH, we had never tested it until the previous patch which unified the 32/64-bit dependency code). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12ci: unify ubuntu and ubuntu32 dependenciesJeff King1-18/+16
The script to install dependencies has two separate entries for 32-bit and 64-bit Ubuntu systems. This increases the maintenance burden since both should need roughly the same packages. That hasn't been too bad so far because we've stayed on the same 32-bit image since 2017. Trying to move to a newer image revealed several problems with the linux32 job: - newer images complain about using "linux32 --32bit i386", due to seccomp restrictions. We can loosen these with a docker option, but I don't think running it is even doing anything. We use it only for pretending to "apt" that we're on a 32-bit machine, but inside the container image apt is already configured as a 32-bit system (even though the kernel outside the container is obviously 64-bit). Using the same apt invocation for both architectures just gets rid of this call entirely. - we set DEBIAN_FRONTEND to avoid hanging on packages that ask the user questions. This wasn't a problem on the old image, but it is on newer ones. The 64-bit stanza handles this already. As a bonus, the 64-bit stanza uses "apt -q" instead of redirecting output to /dev/null. This would have saved me a lot of debugging time trying to figure out why it was hanging. :) - the old image seems to have zlib-dev installed by default, but newer ones do not. In addition, there were probably many tests being skipped on the 32-bit build because we didn't have support packages installed (e.g., gpg). Now we'll run them. We do need to keep some parts split off just for 64-bit systems: our p4 and lfs installs reference x86_64/amd64 binaries. The downloaded jgit should work in theory, since it's just a jar file embedded in a shell script that relies on the system java. But the system java in our image is too old, so I've left it as 64-bit only for now. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12ci: drop run-docker scriptsJeff King2-113/+0
We haven't used these scripts since 4a6e4b9602 (CI: remove Travis CI support, 2021-11-23), as the GitHub Actions config has support for directly running jobs within docker containers. It's possible we might want to resurrect something like this in order to be more agnostic to the CI platform. But it's not clear exactly what it would look like. And in the meantime, it's just a maintenance burden as we make changes to CI config, and is subject to bitrot. In fact it's already broken; it references ci/install-docker-dependencies.sh, which went away in 9cdeb34b96 (ci: merge scripts which install dependencies, 2024-04-12). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: stop storing "core.notesRef" globallyPatrick Steinhardt6-28/+29
Stop storing the "core.notesRef" config value globally. Instead, retrieve the value in `default_notes_ref()`. The code is never called in a hot loop anyway, so doing this on every invocation should be perfectly fine. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: stop storing "core.warnAmbiguousRefs" globallyPatrick Steinhardt9-13/+23
Same as the preceding commits, storing the "core.warnAmbiguousRefs" value globally is misdesigned as this setting may be set per repository. Move the logic into the repo-settings subsystem. The usual pattern here is that users are expected to call `prepare_repo_settings()` before they access the settings themselves. This seems somewhat fragile though, as it is easy to miss and leads to somewhat ugly code patterns at the call sites. Instead, introduce a new function that encapsulates this logic for us. This also allows us to change how exactly the lazy initialization works in the future, e.g. by only partially initializing values as requested by the caller. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: stop storing "core.preferSymlinkRefs" globallyPatrick Steinhardt4-8/+4
Same as the preceding commit, storing the "core.preferSymlinkRefs" value globally is misdesigned as this setting may be set per repository. There is only a single user of this value anyway, namely the "files" backend. So let's just remove the global variable and read the value of this setting when initializing the backend. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: stop storing "core.logAllRefUpdates" globallyPatrick Steinhardt9-20/+32
The value of "core.logAllRefUpdates" is being stored in the global variable `log_all_ref_updates`. This design is somewhat aged nowadays, where it is entirely possible to access multiple repositories in the same process which all have different values for this setting. So using a single global variable to track it is plain wrong. Remove the global variable. Instead, we now provide a new function part of the repo-settings subsystem that parses the value for a specific repository. While that may require us to read the value multiple times, we work around this by reading it once when the ref backends are set up and caching the value there. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12refs: stop modifying global `log_all_ref_updates` variablePatrick Steinhardt7-26/+36
In refs-related code we modify the global `log_all_ref_updates` variable, which is done because `should_autocreate_reflog()` does not accept passing an `enum log_refs_config` but instead accesses the global variable. Adapt its interface such that the value is provided by the caller, which allows us to compute the proper value locally without having to modify global state. This change requires us to move the enum to "repo-settings.h", or otherwise we get compilation errors due to include cycles. We're about to fully move this setting into the repo-settings subsystem anyway, so this is fine. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12branch: stop modifying `log_all_ref_updates` variablePatrick Steinhardt1-2/+3
In "branch.c" we modify the global `log_all_ref_updates` variable to force creation of a reflog entry. Modifying global state like this is discouraged, as it may have all kinds of consequences in other places of our codebase. Stop modifying the variable and pass the `REF_FORCE_CREATE_REFLOG` flag instead. Setting this flag has a stronger meaning than setting the config to `LOG_REFS_NORMAL`: - `LOG_REFS_NORMAL` will ask us to only create reflog entries for preexisting reflogs or branches, remote refs, note refs and HEAD. - `REF_FORCE_CREATE_REFLOG` will unconditionally create a reflog and is thus equivalent to `LOG_REFS_ALWAYS`. But as we are in `create_branch()` and thus do not have to worry about arbitrary references, but only about branches, `LOG_REFS_NORMAL` and `LOG_REFS_ALWAYS` are indeed equivalent. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12repo-settings: track defaults close to `struct repo_settings`Patrick Steinhardt2-5/+9
The default values for `struct repo_settings` are set up in `prepare_repo_settings()`. This is somewhat different from how we typically do this, namely by providing an `INIT` macro that sets up the default values for us. Refactor the code to do the same. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12repo-settings: split out declarations into a standalone headerPatrick Steinhardt3-50/+58
While we have "repo-settings.c", we do not have a corresponding "repo-settings.h" file. Instead, this functionality is part of the "repository.h" header, making it hard to discover. Split the declarations out of "repository.h" and create a standalone header file with them. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: guard state depending on a repositoryPatrick Steinhardt14-1/+53
In "environment.h" we have quite a lot of functions and variables that either explicitly or implicitly depend on `the_repository`. The implicit set of stateful declarations includes for example variables which get populated when parsing a repository's Git configuration. This set of variables is broken by design, as their state often depends on the last repository config that has been parsed. So they may or may not represent the state of `the_repository`. Fixing that is quite a big undertaking, and later patches in this series will demonstrate a solution for a first small set of those variables. So for now, let's guard these with `USE_THE_REPOSITORY_VARIABLE` so that callers are aware of the implicit dependency. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: reorder header to split out `the_repository`-free sectionPatrick Steinhardt1-41/+40
Reorder the "environment.h" header such that declarations which are free from `the_repository` come before those which aren't. The new structure is now: - Defines for environment variable names. - Things which do not rely on a repository. - Things which do, including those that implicitly rely on a parsed repository. This includes for example variables which get populated when reading repository config. This will allow us to guard the last category of declarations with `USE_THE_REPOSITORY_VARIABLE`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: move `set_git_dir()` and related into setup layerPatrick Steinhardt4-107/+109
The functions `set_git_dir()` and friends are used to set up repositories. As such, they are quite clearly part of the setup subsystem, but still live in "environment.c". Move them over, which also helps to get rid of dependencies on `the_repository` in the environment subsystem. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_git_namespace()` self-containedPatrick Steinhardt1-28/+29
The logic to set up and retrieve `git_namespace` is distributed across different functions which communicate with each other via a global environment variable. This is rather pointless though, as the value is always derived from an environment variable, and this environment variable does not change after we have parsed global options. Convert the function to be fully self-contained such that it lazily populates once called. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: move object database functions into object layerPatrick Steinhardt5-50/+49
The `odb_mkstemp()` and `odb_pack_keep()` functions are quite clearly tied to the object store, but regardless of that they are located in "environment.c". Move them over, which also helps to get rid of dependencies on `the_repository` in the environment subsystem. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12config: make dependency on repo in `read_early_config()` explicitPatrick Steinhardt7-14/+20
The `read_early_config()` function can be used to read configuration where a repository has not yet been set up. As such, it is optional whether or not `the_repository` has already been initialized. If it was initialized we use its commondir and gitdir. If not, the function will try to detect the Git directories by itself and, if found, also parse their config files. This means that we implicitly rely on `the_repository`. Make this dependency explicit by passing a `struct repository`. This allows us to again drop the `USE_THE_REPOSITORY_VARIABLE` define in "config.c". Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12config: document `read_early_config()` and `read_very_early_config()`Patrick Steinhardt2-4/+11
It's not clear what `read_early_config()` and `read_very_early_config()` do differently compared to `repo_read_config()` from just looking at their names. Document both of these in the header file to clarify their intent. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_git_work_tree()` accept a repositoryPatrick Steinhardt18-34/+36
The `get_git_work_tree()` function retrieves the path of the work tree of `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_graft_file()` accept a repositoryPatrick Steinhardt6-13/+11
The `get_graft_file()` function retrieves the path to the graft file of `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_index_file()` accept a repositoryPatrick Steinhardt11-29/+36
The `get_index_file()` function retrieves the path to the index file of `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_object_directory()` accept a repositoryPatrick Steinhardt20-39/+43
The `get_object_directory()` function retrieves the path to the object directory for `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_git_common_dir()` accept a repositoryPatrick Steinhardt13-21/+22
The `get_git_common_dir()` function retrieves the path to the common directory for `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12environment: make `get_git_dir()` accept a repositoryPatrick Steinhardt21-38/+56
The `get_git_dir()` function retrieves the path to the Git directory for `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-11t0211: add missing LIBCURL prereqMartin Ågren1-2/+4
After building Git with NO_LIBCURL, we're lacking `git remote-http` and `git http-fetch`, so when we test that they trace as they should, we're bound to fail. Add the LIBCURL prereq to those tests. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-11t1517: add missing LIBCURL prereqMartin Ågren1-1/+1
After building Git with NO_LIBCURL, there is no `git remote-http`, so it's not meaningful to test that it can run outside of a repository. Indeed, that test will fail. Add the LIBCURL prereq to it. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10The fourteenth batchJunio C Hamano1-0/+10
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10Merge branch 'sp/mailmap'Junio C Hamano1-0/+1
Update to a mailmap entry. * sp/mailmap: .mailmap document current address.
2024-09-10Merge branch 'ps/declare-pack-redundamt-dead'Junio C Hamano1-0/+20
"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-10Merge branch 'ah/mergetols-vscode'Junio C Hamano1-0/+19
"git mergetool" learned to use VSCode as a merge backend. * ah/mergetols-vscode: mergetools: vscode: new tool
2024-09-10Merge branch 'rj/compat-terminal-unused-fix'Junio C Hamano1-1/+1
Build fix. * rj/compat-terminal-unused-fix: compat/terminal: mark parameter of git_terminal_prompt() UNUSED
2024-09-10Merge branch 'jk/free-commit-buffer-of-skipped-commits'Junio C Hamano1-0/+1
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-10Makefile: rename clar-related variables to avoid confusionPatrick Steinhardt1-17/+17
The Makefile variables related to the recently-introduced clar testing framework have a `UNIT_TESTS_` prefix. This prefix is extremely similar to the prefix used by our other unit tests that use our homegrown unit testing framework, which is `UNIT_TEST_`. The consequence is that it is easy to misread the names and confuse them with each other. Rename the clar-related variables to instead have a `CLAR_TEST_` prefix to address this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10chainlint: reduce annotation noise-factorEric Sunshine2-2/+3
When chainlint detects a problem in a test definition, it highlights the offending code with a "?!...?!" annotation. The rather curious "?!" decoration was chosen to draw the reader's attention to the problem area and to act as a good "needle" when using the terminal's search feature to "jump" to the next problem. Later, chainlint learned to color its output when sent to a terminal. Problem annotations are colored with a red background which stands out well from surrounding text, thus easily draws the reader's attention. Together with the preceding change which gave all problem annotations a uniform "LINT:" prefix, the noisy "?!" decoration has become superfluous as a search "needle" so omit it when output is colored. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10chainlint: make error messages self-explanatoryEric Sunshine44-90/+104
The annotations emitted by chainlint to indicate detected problems are overly terse, so much so that developers new to the project -- those who should most benefit from the linting -- may find them baffling. For instance, although the author of chainlint and seasoned Git developers may understand that "?!AMP?!" is an abbreviation of "ampersand" and indicates a break in the &&-chain, this may not be obvious to newcomers. The "?!LOOP?!" case is particularly serious because that terse single word does nothing to convey that the loop body should end with "|| return 1" (or "|| exit 1" in a subshell) to ensure that a failing command in the body aborts the loop immediately. Moreover, unlike &&-chaining which is ubiquitous in Git tests, the "|| return 1" idiom is relatively infrequent, thus may be harder for a newcomer to discover by consulting nearby code. Address these shortcomings by emitting human-readable messages which both explain the problem and give a strong hint about how to correct it. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10chainlint: don't be fooled by "?!...?!" in test bodyEric Sunshine1-5/+8
As originally implemented, chainlint did not collect structured information about detected problems. Instead, it merely emitted raw parse tokens (not the original test text), along with a "?!...?!" annotation directly into the output stream each time a problem was discovered. In order to report statistics (in --stats mode) and to adjust its exit code to indicate success or failure, it merely counts the number of times "?!...?!" appears in the output stream. An obvious shortcoming of this approach is that it can be fooled by a legitimate "?!...?!" sequence in the body of a test (though, only if an actual problem is detected in the test). The situation did not improve when 7c04aa7390 (chainlint: colorize problem annotations and test delimiters, 2022-09-13) colored the annotations after-the-fact by searching for "?!...?!" in the output stream and inserting color codes. As above, a shortcoming is that this approach can incorrectly color a legitimate "?!...?!" sequence in a test body as if it is an error. However, when 73c768dae9 (chainlint: annotate original test definition rather than token stream, 2022-11-08) taught chainlint to output the original test text verbatim, it started collecting structured information about detected problems. Now that it is available, take advantage of the structured problem information to deterministically count the number of problems detected and to color the annotations directly, rather than scanning the output stream for "?!...?!" and performing these operations after-the-fact. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10ref-filter: fix leak with unterminated %(if) atomsPatrick Steinhardt2-3/+6
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-09ref-filter: add ref_format_clear() functionJeff King7-0/+21
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-09ref-filter: fix leak when formatting %(push:remoteref)Jeff King3-6/+6
When we expand the %(upstream) or %(push) placeholders, we rely on remote.c's remote_ref_for_branch() to fill in the ":refname" argument. But that function has confusing memory ownership semantics: it may or may not return an allocated string, depending on whether we are in "upstream" mode or "push" mode. The caller in ref-filter.c always duplicates the result, meaning that we leak the original in the case of %(push:refname). To solve this, let's make the return value from remote_ref_for_branch() consistent, by always returning an allocated pointer. Note that the switch to returning a non-const pointer has a ripple effect inside the function, too. We were storing the "dst" result as a const pointer, too, even though it is always allocated! It is the return value from apply_refspecs(), which is always a non-const allocated string. And then on the caller side in ref-filter.c (and this is the only caller at all), we just need to avoid the extra duplication when the return value is non-NULL. This clears up one case that LSan finds in t6300, but there are more. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: fix leak with %(describe) argumentsJeff King1-5/+6
When we parse a %(describe) placeholder, we stuff its arguments into a strvec, which is then detached into the used_atom struct. But later, when ref_array_clear() frees the atom, we never free the memory. To solve this, we just need to add the appropriate free() calls. But it's a little awkward, since we have to free each element of the array, in addition to the array itself. Instead, let's store the actual strvec, which lets us do a simple strvec_clear(). This clears up one case that LSan finds in t6300, but there are more. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: fix leak of %(trailers) "argbuf"Jeff King1-3/+6
When we parse a placeholder like "%(trailers:key=foo)", our atom parsing function is passed just the argument string "key=foo". We duplicate this into its own string, but never free it, causing a leak. We do the duplication for two reasons: 1. There's a mismatch with the pretty.c trailer-formatting code that we rely on. It expects to see a closing paren, like "key=foo)". So we duplicate the argument string with that extra character to pass along. This is probably something we could fix in the long run, but it's somewhat non-trivial if we want to avoid regressing error cases for things like "git log --format='%(trailer:oops'". So let's accept it as a necessity for now. 2. The argument parser expects to store the list of "key" entries ("foo" in this case) in a string-list. It also stores the length of the string in the string-list "util" field. The original caller in pretty.c uses this with a "nodup" string list to avoid making extra copies, which creates a subtle dependency on the lifetime of the original format string. We do the same here, which creates that same dependency. So we can't simply free it as soon as the parsing is done. There are two possible solutions here. The first is to hold on to the duplicated "argbuf" string in the used_atom struct, so that it lives as long as the string_list which references it. But I think a less-subtle solution, and what this patch does, is to switch to a duplicating string_list. That makes it self-contained, and lets us free argbuf immediately. It may involve a few extra allocations, but this parsing is something that happens once per program, not once per output ref. This clears up one case that LSan finds in t6300, but there are more. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: store ref_trailer_buf data per-atomJeff King2-6/+49
The trailer API takes options via a trailer_opts struct. Some of those options point to data structures which require extra storage. Those structures aren't actually embedded in the options struct, but rather we pass pointers, and the caller is responsible for managing them. This is a little convoluted, but makes sense since some of them are not even concrete (e.g., you can pass a filter function and a void data pointer, but the trailer code doesn't even know what's in the pointer). When for-each-ref, etc, parse the %(trailers) placeholder, they stuff the extra data into a ref_trailer_buf struct. But we only hold a single static global instance of this struct. So if a format string has multiple %(trailer) placeholders, they'll stomp on each other: the "key" list will end up with entries for all of them, and the separator buffers will use the values from whichever was parsed last. Instead, we should have a ref_trailer_buf for each instance of the placeholder, and store it alongside the trailer_opts in the used_atom structure. And that's what this patch does. Note that we also have to add code to clean them up in ref_array_clear(). The original code did not bother cleaning them up, but it wasn't technically a "leak" since they were still reachable from the static global instance. Reported-by: Brooke Kuhlmann <brooke@alchemists.io> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: drop useless cast in trailers_atom_parser()Jeff King1-1/+1
There's no need to cast invalid_arg before freeing it. It is already a non-const pointer. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: strip signature when parsing tag trailersJeff King2-1/+27
To expand the "%(trailers)" placeholder, we have to feed the commit or tag body to the trailer API. But that API doesn't know anything about signatures, and will be confused by a signed tag like this: the subject the body Some-trailer: foo -----BEGIN PGP SIGNATURE----- ...etc... because it will start looking for trailers after the signature, and get stopped walking backwards by the very non-trailer signature lines. So it thinks there are no trailers. This problem has existed since %(trailers) was added to the ref-filter code, but back then trailers on tags weren't something we really considered (commits don't have the same problem because their signatures are embedded in the header). But since 066cef7707 (builtin/tag: add --trailer option, 2024-05-05), we'd generate an object like the above for "git tag -s --trailer 'Some-trailer: foo' my-tag". The implementation here is pretty simple: we just make a NUL-terminated copy of the non-signature part of the tag (which we've already parsed) and pass it to the trailer API. There are some alternatives I rejected, at least for now: - the trailer code already understands skipping past some cruft at the end of a commit, such as patch dividers. see find_end_of_log_message(). We could teach it to do the same for signatures. But since this is the only context where we'd want that feature, and since we've already parsed the object into subject/body/signature here, it seemed easier to just pass in the truncated message. - it would be nice if we could just pass in a pointer/len pair to the trailer API (rather than a NUL-terminated string) to avoid the extra copy. I think this is possible, since as noted above, the trailer code already has to deal with ignoring some cruft at the end of the input. But after an initial attempt at this, it got pretty messy, as we have to touch a lot of intermediate functions that are also called in other contexts. So I went for the simple and stupid thing, at least for now. I don't think the extra copy overhead will be all that bad. The previous patch noted that an extra copy seemed to cause about 1-2% slowdown for something simple like "%(subject)". But here we are only triggering it for "%(trailers)" (and only when there is a signature), and the trailer code is a bit allocation-heavy already. I couldn't measure any difference formatting "%(trailers)" on linux.git before and after (even though there are not even any trailers to find). Reported-by: Brooke Kuhlmann <brooke@alchemists.io> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ref-filter: avoid extra copies of payload/signatureJeff King1-8/+3
When we know we're going to show the subject or body of a tag or commit, we call find_subpos(), which returns pointers and lengths for the three parts: subject, body, signature. Oddly, the function finds the signature twice: once by calling parse_signature() at the start, which copies the signature into a separate strbuf, and then again by calling parse_signed_buffer() after we've parsed past the subject. This is due to 482c119186 (gpg-interface: improve interface for parsing tags, 2021-02-11) and 88bce0e24c (ref-filter: hoist signature parsing, 2021-02-11). The idea is that in a multi-hash world, tag signatures may appear in the header, rather than at the end of the body, in which case we need to extract them into a separate buffer. But parse_signature() would never find such a buffer! It only looks for signature lines (like "-----BEGIN PGP") at the start of each line, without any header keyword. So this code will never find anything except the usual in-body signature. And the extra code has two downsides: 1. We spend time copying the payload and signature into strbufs. That might even be useful if we ended up with a NUL-terminated copy of the payload data, but we throw it away immediately. And the signature, since it comes at the end of the message, is already its own NUL-terminated buffer. The overhead isn't huge, but I measured a pretty consistent 1-2% speedup running "git for-each-ref --format='%(subject)'" with this patch on a clone of linux.git. 2. The output of find_subpos() is a set of three ptr/len combinations, but only two of them point into the original buffer. This makes the interface confusing: you can't do pointer comparisons between them, and you have to remember to free the signature buffer. Since there's only one caller, it's not too bad in practice, but it did bite me while working on the next patch (and simplifying it will pave the way for that). In the long run we might have to go back to something like this approach, if we do have multi-hash header signatures. But I would argue that the extra buffer should kick in only for a header signature, and be passed out of find_subpos() separately. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09t6300: drop newline from wrapped test titleJeff King1-2/+1
We don't usually include newlines in test titles, because you get funny TAP output like: ok 417 - show good signature with custom format ok 418 - show good signature with custom format with ssh ok 419 - signature atom with grade option and bad signature where a TAP parser would ignore the extra line anyway, giving the wrong title. This comes from 26c9c03f0a (ref-filter: add new "signature" atom, 2023-06-04), and I think it was probably just editor line wrapping. I checked for other cases with: git grep "test_expect_success [A-Z_,]* '[^']*$" git grep 'test_expect_success [A-Z_,]* "[^"]*$' but this was the only hit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09ci: remove 'Upload failed tests' directories' step from linux32 jobsJunio C Hamano1-6/+0
Linux32 jobs seem to be getting: Error: This request has been automatically failed because it uses a deprecated version of `actions/upload-artifact: v1`. Learn more: https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/ before doing anything useful. For now, disable the step. Ever since actions/upload-artifact@v1 got disabled, mentioning the offending version of it seems to stop anything from happening. At least this should run the same build and test. See https://github.com/git/git/actions/runs/10780030750/job/29894867249 for example. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-09Merge branch 'cp/unit-test-reftable-stack' into ps/reftable-excludeJunio C Hamano9-415/+392
* 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-09t-reftable-stack: add test for stack iteratorsChandra Pratap1-0/+83
reftable_stack_init_ref_iterator and reftable_stack_init_log_iterator as defined by reftable/stack.{c,h} initialize a stack iterator to iterate over the ref and log records in a reftable stack respectively. Since these functions are not exercised by any of the existing tests, add a test for them. Mentored-by: Patrick Steinhardt <ps@pks.im> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>