summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2026-03-11worktree: do not pass strbuf by valueDeveshi Dwivedi3-13/+13
write_worktree_linking_files() takes two struct strbuf parameters by value, even though it only reads path strings from them. Passing a strbuf by value is misleading and dangerous. The structure carries a pointer to its underlying character array; caller and callee end up sharing that storage. If the callee ever causes the strbuf to be reallocated, the caller's copy becomes a dangling pointer, which results in a double-free when the caller does strbuf_release(). The function only needs the string values, not the strbuf machinery. Switch it to take const char * and update all callers to pass .buf. Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-11editorconfig: fix style not applying to subdirs anymorePatrick Steinhardt1-1/+5
In 046e1117d5 (templates: add .gitattributes entry for sample hooks, 2026-02-13) we have added another pattern to our EditorConfig that sets the style for our hook templates. As our templates are located in "templates/hooks/", we explicitly specify that subdirectory as part of the globbing pattern. This change causes files in other subdirectories, like for example "builtin/add.c", to not be configured properly anymore. This seems to stem from a subtlety in the EditorConfig specification [1]: If the glob contains a path separator (a / not inside square brackets), then the glob is relative to the directory level of the particular .editorconfig file itself. Otherwise the pattern may also match at any level below the .editorconfig level. What's interesting is that the _whole_ expression is considered to be the glob. So when the expression used is for example "{*.c,foo/*.h}", then it will be considered a single glob, and because it contains a path separator we will now anchor "*.c" matches to the same directory as the ".editorconfig" file. Fix this issue by splitting out the configuration for hook templates into a separate section. It leads to a tiny bit of duplication, but the alternative would be something like the following (note the "{,**/}"): [{{,**/}*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,{,**/}Makefile,templates/hooks/*.sample}] indent_style = tab tab_width = 8 This starts to become somewhat hard to read, so the duplication feels like the better tradeoff. [1]: https://spec.editorconfig.org/#glob-expressions Signed-off-by: Patrick Steinhardt <ps@pks.im> Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10t7605: use test_path_is_file instead of test -fMansi Singh1-3/+3
Replace old-style 'test -f' path checks with the modern test_path_is_file helper in the merge_c1_to_c2_cmds block. The helper provides clearer failure messages and is the established convention in Git's test suite. Signed-off-by: Mansi Singh <mansimaanu8627@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10The 14th batchJunio C Hamano1-0/+26
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10Merge branch 'jh/alias-i18n-fixes'Junio C Hamano5-6/+25
Further update to the i18n alias support to avoid regressions. * jh/alias-i18n-fixes: doc: fix list continuation in alias.adoc git, help: fix memory leaks in alias listing alias: treat empty subsection [alias ""] as plain [alias] doc: fix list continuation in alias subsection example
2026-03-10Merge branch 'pt/fsmonitor-watchman-sample-fix'Junio C Hamano3-21/+5
Fix typo-induced breakages in fsmonitor-watchman sample hook. * pt/fsmonitor-watchman-sample-fix: fsmonitor-watchman: fix variable reference and remove redundant code
2026-03-10Merge branch 'mm/diff-no-index-find-object'Junio C Hamano2-0/+12
"git diff --no-index --find-object=<object-name>" outside a repository of course wouldn't be able to find the object and died while parsing the command line, which is made to die in a bit more user-friendly way. * mm/diff-no-index-find-object: diff: fix crash with --find-object outside repository
2026-03-10Merge branch 'ps/ci-reduce-gitlab-envsize'Junio C Hamano1-0/+4
CI fix. * ps/ci-reduce-gitlab-envsize: ci: unset GITLAB_FEATURES envvar to not bust xargs(1) limits
2026-03-10Merge branch 'fp/t3310-test-path-is-helpers'Junio C Hamano1-6/+6
Test clean-up. * fp/t3310-test-path-is-helpers: t3310: replace test -f/-d with test_path_is_file/test_path_is_dir
2026-03-10Merge branch 'ss/test-that-that-typofix'Junio C Hamano1-1/+1
Typofix in t/. * ss/test-that-that-typofix: t: fix "that that" typo in lib-unicode-nfc-nfd.sh
2026-03-10Merge branch 'rs/parse-options-duplicated-long-options'Junio C Hamano2-2/+23
The parse-options API learned to notice an options[] array with duplicated long options. * rs/parse-options-duplicated-long-options: parseopt: check for duplicate long names and numerical options pack-objects: remove duplicate --stdin-packs definition
2026-03-10Merge branch 'ar/config-hooks'Junio C Hamano12-62/+990
Allow hook commands to be defined (possibly centrally) in the configuration files, and run multiple of them for the same hook event. * ar/config-hooks: hook: add -z option to "git hook list" hook: allow out-of-repo 'git hook' invocations hook: allow event = "" to overwrite previous values hook: allow disabling config hooks hook: include hooks from the config hook: add "git hook list" command hook: run a list of hooks to prepare for multihook support hook: add internal state alloc/free callbacks
2026-03-10Merge branch 'kh/format-patch-noprefix-is-boolean'Junio C Hamano3-1/+37
The configuration variable format.noprefix did not behave as a proper boolean variable, which has now been fixed and documented. * kh/format-patch-noprefix-is-boolean: doc: diff-options.adoc: make *.noprefix split translatable doc: diff-options.adoc: show format.noprefix for format-patch format-patch: make format.noprefix a boolean
2026-03-10Merge branch 'ps/odb-sources' into ps/object-countingJunio C Hamano23-354/+953
* ps/odb-sources: odb/source: make `begin_transaction()` function pluggable odb/source: make `write_alternate()` function pluggable odb/source: make `read_alternates()` function pluggable odb/source: make `write_object_stream()` function pluggable odb/source: make `write_object()` function pluggable odb/source: make `freshen_object()` function pluggable odb/source: make `for_each_object()` function pluggable odb/source: make `read_object_stream()` function pluggable odb/source: make `read_object_info()` function pluggable odb/source: make `close()` function pluggable odb/source: make `reprepare()` function pluggable odb/source: make `free()` function pluggable odb/source: introduce source type for robustness odb: move reparenting logic into respective subsystems odb: embed base source in the "files" backend odb: introduce "files" source odb: split `struct odb_source` into separate header
2026-03-10diff: document -U without <n> as using default contextTian Yuchen2-4/+8
The documentation for '-U<n>' implies that the numeric value '<n>' is mandatory. However, the command line parser has historically accepted '-U' without a number. Strictly requiring a number for '-U' would break existing tests (e.g., in 't4013') and likely disrupt user scripts relying on this undocumented behavior. Hence we retain this fallback behavior for backward compatibility, but document it as such. Signed-off-by: Tian Yuchen <cat@malon.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09dir: avoid -Wdiscarded-qualifiers in remove_path()Collin Funk1-4/+4
When building with glibc-2.43 there is the following warning: dir.c:3526:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 3526 | slash = strrchr(name, '/'); | ^ In this case we use a non-const pointer to get the last slash of the unwritable file name, and then use it again to write in the strdup'd file name. We can avoid this warning and make the code a bit more clear by using a separate variable to access the original argument and its strdup'd copy. Signed-off-by: Collin Funk <collin.funk1@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09SubmittingPatches: spell out "replace fully to pretend to be perfect"Junio C Hamano1-0/+12
It unfortunately is a recurring theme that new developers tend to pile more "fixup" patches on top of the already reviewed patches, making the topic longer and keeping the history of all wrong turns, which interests nobody in the larger picture. Even picking a narrow search in the list archive for "pretend to be a perfect " substring, we find these: https://lore.kernel.org/git/xmqqk29bsz2o.fsf@gitster.mtv.corp.google.com/ https://lore.kernel.org/git/xmqqd0ds5ysq.fsf@gitster-ct.c.googlers.com/ https://lore.kernel.org/git/xmqqr173faez.fsf@gitster.g/ The SubmittingPatches guide does talk about going incremental once a topic hits the 'next' branch, but it does not say much about how a new iteration of the topic should be prepared before that happens, and it does not mention that the developers are encouraged to seize the opportunity to pretend to be perfect with a full replacement set of patches. Add a new paragraph to stress this point in the section that describes the life-cycle of a patch series. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09The 13th batchJunio C Hamano1-0/+14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09Merge branch 'jk/repo-structure-cleanup'Junio C Hamano1-1/+0
Code clean-up. * jk/repo-structure-cleanup: repo: remove unnecessary variable shadow
2026-03-09Merge branch 'lp/diff-stat-utf8-display-width-fix'Junio C Hamano2-8/+36
"git log --graph --stat" did not count the display width of colored graph part of its own output correctly, which has been corrected. * lp/diff-stat-utf8-display-width-fix: t4052: test for diffstat width when prefix contains ANSI escape codes diff: handle ANSI escape codes in prefix when calculating diffstat width
2026-03-09Merge branch 'cs/add-skip-submodule-ignore-all'Junio C Hamano12-19/+235
"git add <submodule>" has been taught to honor submodule.<name>.ignore that is set to "all" (and requires "git add -f" to override it). * cs/add-skip-submodule-ignore-all: Documentation: update add --force option + ignore=all config tests: fix existing tests when add an ignore=all submodule tests: t2206-add-submodule-ignored: ignore=all and add --force tests read-cache: submodule add need --force given ignore=all configuration read-cache: update add_files_to_cache take param ignored_too
2026-03-09Merge branch 'ps/refs-for-each'Junio C Hamano28-361/+457
Code refactoring around refs-for-each-* API functions. * ps/refs-for-each: refs: replace `refs_for_each_fullref_in()` refs: replace `refs_for_each_namespaced_ref()` refs: replace `refs_for_each_glob_ref()` refs: replace `refs_for_each_glob_ref_in()` refs: replace `refs_for_each_rawref_in()` refs: replace `refs_for_each_rawref()` refs: replace `refs_for_each_ref_in()` refs: improve verification for-each-ref options refs: generalize `refs_for_each_fullref_in_prefixes()` refs: generalize `refs_for_each_namespaced_ref()` refs: speed up `refs_for_each_glob_ref_in()` refs: introduce `refs_for_each_ref_ext` refs: rename `each_ref_fn` refs: rename `do_for_each_ref_flags` refs: move `do_for_each_ref_flags` further up refs: move `refs_head_ref_namespaced()` refs: remove unused `refs_for_each_include_root_ref()`
2026-03-09Merge branch 'ar/run-command-hook-take-2'Junio C Hamano11-279/+750
Use the hook API to replace ad-hoc invocation of hook scripts via the run_command() API. * ar/run-command-hook-take-2: builtin/receive-pack: avoid spinning no-op sideband async threads receive-pack: convert receive hooks to hook API receive-pack: convert update hooks to new API run-command: poll child input in addition to output hook: add jobs option reference-transaction: use hook API instead of run-command transport: convert pre-push to hook API hook: allow separate std[out|err] streams hook: convert 'post-rewrite' hook in sequencer.c to hook API hook: provide stdin via callback run-command: add stdin callback for parallelization run-command: add helper for pp child states t1800: add hook output stream tests
2026-03-09Merge branch 'ar/config-hooks' into ar/config-hook-cleanupsJunio C Hamano17-312/+1711
* ar/config-hooks: (21 commits) builtin/receive-pack: avoid spinning no-op sideband async threads hook: add -z option to "git hook list" hook: allow out-of-repo 'git hook' invocations hook: allow event = "" to overwrite previous values hook: allow disabling config hooks hook: include hooks from the config hook: add "git hook list" command hook: run a list of hooks to prepare for multihook support hook: add internal state alloc/free callbacks receive-pack: convert receive hooks to hook API receive-pack: convert update hooks to new API run-command: poll child input in addition to output hook: add jobs option reference-transaction: use hook API instead of run-command transport: convert pre-push to hook API hook: allow separate std[out|err] streams hook: convert 'post-rewrite' hook in sequencer.c to hook API hook: provide stdin via callback run-command: add stdin callback for parallelization run-command: add helper for pp child states ...
2026-03-09.mailmap: update email address for Tian YuchenTian Yuchen1-0/+1
Map my old Gmail address to my new custom address in .mailmap. Signed-off-by: Tian Yuchen <a3205153416@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09patch-ids: document intentional const-casting in patch_id_neq()Tian Yuchen1-1/+8
The hashmap API requires the comparison function to take const pointers. However, patch_id_neq() uses lazy evaluation to compute patch IDs on demand. As established in b3dfeebb (rebase: avoid computing unnecessary patch IDs, 2016-07-29), this avoids unnecessary work since not all objects in the hashmap will eventually be compared. Remove the ten-year-old "NEEDSWORK" comment and formally document this intentional design trade-off. Signed-off-by: Tian Yuchen <cat@malon.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09history: initialize rev_info in cmd_history_reword()René Scharfe1-1/+1
git history reword expects a single valid revision argument and errors out if it doesn't get it. In that case the struct rev_info passed to release_revisions() for cleanup is still uninitialized, which can result in attempts to free(3) random pointers. Avoid that by initializing the structure. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09bloom: remove a misleading const qualifierCollin Funk1-2/+2
When building with glibc-2.43 there is the following warning: bloom.c: In function ‘get_or_compute_bloom_filter’: bloom.c:515:52: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 515 | char *last_slash = strrchr(path, '/'); | ^~~~~~~ In this case, we always write through "path" through the "last_slash" pointer. Therefore, the const qualifier on "path" is misleading and we can just remove it. Signed-off-by: Collin Funk <collin.funk1@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-07t3310: avoid hiding failures from rev-parse in command substitutionsFrancesco Paparatto1-18/+29
Running `git` commands inside command substitutions like test "$(git rev-parse A)" = "$(git rev-parse B)" can hide failures from the `git` invocations and provide little diagnostic information when `test` fails. Use `test_cmp` when comparing against a stored expected value so mismatches show both expected and actual output. Use `test_cmp_rev` when comparing two revisions. These helpers produce clearer failure output, making it easier to understand what went wrong. Suggested-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Francesco Paparatto <francescopaparatto@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-07doc: make it easier to find custom command informationOmri Sarig1-1/+4
Git supports creating additional commands through aliases, and through placement of executables with a "git-" prefix in the PATH. This information was not easy enough to find - users will look for this information around the command description, but the documentation exists in other locations. Update the "GIT COMMANDS" section to reference the relevant sections, making it easier for to find this information. Signed-off-by: Omri Sarig <omri.sarig13@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06meson: turn on NO_MMAP when building with LSanJeff King1-1/+1
The previous commit taught the Makefile to turn on NO_MMAP in this instance. We should do the same with meson for consistency. We already do this for ASan builds, so we can just tweak one conditional. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06Makefile: turn on NO_MMAP when building with LSanJeff King1-0/+1
The past few commits fixed some cases where we leak memory allocated by mmap(). Building with SANITIZE=leak doesn't detect these because it covers only heap buffers allocated by malloc(). But if we build with NO_MMAP, our compat mmap() implementation will allocate a heap buffer and pread() into it. And thus Lsan will detect these leaks for free. Using NO_MMAP is less performant, of course, since we have to use extra memory and read in the whole file, rather than faulting in pages from disk. But LSan builds are already slow, and this doesn't make them measurably worse. Getting extra coverage for our leak-checking is worth it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06object-file: fix mmap() leak in odb_source_loose_read_object_stream()Jeff King1-1/+1
We mmap() a loose object file, storing the result in the local variable "mapped", which is eventually assigned into our stream struct as "st.mapped". If we hit an error, we jump to an error label which does: munmap(st.mapped, st.mapsize); to clean up. But this is wrong; we don't assign st.mapped until the end of the function, after all of the "goto error" jumps. So this munmap() is never cleaning up anything (st.mapped is always NULL, because we initialize the struct with calloc). Instead, we should feed the local variable to munmap(). This leak is due to 595296e124 (streaming: allocate stream inside the backend-specific logic, 2025-11-23), which introduced the local variable. Before that, we assigned the mmap result directly into st.mapped. It was probably switched there so that we do not have to allocate/free the struct when the map operation fails (e.g., because we don't have the loose object). Before that commit, the struct was passed in from the caller, so there was no allocation at all. You can see the leak in the test suite by building with: make SANITIZE=leak NO_MMAP=1 CC=clang and running t1060. We need NO_MMAP so that the mmap() is backed by an actual malloc(), which allows LSan to detect it. And the leak seems not to be detected when compiling with gcc, probably due to some internal compiler decisions about how the stack memory is written. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06docs: add usage for the cover-letter fmt featureMirko Faina2-0/+18
Document the new "--cover-letter-format" option in format-patch and its related configuration variable "format.commitListFormat". Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06format-patch: add commitListFormat configMirko Faina2-0/+74
Using "--cover-letter" we can tell format-patch to generate a cover letter, in this cover letter there's a list of commits included in the patch series and the format is specified by the "--cover-letter-format" option. Would be useful if this format could be configured from the config file instead of always needing to pass it from the command line. Teach format-patch how to read the format spec for the cover letter from the config files. The variable it should look for is called format.commitListFormat. Possible values: - commitListFormat is set but no string is passed: it will default to "[%(count)/%(total)] %s" - if a string is passed: will use it as a format spec. Note that this is either "shortlog" or a format spec prefixed by "log:" e.g."log:%s (%an)" - if commitListFormat is not set: it will default to the shortlog format. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06format-patch: add ability to use alt cover formatMirko Faina3-3/+86
Often when sending patch series there's a need to clarify to the reviewer what's the purpose of said series, since it might be difficult to understand it from reading the commits messages one by one. "git format-patch" provides the useful "--cover-letter" flag to declare if we want it to generate a template for us to use. By default it will generate a "git shortlog" of the changes, which developers find less useful than they'd like, mainly because the shortlog groups commits by author, and gives no obvious chronological order. Give format-patch the ability to specify an alternative format spec through the "--cover-letter-format" option. This option either takes "shortlog", which is the current format, or a format spec prefixed with "log:". Example: git format-patch --cover-letter \ --cover-letter-format="log:[%(count)/%(total)] %s (%an)" HEAD~3 [1/3] this is a commit summary (Mirko Faina) [2/3] this is another commit summary (Mirko Faina) ... Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06format-patch: move cover letter summary generationMirko Faina1-12/+20
As of now format-patch allows generation of a template cover letter for patch series through "--cover-letter". Move shortlog summary code generation to its own function. This is done in preparation to other patches where we enable the user to format the commit list using thier own format string. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06pretty.c: add %(count) and %(total) placeholdersMirko Faina1-0/+15
In many commands we can customize the output through the "--format" or the "--pretty" options. This patch adds two new placeholders used mainly when there's a range of commits that we want to show. Currently these two placeholders are not usable as they're coupled with the rev_info->nr and rev_info->total fields, fields that are used only by the format-patch numbered email subjects. Teach repo_format_commit_message() the %(count) and %(total) placeholders. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06Documentation: extend guidance for submitting patchesJustin Tobler1-0/+13
Before submitting patches on the mailing list, it is often a good idea to check for previous related discussions or if similar work is already in progress. This enables better coordination amongst contributors and could avoid duplicating work. Additionally, it is often recommended to give reviewers some time to reply to a patch series before sending new versions. This helps collect broader feedback and reduces unnecessary churn from rapid rerolls. Document this guidance in "Documentation/SubmittingPatches" accordingly. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: drop 'default' configurationJunio C Hamano2-5/+2
The topic so far allows users to tweak the configuration variable sideband.allowControlCharacters to override the hardcoded default, but among which there is the value called 'default'. The plan [*] of the series is to loosen the setting by a later commit in the series and schedule it to tighten at the Git 3.0 boundary for end users, at which point, the meaning of this 'default' value will change. Which is a dubious design. A user expresses their preference by setting configuration variable in order to guard against sudden change brought in by changes to the hardcoded default behaviour, and letting them set it to 'default' that will change at the Git 3.0 boundary defeats its purpose. If a user wants to say "I am easy and can go with whatever hardcoded default Git implementors choose for me", they simply leave the configuration variable unspecified. Let's remove it from the state before Git 3.0 so that those users who set it to 'default' will not see the behaviour changed under their feet all of sudden. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: offer to configure sanitizing on a per-URL basisJohannes Schindelin5-24/+102
The main objection against sanitizing the sideband that was raised during the review of the sideband sanitizing patches, first on the git-security mailing list, then on the public mailing list, was that there are some setups where server-side `pre-receive` hooks want to error out, giving colorful messages to the users on the client side (if they are not redirecting the output into a file, that is). To avoid breaking such setups, the default chosen by the sideband sanitizing patches is to pass through ANSI color sequences. Still, there might be some use case out there where that is not enough. Therefore the `sideband.allowControlCharacters` config setting allows for configuring levels of sanitizing. As Junio Hamano pointed out, to keep users safe by default, we need to be able to scope this to some servers because while a user may trust their company's Git server, the same might not apply to other Git servers. To allow for this, let's imitate the way `http.<url>.*` offers to scope config settings to certain URLs, by letting users override the `sideband.allowControlCharacters` setting via `sideband.<url>.allowControlCharacters`. Suggested-by: Junio Hamano <gitster@pobox.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: add options to allow more control sequences to be passed throughJohannes Schindelin3-15/+123
Even though control sequences that erase characters are quite juicy for attack scenarios, where attackers are eager to hide traces of suspicious activities, during the review of the side band sanitizing patch series concerns were raised that there might be some legimitate scenarios where Git server's `pre-receive` hooks use those sequences in a benign way. Control sequences to move the cursor can likewise be used to hide tracks by overwriting characters, and have been equally pointed out as having legitimate users. Let's add options to let users opt into passing through those ANSI Escape sequences: `sideband.allowControlCharacters` now supports also `cursor` and `erase`, and it parses the value as a comma-separated list. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: do allow ANSI color sequences by defaultJohannes Schindelin3-9/+91
The preceding two commits introduced special handling of the sideband channel to neutralize ANSI escape sequences before sending the payload to the terminal, and `sideband.allowControlCharacters` to override that behavior. However, as reported by brian m. carlson, some `pre-receive` hooks that are actively used in practice want to color their messages and therefore rely on the fact that Git passes them through to the terminal, even though they have no way to determine whether the receiving side can actually handle Escape sequences (think e.g. about the practice recommended by Git that third-party applications wishing to use Git functionality parse the output of Git commands). In contrast to other ANSI escape sequences, it is highly unlikely that coloring sequences can be essential tools in attack vectors that mislead Git users e.g. by hiding crucial information. Therefore we can have both: Continue to allow ANSI coloring sequences to be passed to the terminal by default, and neutralize all other ANSI Escape sequences. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: introduce an "escape hatch" to allow control charactersJohannes Schindelin4-1/+24
The preceding commit fixed the vulnerability whereas sideband messages (that are under the control of the remote server) could contain ANSI escape sequences that would be sent to the terminal verbatim. However, this fix may not be desirable under all circumstances, e.g. when remote servers deliberately add coloring to their messages to increase their urgency. To help with those use cases, give users a way to opt-out of the protections: `sideband.allowControlCharacters`. Suggested-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06sideband: mask control charactersJohannes Schindelin2-2/+27
The output of `git clone` is a vital component for understanding what has happened when things go wrong. However, these logs are partially under the control of the remote server (via the "sideband", which typically contains what the remote `git pack-objects` process sends to `stderr`), and is currently not sanitized by Git. This makes Git susceptible to ANSI escape sequence injection (see CWE-150, https://cwe.mitre.org/data/definitions/150.html), which allows attackers to corrupt terminal state, to hide information, and even to insert characters into the input buffer (i.e. as if the user had typed those characters). To plug this vulnerability, disallow any control character in the sideband, replacing them instead with the common `^<letter/symbol>` (e.g. `^[` for `\x1b`, `^A` for `\x01`). There is likely a need for more fine-grained controls instead of using a "heavy hammer" like this, which will be introduced subsequently. Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06pack-revindex: avoid double-loading .rev filesJeff King1-0/+4
The usual entry point for loading the pack revindex is the load_pack_revindex() function. It returns immediately if the packed_git has a non-NULL revindex or revindex data field (representing an in-memory or mmap'd .rev file, respectively), since the data is already loaded. But in 5a6072f631 (fsck: validate .rev file header, 2023-04-17) the fsck code path switched to calling load_pack_revindex_from_disk() directly, since it wants to check the on-disk data (if there is any). But that function does _not_ check to see if the data has already been loaded; it just maps the file, overwriting the revindex_map pointer (and pointing revindex_data inside that map). And in that case we've leaked the mmap() pointed to by revindex_map (if it was non-NULL). This usually doesn't happen, since fsck wouldn't need to load the revindex for any reason before we get to these checks. But there are some cases where it does. For example, is_promisor_object() runs odb_for_each_object() with the PACK_ORDER flag, which uses the revindex. This happens a few times in our test suite, but SANITIZE=leak doesn't detect it because we are leaking an mmap(), not a heap-allocated buffer from malloc(). However, if you build with NO_MMAP, then our compat mmap will read into a heap buffer instead, and LSan will complain. This causes failures in t5601, t0410, t5702, and t5616. We can fix it by checking for existing revindex_data when loading from disk. This is redundant when we're called from load_pack_revindex(), but it's a cheap check. The alternative is to teach check_pack_rev_indexes() in fsck to skip the load, but that seems messier; it doesn't otherwise know about internals like revindex_map and revindex_data. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06check_connected(): fix leak of pack-index mmapJeff King1-1/+4
Since c6807a40dc (clone: open a shortcut for connectivity check, 2013-05-26), we may open a one-off packed_git struct to check what's in the pack we just received. At the end of the function we throw away the struct (rather than linking it into the repository struct as usual). We used to leak the struct until dd4143e7bf (connected.c: free the "struct packed_git", 2022-11-08), which calls free(). But that's not sufficient; inside the struct we'll have mmap'd the pack idx data from disk, which needs an munmap() call. Building with SANITIZE=leak doesn't detect this, because we are leaking our own mmap(), and it only finds heap allocations from malloc(). But if we use our compat mmap implementation like this: make NO_MMAP=MapsBecomeMallocs SANITIZE=leak then LSan will notice the leak, because now it's a regular heap buffer allocated by malloc(). We can fix it by calling close_pack(), which will free any associated memory. Note that we need to check for NULL ourselves; unlike free(), it is not safe to pass a NULL pointer to close_pack(). Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06check_connected(): delay opening new_packJeff King1-18/+15
In check_connected(), if the transport tells us we got a single packfile that has already been verified as self-contained and connected, then we can skip checking connectivity for any tips that are mentioned in that pack. This goes back to c6807a40dc (clone: open a shortcut for connectivity check, 2013-05-26). We don't need to open that pack until we are about to start sending oids to our child rev-list process, since that's when we check whether they are in the self-contained pack. Let's push the opening of that pack further down in the function. That saves us from having to clean it up when we leave the function early (and by the time have opened the rev-list process, we never leave the function early, since we have to clean up the child process). Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06rebase: support --trailerLi Chen6-2/+228
Add a new --trailer=<trailer> option to git rebase to append trailer lines to each rewritten commit message (merge backend only). Because the apply backend does not provide a commit-message filter, reject --trailer when --apply is in effect and require the merge backend instead. This option implies --force-rebase so that fast-forwarded commits are also rewritten. Validate trailer arguments early to avoid starting an interactive rebase with invalid input. Add integration tests covering error paths and trailer insertion across non-interactive and interactive rebases. Signed-off-by: Li Chen <me@linux.beauty> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-06commit, tag: parse --trailer with OPT_STRVECLi Chen4-28/+8
Now that amend_file_with_trailers() expects raw trailer lines, do not store argv-style "--trailer=<trailer>" strings in git commit and git tag. Parse --trailer using OPT_STRVEC so trailer_args contains only the trailer value, and drop the temporary prefix stripping in amend_file_with_trailers(). Signed-off-by: Li Chen <me@linux.beauty> Signed-off-by: Junio C Hamano <gitster@pobox.com>