summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2026-03-24Merge branch 'dd/cocci-do-not-pass-strbuf-by-value'Junio C Hamano2-3/+14
Add a coccinelle rule to break the build when "struct strbuf" gets passed by value. * dd/cocci-do-not-pass-strbuf-by-value: stash: do not pass strbuf by value coccinelle: detect struct strbuf passed by value
2026-03-24Merge branch 'ty/doc-diff-u-wo-number'Junio C Hamano2-4/+8
"git diff -U<num>" was too lenient in its command line parsing and took an empty string as a valid <num>. * ty/doc-diff-u-wo-number: diff: document -U without <n> as using default context
2026-03-24Merge branch 'ps/upload-pack-buffer-more-writes'Junio C Hamano14-47/+239
Reduce system overhead "git upload-pack" spends on relaying "git pack-objects" output to the "git fetch" running on the other end of the connection. * ps/upload-pack-buffer-more-writes: builtin/pack-objects: reduce lock contention when writing packfile data csum-file: drop `hashfd_throughput()` csum-file: introduce `hashfd_ext()` sideband: use writev(3p) to send pktlines wrapper: introduce writev(3p) wrappers compat/posix: introduce writev(3p) wrapper upload-pack: reduce lock contention when writing packfile data upload-pack: prefer flushing data over sending keepalive upload-pack: adapt keepalives based on buffering upload-pack: fix debug statement when flushing packfile data
2026-03-24Merge branch 'yc/histogram-hunk-shift-fix'Junio C Hamano3-2/+210
The final clean-up phase of the diff output could turn the result of histogram diff algorithm suboptimal, which has been corrected. * yc/histogram-hunk-shift-fix: xdiff: re-diff shifted change groups when using histogram algorithm
2026-03-24Merge branch 'mf/t0008-cleanup'Junio C Hamano1-1/+2
Test clean-up. * mf/t0008-cleanup: t0008: improve test cleanup to fix failing test
2026-03-24Merge branch 'pb/t4200-test-path-is-helpers'Junio C Hamano1-13/+13
Test clean-up. * pb/t4200-test-path-is-helpers: t4200: convert test -[df] checks to test_path_* helpers
2026-03-24Merge branch 'jk/transport-color-leakfix'Junio C Hamano1-3/+3
Leakfix. * jk/transport-color-leakfix: transport: plug leaks in transport_color_config()
2026-03-24Merge branch 'rj/pack-refs-tests-path-is-helpers'Junio C Hamano1-14/+14
Test updates. * rj/pack-refs-tests-path-is-helpers: t/pack-refs-tests: use test_path_is_missing
2026-03-24Merge branch 'ps/history-split'Junio C Hamano16-341/+1592
"git history" learned the "split" subcommand. * ps/history-split: builtin/history: implement "split" subcommand builtin/history: split out extended function to create commits cache-tree: allow writing in-memory index as tree add-patch: allow disabling editing of hunks add-patch: add support for in-memory index patching add-patch: remove dependency on "add-interactive" subsystem add-patch: split out `struct interactive_options` add-patch: split out header from "add-interactive.h"
2026-03-24Merge branch 'ps/clar-wo-path-max'Junio C Hamano2-15/+68
Clar (unit testing framework) update from the upstream. * ps/clar-wo-path-max: clar: update to fix compilation on platforms without PATH_MAX
2026-03-24Merge branch 'ss/t0410-delete-object-cleanup'Junio C Hamano1-1/+4
Test clean-up. * ss/t0410-delete-object-cleanup: t0410: modernize delete_object helper
2026-03-24Merge branch 'gj/user-manual-fix-grep-example'Junio C Hamano1-1/+1
Fix an example in the user-manual. * gj/user-manual-fix-grep-example: doc: fix git grep args order in Quick Reference
2026-03-24Merge branch 'jt/fast-import-sign-again'Junio C Hamano10-102/+225
"git fast-import" learned to optionally replace signature on commits whose signatures get invalidated due to replaying by signing afresh. * jt/fast-import-sign-again: fast-import: add mode to sign commits with invalid signatures gpg-interface: allow sign_buffer() to use default signing key commit: remove unused forward declaration
2026-03-24use strvec_pushv() to add another strvecJunio C Hamano5-13/+51
Add and apply a semantic patch that simplifies the code by letting strvec_pushv() append the items of a second strvec instead of pushing them one by one. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-24Merge branch 'ps/build-tweaks' into rs/use-strvec-pushvJunio C Hamano49-99/+123
The topic moves the coccinelle rules from contrib/ to tools/ directory, breaking merges with this topic. * ps/build-tweaks: meson: precompile "git-compat-util.h" meson: compile compatibility sources separately git-compat-util.h: move warning infra to prepare for PCHs builds: move build scripts into "tools/" contrib: move "update-unicode.sh" script into "tools/" contrib: move "coverage-diff.sh" script into "tools/" contrib: move "coccinelle/" directory into "tools/" Introduce new "tools/" directory
2026-03-24commit-graph: fix writing generations with dates exceeding 34 bitsPatrick Steinhardt2-3/+54
The `timestamp_t` type is declared as `uintmax_t` and thus typically has 64 bits of precision. Usually, the full precision of such dates is not required: it would be comforting to know that Git is still around in millions of years, but all in all the chance is rather low. We abuse this fact in the commit-graph: instead of storing the full 64 bits of precision, committer dates only store 34 bits. This is still plenty of headroom, as it means that we can represent dates until year 2514. Commits which are dated beyond that year will simply get a date whose remaining bits are masked. The result of this is somewhat curious: the committer date will be different depending on whether a commit gets parsed via the commit-graph or via the object database. This isn't really too much of an issue in general though, as we don't typically use the date parsed from the commit-graph in user-facing output. But with 024b4c9697 (commit: make `repo_parse_commit_no_graph()` more robust, 2026-02-16) it started to become a problem when writing the commit-graph itself. This commit changed `repo_parse_commit_no_graph()` so that we re-parse the commit via the object database in case it was already parsed beforehand via the commit-graph. The consequence is that we may now act with two different commit dates at different stages: - Initially, we use the 34-bit precision timestamp when writing the chunk generation data. We thus correctly compute the offsets relative to the on-disk timestamp here. - Later, when writing the overflow data, we may end up with the full-precision timestamp. When the date is larger than 34 bits the result of this is an underflow when computing the offset. This causes a mismatch in the number of generation data overflow records we want to write, and that ultimately causes Git to die. Introduce a new helper function that computes the generation offset for a commit while correctly masking the date to 34 bits. This makes the previously-implicit assumptions about the commit date precision explicit and thus hopefully less fragile going forward. Adapt sites that compute the offset to use the function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23refspec: fix typo in commentK Jayatheerth1-1/+1
Fix a long-standing typo in a comment: "refpsecs" -> "refspecs". Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23remote-curl: fall back to default hash outside repoK Jayatheerth2-0/+14
When a remote helper like git-remote-http is invoked outside of a repository (for example, by running git ls-remote in a non-git directory), setup_git_directory_gently() leaves the_hash_algo uninitialized as NULL. If the user has a globally configured fetch refspec, remote-curl attempts to parse it during initialization. Inside parse_refspec(), it checks whether the LHS of the refspec is an exact OID by evaluating llen == the_hash_algo->hexsz. Because the_hash_algo is NULL, this results in a segmentation fault. In 9e89dcb66a (builtin/ls-remote: fall back to SHA1 outside of a repo, 2024-08-02), we added a workaround to ls-remote to fall back to the default hash algorithm to prevent exactly this type of crash when parsing refspec capabilities. However, because remote-curl runs as a separate process, it does not inherit that fallback and crashes anyway. Instead of pushing a NULL-guard workaround down into parse_refspec(), fix this by mirroring the ls-remote workaround directly in remote-curl.c. If we are operating outside a repository, initialize the_hash_algo to GIT_HASH_DEFAULT. This keeps the HTTP transport consistent with non-HTTP transports that execute in-process, preventing crashes without altering the generic refspec parsing logic. Reported-by: Jo Liss <joliss@gmail.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format-patch: --commit-list-format without prefixMirko Faina3-1/+29
Having to prefix a custom format-string with "log:" when passed from the CLI can be annoying. It would be great if this prefix wasn't required. Teach make_cover_letter() to accept custom format-strings without the "log:" prefix if a placeholder is detected. Note that both here and in "git log --format" the check is done naively by just checking for the presence of a '%'. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format-patch: add preset for --commit-list-formatMirko Faina4-8/+21
"git format-patch --commit-list-format" enables the user to make their own format for the commit list in the cover letter. It would be nice to have a ready to use format to replace shortlog. Teach make_cover_letter() the "modern" format preset. This new format is the same as: "log:[%(count)/%(total)] %s". Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format-patch: wrap generate_commit_list_cover()Mirko Faina1-1/+7
While most conventions should not allow for the text lines in commit messages to get too long, when they do it could make emails harder to read. Teach generate_commit_list_cover() to wrap its commit lines if they are too long. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format.commitListFormat: strip meaning from emptyMirko Faina2-21/+1
The configuration variable format.commitListFormat allows for an empty value. This is unusual and can create issues when interacting with this configuration variable through the CLI. Strip meaning to format.commitListFormat with an empty value. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23docs/pretty-formats: add %(count) and %(total)Mirko Faina1-0/+4
When --commit-list-format was introduced to format-patch, two new placeholders were added to the PRETTY FORMATS code without being documented. Do so now. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format-patch: rename --cover-letter-format optionMirko Faina4-31/+32
To align the name of the configuration variable and the name of the command line option, either one should change name. By changing the name of the option we get the added benefit of having --cover-<TAB> expand to --cover-letter without ambiguity. If the user gives the --cover-letter-format option it would be reasonable to expect that the user wants to generate the cover letter despite not giving --cover-letter. Rename --cover-letter-format to --commit-list-format and make it imply --cover-letter unless --no-cover-letter is given. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23format-patch: refactor generate_commit_list_coverMirko Faina1-4/+3
Refactor for readability and remove unnecessary initialization. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23pretty.c: better die message %(count) and %(total)Mirko Faina1-2/+2
Improve die messages for commands that do not support %(count) and %(total) Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23The 19th batchJunio C Hamano1-0/+16
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23Merge branch 'ty/mktree-wo-the-repository'Junio C Hamano1-10/+9
Code clean-up. * ty/mktree-wo-the-repository: builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE
2026-03-23Merge branch 'bb/imap-send-openssl-4.0-prep'Junio C Hamano1-9/+22
"imap-send" used to use functions whose use is going to be removed with OpenSSL 4.0; rewrite them using public API that has been available since OpenSSL 1.1 since 2016 or so. * bb/imap-send-openssl-4.0-prep: imap-send: move common code into function host_matches() imap-send: use the OpenSSL API to access the subject common name imap-send: use the OpenSSL API to access the subject alternative names
2026-03-23Merge branch 'ac/help-sort-correctly'Junio C Hamano2-51/+77
The code in "git help" that shows configuration items in sorted order was awkwardly organized and prone to bugs. * ac/help-sort-correctly: help: cleanup the contruction of keys_uniq
2026-03-23Merge branch 'jc/test-allow-sed-with-ere'Junio C Hamano2-2/+2
Adjust test-lint to allow "sed -E" to use ERE in the patterns. * jc/test-allow-sed-with-ere: t: allow use of "sed -E"
2026-03-23Merge branch 'ng/submodule-default-remote'Junio C Hamano6-4/+330
Instead of hardcoded 'origin', use the configured default remote when fetching from submodules. * ng/submodule-default-remote: submodule: fetch missing objects from default remote
2026-03-23Merge branch 'ms/t7605-test-path-is-helpers'Junio C Hamano1-3/+3
Test updates. * ms/t7605-test-path-is-helpers: t7605: use test_path_is_file instead of test -f
2026-03-23Merge branch 'cf/constness-fixes'Junio C Hamano2-6/+6
Small code clean-up around the constness area. * cf/constness-fixes: dir: avoid -Wdiscarded-qualifiers in remove_path() bloom: remove a misleading const qualifier
2026-03-23builtin/fsck: stop using `the_repository` in error reportingPatrick Steinhardt1-23/+23
In the preceding commit we have introduced the repository into `struct fsck_object_report`. This allows us to drop remaining uses of the global `the_repository` variable. Drop them and remove `USE_THE_REPOSITORY_VARIABLE`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` when marking objectsPatrick Steinhardt1-12/+14
We implicitly rely on `the_repository` when marking objects for connectivity. Refactor this to instead inject the repository via the callback payload. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` when checking packed objectsPatrick Steinhardt3-10/+17
We implicitly rely on `the_repository` when checking objects part of a packfile. These objects are iterated over via `verify_pack()`, which is provided by the packfile subsystem, and a callback function is then invoked for each of the objects in that specific pack. Unfortunately, it is not possible to provide a payload to the callback function. Refactor `verify_pack()` to accept a payload that is passed through to the callback so that we can inject the repository and get rid of the use of `the_repository`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` with loose objectsPatrick Steinhardt1-6/+8
We depend on `the_repository` when performing consistency checks for loose objects. Refactor this to use a context-provided repository instead that is injected via the `struct for_each_loose_cb`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` when checking reflogsPatrick Steinhardt1-10/+14
We implicitly rely on `the_repository` when checking reflogs. Refactor this to instead inject the repository via the callback payload. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` when checking refsPatrick Steinhardt1-5/+6
We implicitly rely on `the_repository` when checking refs. Refactor this to instead inject the repository via the callback payload. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: stop using `the_repository` when snapshotting refsPatrick Steinhardt1-11/+22
We depedn on `the_repository` when snapshotting refs. Refactor this to use a context-provided repository instead that is injected via the `struct snapshot_ref_data`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23builtin/fsck: fix trivial dependence on `the_repository`Patrick Steinhardt1-49/+49
We have a bunch of sites in "builtin/fsck.c" that depend on `the_repository` even though we already have a repository available, or in cases where we can trivially make it available. Refactor such sites to use the context-provided repository instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23fsck: drop USE_THE_REPOSITORYPatrick Steinhardt1-15/+13
Stop using `the_repository` in "fsck.c" in favor of the repository that we've already got available via `struct fsck_options`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23fsck: store repository in fsck optionsPatrick Steinhardt9-14/+21
The fsck subsystem relies on `the_repository` quite a bit. While we could of course explicitly pass a repository down the callchain, we already have a `struct fsck_options` that we pass to almost all functions. Extend the options to also store the repository to make it readily available. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23fsck: initialize fsck options via a functionPatrick Steinhardt9-38/+81
We initialize the `struct fsck_options` via a set of macros, often in global scope. In the next commit though we're about to introduce a new repository field to the options that must be initialized, and naturally we don't have a repo other than `the_repository` available in this scope. Refactor the code to instead intrdouce a new `fsck_options_init()` function that initializes the options for us and move initialization into function scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23fetch-pack: move fsck options into function scopePatrick Steinhardt1-1/+4
When fetching a packfile, we optionally verify received objects via the fsck subsystem. The options for those consistency checks are declared in global scope without a good reason, and they are never cleaned up. So in case the options are reused, they may accumulate more state over time. Furthermore, in subsequent changes we'll introduce a repository pointer into the structure. Obviously though, we don't have a repository available at static time, except for `the_repository`, which we don't want to use here. Refactor the code to move the options into the respective functions and properly manage their lifecycle. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23diff-highlight: fetch all config with one processJeff King1-8/+20
When diff-highlight was written, there was no way to fetch multiple config keys _and_ have them interpreted as colors. So we were stuck with either invoking git-config once for each config key, or fetching them all and converting human-readable color names into ANSI codes ourselves. I chose the former, but it means that diff-highlight kicks off 6 git-config processes (even if you haven't configured anything, it has to check each one). But since Git 2.18.0, we can do: git config --type=color --get-regexp=^color\.diff-highlight\. to get all of them in one shot. Note that any callers which pass in colors directly to the module via @OLD_HIGHLIGHT and @NEW_HIGHLIGHT (like diff-so-fancy plans to do) are unaffected; those colors suppress any config lookup we'd do ourselves. You can see the effect like: # diff-highlight suppresses git-config's stderr, so dump # trace through descriptor 3 git show d1f33c753d | GIT_TRACE=3 diff-highlight 3>&2 >/dev/null which drops from 6 lines down to 1. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23diff-highlight: allow module callers to pass in color configScott Baker2-12/+35
Users of the module may want to pass in their own color config for a few obvious reasons: - they are pulling the config from different variables than diff-highlight itself uses - they are loading the config in a more efficient way (say, by parsing git-config --list) and don't want to incur the six (!) git-config calls that DiffHighlight.pm runs to check all config Let's allow users of the module to pass in the color config, and lazy-load it when needed if they haven't. Signed-off-by: Scott Baker <scott@perturb.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23diff-highlight: test color configJeff King1-0/+28
We added configurable colors long ago in bca45fbc1f (diff-highlight: allow configurable colors, 2014-11-20), but never actually tested it. Since we'll be touching the color code in a moment, this is a good time to beef up the tests. Note that we cover both the highlight/reset style used by the default colors, as well as the normal/highlight style added by that commit (which was previously totally untested). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-23diff-highlight: use test_decode_color in testsJeff King1-20/+17
The diff-highlight tests use raw color bytes when comparing expected and actual output. Let's use test_decode_color, which is our usual technique in other tests. It makes reading test output diffs a bit easier, since you're not relying on your terminal to interpret the result (or worse, interpreting characters yourself via "cat -A"). This will also make it easier to add tests with new colors/attributes, without having to pre-define the byte sequences ourselves. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>