aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2025-07-24t/unit-tests: convert reftable table test to use clarSeyi Kuforiji3-44/+38
Adapt reftable table test file to use clar by using clar assertions where necessary. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-24t/unit-tests: convert reftable pq test to use clarSeyi Kuforiji3-34/+30
Adapt reftable priority queue test file to use clar by using clar assertions where necessary. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-24t/unit-tests: convert reftable merged test to use clarSeyi Kuforiji3-94/+72
Adapt reftable merged test file to use clar testing framework by using clar assertions where necessary. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-24t/unit-tests: convert reftable block test to use clarSeyi Kuforiji3-88/+80
Adapt reftable block test file to use clar testing framework by using clar assertions where necessary. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-24t/unit-tests: convert reftable basics test to use clar test frameworkSeyi Kuforiji4-221/+229
Adapt reftable basics test file to clar by using clar assertions where necessary.Break up test edge case to improve modularity and clarity. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-24t/unit-tests: implement clar specific reftable test helper functionsSeyi Kuforiji4-1/+124
Helper functions defined in `t/unit-tests/lib-reftable.{c,h}` are required for the reftable-related test files to run. In the current implementation these functions are designed to conform with our homegrown unit-testing structure. So in other to convert the reftable test files, there is need for a clar specific implementation of these helper functions. Implement equivalent helper functions in `lib-reftable-clar.{c,h}` to use clar. These functions conform with the clar testing framework and become available for all reftable-related test files implemented using the clar testing framework, which requires them. This will be used by subsequent commits. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-30A bit more topics for -rc1Junio C Hamano1-0/+22
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-30Merge branch 'ps/midx-negative-packfile-cache'Junio C Hamano2-2/+21
When a stale .midx file refers to .pack files that no longer exist, we ended up checking for these non-existent files repeatedly, which has been optimized by memoizing the non-existence. * ps/midx-negative-packfile-cache: midx: stop repeatedly looking up nonexistent packfiles packfile: explain ordering of how we look up auxiliary pack files
2025-05-30Merge branch 'kh/notes-doc-fixes'Junio C Hamano3-26/+38
"git notes --help" documentation updates. * kh/notes-doc-fixes: doc: notes: use stuck form throughout doc: notes: treat --stdin equally between copy/remove doc: notes: point out copy --stdin use with argv doc: notes: clearly state that --stripspace is the default doc: notes: remove stripspace discussion from other options doc: notes: rework --[no-]stripspace doc: notes: split out options with negated forms doc: config: mention core.commentChar on commit.cleanup doc: stripspace: mention where the default comes from
2025-05-30Merge branch 'mm/apply-reverse-mode-of-deleted-path'Junio C Hamano2-6/+227
"git apply --index/--cached" when applying a deletion patch in reverse failed to give the mode bits of the path "removed" by the patch to the file it creates, which has been corrected. * mm/apply-reverse-mode-of-deleted-path: apply: set file mode when --reverse creates a deleted file t4129: test that git apply warns for unexpected mode changes
2025-05-30Merge branch 'op/cvsserver-perl-warning'Junio C Hamano1-24/+3
Recent versions of Perl started warning against "! A =~ /pattern/" which does not negate the result of the matching. As it turns out that the problematic function is not even called, it was removed. * op/cvsserver-perl-warning: cvsserver: remove unused escapeRefName function
2025-05-30Merge branch 'am/sparse-index-name-hash-fix'Junio C Hamano1-2/+4
Avoid adding directory path to a sparse-index tree entries to the name-hash, since they would bloat the hashtable without anybody querying for them. This was done already for a single threaded part of the code, but now the multi-threaded code also does the same. * am/sparse-index-name-hash-fix: name-hash: don't add sparse directories in threaded lazy init
2025-05-30Merge branch 'pw/midx-repack-overflow-fix'Junio C Hamano3-10/+39
Integer overflow fix around code paths for "git multi-pack-index repack".. * pw/midx-repack-overflow-fix: midx docs: clarify tie breaking midx: avoid negative array index midx repack: avoid potential integer overflow on 64 bit systems midx repack: avoid integer overflow on 32 bit systems
2025-05-30Merge branch 'cb/reftable-unused-portability-fix'Junio C Hamano1-0/+4
Build fix. * cb/reftable-unused-portability-fix: reftable: make REFTABLE_UNUSED C99 compatible
2025-05-29reftable: make REFTABLE_UNUSED C99 compatibleCarlo Marcelo Arenas Belón1-0/+4
Since f93b2a0424 (reftable/basics: introduce `REFTABLE_UNUSED` annotation, 2025-02-18), the reftable library was migrated to use an internal version of `UNUSED`, which unconditionally sets a GNU __attribute__ to avoid warnings function parameters that are not being used. Make the definition conditional to prevent breaking the build with non GNU compilers. Reported-by: "Randall S. Becker" <rsbecker@nexbridge.com> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-29Merge branch 'master' of https://github.com/j6t/git-guiJunio C Hamano12-102/+453
* 'master' of https://github.com/j6t/git-gui: git-gui: wire up support for the Meson build system git-gui: stop including GIT-VERSION-FILE file git-gui: extract script to generate macOS app git-gui: extract script to generate macOS wrapper git-gui: extract script to generate "tclIndex" git-gui: extract script to generate "git-gui" git-gui: drop no-op GITGUI_SCRIPT replacement git-gui: make output of GIT-VERSION-GEN source'able git-gui: prepare GIT-VERSION-GEN for out-of-tree builds git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS
2025-05-29Merge branch 'master' of https://github.com/j6t/gitkJunio C Hamano2-7/+5
* 'master' of https://github.com/j6t/gitk: gitk: do not hard-code color of search results in commit list gitk: place file name arguments after options in msgfmt call gitk: Legacy widgets doesn't have combobox
2025-05-29Merge branch 'pks-meson-support' of github.com:pks-t/git-guiJohannes Sixt12-102/+453
* 'pks-meson-support' of github.com:pks-t/git-gui: git-gui: wire up support for the Meson build system git-gui: stop including GIT-VERSION-FILE file git-gui: extract script to generate macOS app git-gui: extract script to generate macOS wrapper git-gui: extract script to generate "tclIndex" git-gui: extract script to generate "git-gui" git-gui: drop no-op GITGUI_SCRIPT replacement git-gui: make output of GIT-VERSION-GEN source'able git-gui: prepare GIT-VERSION-GEN for out-of-tree builds git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-28Git 2.50-rc0v2.50.0-rc0Junio C Hamano2-1/+9
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-28Merge branch 'jt/receive-pack-skip-connectivity-check'Junio C Hamano5-63/+122
"git receive-pack" optionally learns not to care about connectivity check, which can be useful when the repository arranges to ensure connectivity by some other means. * jt/receive-pack-skip-connectivity-check: builtin/receive-pack: add option to skip connectivity check t5410: test receive-pack connectivity check
2025-05-28Merge branch 'kn/passing-leak-tests'Junio C Hamano3-8/+0
Remove the leftover hints to the test framework to mark tests that do not pass the leak checker tests, as they should no longer be needed. * kn/passing-leak-tests: t: remove unexpected SANITIZE_LEAK variables
2025-05-28midx: stop repeatedly looking up nonexistent packfilesPatrick Steinhardt1-2/+10
The multi-pack index acts as a cache across a set of packfiles so that we can quickly look up which of those packfiles contains a given object. As such, the multi-pack index naturally needs to be updated every time one of the packfiles goes away, or otherwise the multi-pack index has grown stale. A stale multi-pack index should be handled gracefully by Git though, and in fact it is: if the indexed pack cannot be found we simply ignore it and eventually we fall back to doing the object lookup by just iterating through all packs, even if those aren't indexed. But while this fallback works, it has one significant downside: we don't cache the fact that a pack has vanished. This leads to us repeatedly trying to look up the same pack only to realize that it (still) doesn't exist. This issue can be easily demonstrated by creating a repository with a stale multi-pack index and a couple of objects. We do so by creating a repository with two packfiles, both of which are indexed by the multi-pack index, and then repack those two packfiles. Note that we have to move the multi-pack-index before doing the final repack, as Git knows to delete it otherwise. $ git init repo $ cd repo/ $ git config set maintenance.auto false $ for i in $(seq 1000); do printf "%d-original" $i >file-$i; done $ git add . $ git commit -moriginal $ git repack -dl $ for i in $(seq 1000); do printf "%d-modified" $i >file-$i; done $ git commit -a -mmodified $ git repack -dl $ git multi-pack-index write $ mv .git/objects/pack/multi-pack-index . $ git repack -Adl $ mv multi-pack-index .git/objects/pack/ Commands that cause a lot of objects lookups will now repeatedly invoke `add_packed_git()`, which leads to three failed access(3p) calls as well as one failed stat(3p) call. The following strace for example is done for `git log --patch` in the above repository: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 74.67 0.024693 1 18038 18031 access 25.33 0.008378 1 6045 6017 newfstatat ------ ----------- ----------- --------- --------- ---------------- 100.00 0.033071 1 24083 24048 total Fix the issue by introducing a negative lookup cache for indexed packs. This cache works by simply storing an invalid pointer for a missing pack when `prepare_midx_pack()` fails to look up the pack. Most users of the `packs` array don't need to be adjusted, either, as they all know to call `prepare_midx_pack()` before accessing the array. With this change in place we can now see a significantly reduced number of syscalls: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 73.58 0.000323 5 60 28 newfstatat 26.42 0.000116 5 23 16 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000439 5 83 44 total Furthermore, this change also results in a speedup: Benchmark 1: git log --patch (revision = HEAD~) Time (mean ± σ): 50.4 ms ± 2.5 ms [User: 22.0 ms, System: 24.4 ms] Range (min … max): 45.4 ms … 54.9 ms 53 runs Benchmark 2: git log --patch (revision = HEAD) Time (mean ± σ): 12.7 ms ± 0.4 ms [User: 11.1 ms, System: 1.6 ms] Range (min … max): 12.4 ms … 15.0 ms 191 runs Summary git log --patch (revision = HEAD) ran 3.96 ± 0.22 times faster than git log --patch (revision = HEAD~) In the end, it should in theory never be necessary to have this negative lookup cache given that we know to update the multi-pack index together with repacks. But as the change is quite contained and as the speedup can be significant as demonstrated above, it does feel sensible to have the negative lookup cache regardless. Based-on-patch-by: Jeff King <peff@peff.net> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-28packfile: explain ordering of how we look up auxiliary pack filesPatrick Steinhardt1-0/+11
When adding a packfile to an object database we perform four syscalls: - Three calls to access(3p) are done to check for auxiliary data structures. - One call to stat(3p) is done to check for the ".pack" itself. One curious bit is that we perform the access(3p) calls before checking for the packfile itself, but if the packfile doesn't exist we discard all results. The access(3p) calls are thus essentially wasted, so one may be triggered to reorder those calls so that we can short-circuit the other syscalls in case the packfile does not exist. The order in which we look up files is quite important though to help avoid races: - When installing a packfile we move auxiliary data structures into place before we install the ".idx" file. - When deleting a packfile we first delete the ".idx" and ".pack" files before deleting auxiliary data structures. As such, to avoid any races with concurrently created or deleted packs we need to make sure that we _first_ read auxiliary data structures before we read the corresponding ".idx" or ".pack" file. Otherwise it may easily happen that we return a populated but misclassified pack. Add a comment to `add_packed_git()` to make future readers aware of this ordering requirement. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: use stuck form throughoutKristoffer Haugsbakk1-1/+1
gitcli(7) recommends the *stuck form*. `--ref` is the only one which does not use it. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: treat --stdin equally between copy/removeKristoffer Haugsbakk1-3/+5
46538012d94 (notes remove: --stdin reads from the standard input, 2011-05-18) added `--stdin` for the `remove` subcommand, documenting it in the “Options” section. But `copy --stdin` was added before that, in 160baa0d9cb (notes: implement 'git notes copy --stdin', 2010-03-12). Treat this option equally between the two subcommands: • remove: mention `--stdin` on the subcommand as well, like for `copy` • copy: mention it as well under the option documentation Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: point out copy --stdin use with argvKristoffer Haugsbakk1-0/+3
Unlike `remove --stdin`, this option cannot be combined with object names given via the command line. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: clearly state that --stripspace is the defaultKristoffer Haugsbakk1-0/+9
Clearly state when which of the regular and negated form of the option take effect.[1] Also mention the subtle behavior that occurs when you mix options like `-m` and `-C`, including a note that it might be fixed in the future. The topic was brought up on v8 of the `--separator` series.[2][3] [1]: https://lore.kernel.org/git/xmqqcyct1mtq.fsf@gitster.g/ [2]: https://lore.kernel.org/git/xmqq4jp326oj.fsf@gitster.g/ † 3: v11 was the version that landed Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: remove stripspace discussion from other optionsKristoffer Haugsbakk1-10/+2
Cleaning up whitespace in metadata is typical porcelain behavior and this default does not need to be pointed out.[1] Only speak up when the default `--stripspace` is not used. Also remove all misleading mentions of comment lines in the process; see the previous commit. Also remove the period that trails the parenthetical here. † 1: See `-F` in git-commit(1) which has nothing to say about whitespace cleanup. The cleanup discussion is on `--cleanup`. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: rework --[no-]stripspaceKristoffer Haugsbakk1-5/+7
Document this option by copying the bullet list from git-stripspace(1). A bullet list is cleaner when there are this many points to consider. We also get a more standardized description of the multiple-blank-lines behavior. Compare the repeating (git-notes(1)): empty lines other than a single line between paragraphs With (git-stripspace(1)): multiple consecutive empty lines And: leading [...] whitespace With: empty lines from the beginning Leading whitespace in the form of spaces (indentation) are not removed. However, empty lines at the start of the message are removed. Note that we drop the mentions of comment line handling because they are wrong; this option does not control how lines which can be recognized as comment lines are handled. Only interactivity controls that: • Comment lines are stripped after editing interactively • Lines which could be recognized as comment lines are left alone when the message is given non-interactively So it is misleading to document the comment line behavior on this option. Further, the text is wrong: Lines starting with `#` will be stripped out in non-editor cases like `-m`, [...] Comment lines are still indirectly discussed on other options. We will deal with them in the next commit. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: notes: split out options with negated formsKristoffer Haugsbakk1-2/+4
Split these out so that they are easier to search for.[1] [1]: https://lore.kernel.org/git/xmqqcyct1mtq.fsf@gitster.g/ Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: config: mention core.commentChar on commit.cleanupKristoffer Haugsbakk1-3/+4
Mention it in parentheses since we are in a configuration context. Refer to the default as such, not as “the” character. Also don’t mention `#` again; just say “comment character”. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27doc: stripspace: mention where the default comes fromKristoffer Haugsbakk1-1/+2
Also quote `#` in line with the modern formatting convention. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27The eighteenth batchJunio C Hamano1-0/+24
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27Merge branch 'kj/my-first-contribution-updates'Junio C Hamano1-22/+33
Doc updates. * kj/my-first-contribution-updates: docs: replace git_config to repo_config docs: clarify cmd_psuh signature and explain UNUSED macro docs: remove unused mentoring mailing list reference
2025-05-27Merge branch 'es/meson-configure-build-options-fix'Junio C Hamano1-8/+6
Build procedure updates. * es/meson-configure-build-options-fix: meson: reformat default options to workaround bug in `meson configure`
2025-05-27Merge branch 'en/sequencer-comment-messages'Junio C Hamano6-88/+94
Prefix '#' to the commit title in the "rebase -i" todo file, just like a merge commit being replayed. * en/sequencer-comment-messages: sequencer: make it clearer that commit descriptions are just comments
2025-05-27Merge branch 'js/misc-fixes'Junio C Hamano10-161/+130
Assorted fixes for issues found with CodeQL. * js/misc-fixes: sequencer: stop pretending that an assignment is a condition bundle-uri: avoid using undefined output of `sscanf()` commit-graph: avoid using stale stack addresses trace2: avoid "futile conditional" Avoid redundant conditions fetch: avoid unnecessary work when there is no current branch has_dir_name(): make code more obvious upload-pack: rename `enum` to reflect the operation commit-graph: avoid malloc'ing a local variable fetch: carefully clear local variable's address after use commit: simplify code
2025-05-27Merge branch 'sj/use-mmap-to-check-packed-refs'Junio C Hamano4-30/+67
The code path to access the "packed-refs" file while "fsck" is taught to mmap the file, instead of reading the whole file in the memory. * sj/use-mmap-to-check-packed-refs: packed-backend: mmap large "packed-refs" file during fsck packed-backend: extract snapshot allocation in `load_contents` packed-backend: fsck should warn when "packed-refs" file is empty
2025-05-27Merge branch 'jc/doc-synopsis-option-markup'Junio C Hamano6-157/+148
Doc mark-up fixes. * jc/doc-synopsis-option-markup: git-var doc: fix usage of $ENV_VAR vs ENV_VAR git-verify-* doc: update mark-up of synopsis option descriptions git-{var,write-tree} docs: update mark-up of synopsis option descriptions git-daemon doc: update mark-up of synopsis option descriptions
2025-05-27Merge branch 'ds/sparse-apply-add-p'Junio C Hamano5-7/+167
"git apply" and "git add -i/-p" code paths no longer unnecessarily expand sparse-index while working. * ds/sparse-apply-add-p: p2000: add performance test for patch-mode commands reset: integrate sparse index with --patch git add: make -p/-i aware of sparse index apply: integrate with the sparse index
2025-05-27Merge branch 'rj/build-tweaks-part2'Junio C Hamano4-13/+52
Updates to meson-based build procedure. * rj/build-tweaks-part2: configure.ac: upgrade to a compilation check for sysinfo meson.build: correct setting of GIT_EXEC_PATH meson: correct path to system config/attribute files meson: correct install location of YAML.pm meson.build: quote the GITWEBDIR build configuration
2025-05-27Merge branch 'en/merge-tree-check'Junio C Hamano5-7/+94
"git merge-tree" learned an option to see if it resolves cleanly without actually creating a result. * en/merge-tree-check: merge-tree: add a new --quiet flag merge-ort: add a new mergeability_only option
2025-05-27Merge branch 'jk/no-funny-object-types'Junio C Hamano20-447/+220
Support to create a loose object file with unknown object type has been dropped. * jk/no-funny-object-types: object-file: drop support for writing objects with unknown types hash-object: handle --literally with OPT_NEGBIT hash-object: merge HASH_* and INDEX_* flags hash-object: stop allowing unknown types t: add lib-loose.sh t/helper: add zlib test-tool oid_object_info(): drop type_name strbuf fsck: stop using object_info->type_name strbuf oid_object_info_convert(): stop using string for object type cat-file: use type enum instead of buffer for -t option object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag cat-file: make --allow-unknown-type a noop object-file.h: fix typo in variable declaration
2025-05-27Merge branch 'ly/commit-graph-fill-oids-leakfix'Junio C Hamano1-0/+2
Leakfix. * ly/commit-graph-fill-oids-leakfix: commit-graph: fix memory leak when `fill_oids_from_packs()` fails
2025-05-27Merge branch 'ly/sequencer-rearrange-leakfix'Junio C Hamano1-3/+5
Leakfix. * ly/sequencer-rearrange-leakfix: sequencer: fix memory leak if `todo_list_rearrange_squash()` failed
2025-05-27Merge branch 'ly/mailinfo-decode-header-leakfix'Junio C Hamano1-21/+21
Leakfix. * ly/mailinfo-decode-header-leakfix: mailinfo: fix pointential memory leak if `decode_header` failed
2025-05-27Merge branch 'md/userdiff-bash-shell-function'Junio C Hamano8-8/+128
The userdiff pattern for shell scripts has been updated to cope with more bash-isms. * md/userdiff-bash-shell-function: userdiff: extend Bash pattern to cover more shell function forms
2025-05-27cvsserver: remove unused escapeRefName functionOndřej Pohořelský1-24/+3
Function 'escapeRefName' introduced in 51a7e6dbc9 has never been used. Despite being dead code, changes in Perl 5.41.4 exposed precedence warning within its logic, which then caused test failures in t9402 by logging the warnings to stderr while parsing the code. The affected tests are t9402.30, t9402.31, t9402.32 and t9402.34. Remove this unused function to simplify the codebase and stop the warnings and test failures. Its corresponding unescapeRefName function, which remains in use, has had its comments updated. Reported-by: Jitka Plesnikova <jplesnik@redhat.com> Signed-off-by: Ondřej Pohořelský <opohorel@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27apply: set file mode when --reverse creates a deleted fileMark Mentovai2-3/+164
Commit 01aff0a (apply: correctly reverse patch's pre- and post-image mode bits, 2023-12-26) revised reverse_patches() to maintain the desired property that when only one of patch::old_mode and patch::new_mode is set, the mode will be carried in old_mode. That property is generally correct, with one notable exception: when creating a file, only new_mode will be set. Since reversing a deletion results in a creation, new_mode must be set in that case. Omitting handling for this case means that reversing a patch that removes an executable file will not result in the executable permission being set on the re-created file. Existing test coverage for file modes focuses only on mode changes of existing files. Swap old_mode and new_mode in reverse_patches() for what's represented in the patch as a file deletion, as it is transformed into a file creation under reversal. This causes git apply --reverse to set the executable permission properly when re-creating a deleted executable file. Add tests ensuring that git apply sets file modes correctly on file creation, both in the forward and reverse directions. Signed-off-by: Mark Mentovai <mark@chromium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-27t4129: test that git apply warns for unexpected mode changesMark Mentovai1-5/+65
There is no test covering what commit 01aff0a (apply: correctly reverse patch's pre- and post-image mode bits, 2023-12-26) addressed. Prior to that commit, git apply was erroneously unaware of a file's expected mode while reverse-patching a file whose mode was not changing. Add the missing test coverage to assure that git apply is aware of the expected mode of a file being patched when the patch does not indicate that the file's mode is changing. This is achieved by arranging a file mode so that it doesn't agree with patch being applied, and checking git apply's output for the warning it's supposed to raise in this situation. Test in both reverse and normal (forward) directions. Signed-off-by: Mark Mentovai <mark@chromium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-23The seventeenth batchJunio C Hamano1-0/+19
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-23Merge branch 'lo/json-writer-docs'Junio C Hamano2-4/+171
In-code docstring updates. * lo/json-writer-docs: json-writer: describe the usage of jw_* functions json-writer: add docstrings to jw_* functions
2025-05-23Merge branch 'en/replay-wo-the-repository'Junio C Hamano1-30/+35
The dependency on the_repository variable has been reduced from the code paths in "git replay". * en/replay-wo-the-repository: replay: replace the_repository with repo parameter passed to cmd_replay ()
2025-05-23Merge branch 'ag/send-email-hostname-f'Junio C Hamano1-1/+15
Teach "git send-email" to also consult `hostname -f` for mail domain to compute the identity given to SMTP servers. * ag/send-email-hostname-f: send-email: try to get fqdn by running hostname -f on Linux and macOS
2025-05-23Merge branch 'ps/ci-gitlab-enable-msvc-meson-job'Junio C Hamano1-1/+0
CI settings at GitLab has been updated to run MSVC based Meson job automatically (as opposed to be done only upon manual request). * ps/ci-gitlab-enable-msvc-meson-job: gitlab-ci: always run MSVC-based Meson job
2025-05-23Merge branch 'ds/scalar-no-maintenance'Junio C Hamano4-20/+113
Two "scalar" subcommands that adds a repository that hasn't been under "scalar"'s control are taught an option not to enable the scheduled maintenance on it. * ds/scalar-no-maintenance: scalar reconfigure: improve --maintenance docs scalar reconfigure: add --maintenance=<mode> option scalar clone: add --no-maintenance option scalar register: add --no-maintenance option scalar: customize register_dir()'s behavior
2025-05-23Merge branch 'ly/pack-bitmap-load-leakfix'Junio C Hamano1-4/+4
Leakfix. * ly/pack-bitmap-load-leakfix: pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed
2025-05-23Merge branch 'js/ci-build-win-in-release-mode'Junio C Hamano1-1/+1
win+Meson CI pipeline, unlike other pipelines for Windows, used to build artifacts in develper mode, which has been changed to build them in release mode for consistency. * js/ci-build-win-in-release-mode: ci(win+Meson): build in Release mode
2025-05-22midx docs: clarify tie breakingPhillip Wood1-4/+7
Clarify what happens when an object exists in more than one pack, but not in the preferred pack. "git multi-pack-index repack" relies on ties for objects that are not in the preferred pack being resolved in favor of the newest pack that contains a copy of the object. If ties were resolved in favor of the oldest pack as the current documentation suggests the multi-pack index would not reference any of the objects in the pack created by "git multi-pack-index repack". Helped-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-22midx: avoid negative array indexPhillip Wood1-2/+2
nth_midxed_pack_int_id() returns the index of the pack file in the multi pack index's list of packfiles that the specified object. The index is returned as a uint32_t. Storing this in an int will make the index negative if the most significant bit is set. Fix this by using uint32_t as the rest of the code does. This is unlikely to be a practical problem as it requires the multipack index to reference 2^31 packfiles. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-22midx repack: avoid potential integer overflow on 64 bit systemsPhillip Wood1-2/+8
On a 64 bit system the calculation p->pack_size * pack_info[i].referenced_objects could overflow. If a pack file contains 2^28 objects with an average compressed size of 1KB then the pack size will be 2^38B. If all of the objects are referenced by the multi-pack index the sum above will overflow. Avoid this by using shifted integer arithmetic and changing the order of the calculation so that the pack size is divided by the total number of objects in the pack before multiplying by the number of objects referenced by the multi-pack index. Using a shift of 14 bits should give reasonable accuracy while avoiding overflow for pack sizes less that 1PB. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-22midx repack: avoid integer overflow on 32 bit systemsPhillip Wood2-4/+24
On a 32 bit system "git multi-pack-index --repack --batch-size=120M" failed with fatal: size_t overflow: 6038786 * 1289 The calculation to estimated size of the objects in the pack referenced by the multi-pack-index uses st_mult() to multiply the pack size by the number of referenced objects before dividing by the total number of objects in the pack. As size_t is 32 bits on 32 bit systems this calculation easily overflows. Fix this by using 64bit arithmetic instead. Also fix a potential overflow when caluculating the total size of the objects referenced by the multipack index with a batch size larger than SIZE_MAX / 2. In that case total_size += estimated_size can overflow as both total_size and estimated_size can be greater that SIZE_MAX / 2. This is addressed by using saturating arithmetic for the addition. Although estimated_size is of type uint64_t by the time we reach this sum it is bounded by the batch size which is of type size_t and so casting estimated_size to size_t does not truncate the value. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-22Merge branch 'top-panel-search-highlight' of github.com:bnfour/gitkJohannes Sixt1-2/+2
* 'top-panel-search-highlight' of github.com:bnfour/gitk: gitk: do not hard-code color of search results in commit list Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-21name-hash: don't add sparse directories in threaded lazy initAlex Mironov1-2/+4
Ensure that logic added in 5f11669586 (name-hash: don't add directories to name_hash, 2021-04-12) also applies in multithreaded hashtable init path. As per the original single-threaded change above: sparse directory entries represent a directory that is outside the sparse-checkout definition. These are not paths to blobs, so should not be added to the name_hash table. Instead, they should be added to the directory hashtable when 'ignore_case' is true. Add a condition to avoid placing sparse directories into the name_hash hashtable. This avoids filling the table with extra entries that will never be queried. Signed-off-by: Alex Mironov <alexandrfox@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-20t: remove unexpected SANITIZE_LEAK variablesKarthik Nayak3-8/+0
As of 1fc7ddf35b (test-lib: unconditionally enable leak checking, 2024-11-20), both the `GIT_TEST_PASSING_SANITIZE_LEAK` and `TEST_PASSES_SANITIZE_LEAK` variables no longer have any meaning, the leak checks are enabled by default. However, some newly added tests include them by mistake. Let's clean this up. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Acked-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-20builtin/receive-pack: add option to skip connectivity checkJustin Tobler3-18/+56
During git-receive-pack(1), connectivity of the object graph is validated to ensure that the received packfile does not leave the repository in a broken state. This is done via git-rev-list(1) and walking the objects, which can be expensive for large repositories. Generally, this check is critical to avoid an incomplete received packfile from corrupting a repository. Server operators may have additional knowledge though around exactly how Git is being used on the server-side which can be used to facilitate more efficient connectivity computation of incoming objects. For example, if it can be ensured that all objects in a repository are connected and do not depend on any missing objects, the connectivity of newly written objects can be checked by walking the object graph containing only the new objects from the updated tips and identifying the missing objects which represent the boundary between the new objects and the repository. These boundary objects can be checked in the canonical repository to ensure the new objects connect as expected and thus avoid walking the rest of the object graph. Git itself cannot make the guarantees required for such an optimization as it is possible for a repository to contain an unreachable object that references a missing object without the repository being considered corrupt. Introduce the --skip-connectivity-check option for git-receive-pack(1) which bypasses this connectivity check to give more control to the server-side. Note that without proper server-side validation of newly received objects handled outside of Git, usage of this option risks corrupting a repository. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-20t5410: test receive-pack connectivity checkJustin Tobler2-2/+23
As part of git-recieve-pack(1), the connectivity of objects is checked. Add a test validating that git-receive-pack(1) fails due to an incoming packfile that would leave the repository with missing objects. Instead of creating a new test file, "t5410" is generalized for receive-pack testing. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-20Merge branch 'yh/fix-non-themed-combobox'Johannes Sixt1-4/+2
* yh/fix-non-themed-combobox: gitk: Legacy widgets doesn't have combobox
2025-05-19The sixteenth batchJunio C Hamano1-0/+15
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19Merge branch 'ps/reftable-read-block-perffix'Junio C Hamano4-17/+19
Performance regression in not-yet-released code has been corrected. * ps/reftable-read-block-perffix: reftable: fix perf regression when reading blocks of unwanted type
2025-05-19Merge branch 'ly/reftable-writer-leakfix'Junio C Hamano1-2/+6
Leakfix. * ly/reftable-writer-leakfix: reftable/writer: fix memory leak when `writer_index_hash()` fails reftable/writer: fix memory leak when `padded_write()` fails
2025-05-19Merge branch 'jk/oidmap-cleanup'Junio C Hamano11-18/+21
Code cleanup. * jk/oidmap-cleanup: raw_object_store: drop extra pointer to replace_map oidmap: add size function oidmap: rename oidmap_free() to oidmap_clear()
2025-05-19Merge branch 'rc/t1001-test-path-is-file'Junio C Hamano1-1/+1
Test update. * rc/t1001-test-path-is-file: t1001: replace 'test -f' with 'test_path_is_file'
2025-05-19Merge branch 'ly/am-split-stgit-leakfix'Junio C Hamano1-1/+3
Leakfix. * ly/am-split-stgit-leakfix: builtin/am: fix memory leak in `split_mail_stgit_series`
2025-05-19Merge branch 'bc/make-avoid-unneeded-rebuild-with-compdb-dir'Junio C Hamano1-1/+1
Build performance fix. * bc/make-avoid-unneeded-rebuild-with-compdb-dir: Makefile: avoid constant rebuilds with compilation database
2025-05-19Merge branch 'ag/doc-send-email'Junio C Hamano3-9/+66
The `send-email` documentation has been updated with OAuth2.0 related examples. * ag/doc-send-email: docs: add credential helper for outlook and gmail in OAuth list of helpers docs: improve send-email documentation send-mail: improve checks for valid_fqdn
2025-05-19Merge branch 'sc/bundle-uri-use-all-refs-in-bundle'Junio C Hamano3-94/+124
Bundle-URI feature did not use refs recorded in the bundle other than normal branches as anchoring points to optimize the follow-up fetch during "git clone"; now it is told to utilize all. * sc/bundle-uri-use-all-refs-in-bundle: bundle-uri: add test for bundle-uri clones with tags bundle-uri: copy all bundle references ino the refs/bundle space
2025-05-19Merge branch 'pw/sequencer-reflog-use-after-free'Junio C Hamano2-60/+67
Use-after-free fix in the sequencer. * pw/sequencer-reflog-use-after-free: sequencer: rework reflog message handling sequencer: move reflog message functions
2025-05-19configure.ac: upgrade to a compilation check for sysinfoRamsay Jones1-3/+22
Commit f5e3c6c57d ("meson: do a full usage-based compile check for sysinfo", 2025-04-25) updated the 'sysinfo()' check, as part of the meson build, due to the failure of the check on Solaris. Prior to that commit, the meson build only checked the availability of the '<sys/sysinfo.h>' header file. On Solaris, both the header and the 'sysinfo()' function exist, but are completely unrelated to the same function on Linux (and cygwin). Commit 50dec7c566 ("config.mak.uname: add sysinfo() configuration for cygwin", 2025-04-17) added a similar 'sysinfo()' check to the autoconf build. This check looked for the 'sysinfo()' function itself, rather than just the header, but it will fail (incorrectly set HAVE_SYSINFO) for the same reason. In order to correctly identify the 'sysinfo()' function we require as part of 'git-gc' (used in the 'total_ram() function), we also upgrade to a compilation check, in a similar way to the meson commit. Note that since commit c9a51775a3 ("builtin/gc.c: correct RAM calculation when using sysinfo", 2025-04-17) both the 'totalram' and 'mem_unit' fields of the 'struct sysinfo' are used, so the new check includes both of those fields in the compile check. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19meson.build: correct setting of GIT_EXEC_PATHRamsay Jones1-2/+10
For the non-'runtime prefix' case, the meson build sets the GIT_EXEC_PATH build variable to an absolute path equivalent to <prefix>/libexec/git-core. In comparison, the default make build sets it to a relative path equivalent to 'libexec/git-core'. Indeed, the make build requires the use of some means outside of the Makefile (eg. config.mak[.*] or the command-line) to set GIT_EXEC_PATH to anything other than 'libexec/git-core'. For example, the make invocation: $ make gitexecdir=/some/other/bin all install will build git with GIT_EXEC_PATH set to '/some/other/bin' and install the 'library' executables to that location. However, without setting the 'gitexecdir' make variable, irrespective of the 'runtime prefix' setting, the GIT_EXEC_PATH is always set to 'libexec/git-core'. The meson built-in 'libexecdir' option can be used to provide a similar configurability. The default value for the option is 'libexec'. Attempting to set the option to '' on the command-line, will reset it to the '.' string, presumably to ensure a relative path value. This commit allows the meson build, similar to the above, to configure the project like: $ meson setup --buildtype=debugoptimized -Dprefix=$HOME -Dpcre2=disabled \ -Dlibexecdir=/some/other/bin build so that the GIT_EXEC_PATH is set to '/some/other/bin'. Absent the -Dlibexecdir argument, the GIT_EXEC_PATH is set to 'libexec/git-core'. In order to correct the value of GIT_EXEC_PATH, default the value to the static string value 'libexec/git-core', and only override if the value of the 'libexecdir' option has a value different to 'libexec' or '.'. Also, like the Makefile, add a check for an absolute path when the runtime prefix option is true (and if so, error out). Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19meson: correct path to system config/attribute filesRamsay Jones2-6/+18
The path to the system-wide config and attributes files are not being set correctly in the meson build. Unless explicitly overridden on the command line during setup, the 'gitconfig' and 'gitattributes' options are defaulting to absolute paths in the '/etc' system directory. This is only appropriate if the <prefix> is set specifically to '/usr'. The directory in which these files are placed is generally referred to as the 'system configuration directory' or 'sysconfdir' for short. When the prefix is '/usr' then the sysconfdir is usually set to '/etc', but any other value for prefix results in the relative directory value 'etc' instead. (eg if prefix is '/usr/local', then the 'etc' relative value results in a system configuration directory of '/usr/local/etc'). When setting the 'sysconfdir' builtin option value, the meson system uses exactly this algorithm, so we can use get_option('sysconfdir') directly when setting the (non-overridden) build variables. In order to allow for overriding from the command line, remove the default values specified for the 'gitconfig' and 'gitattributes' options in the 'meson_options.txt' file. This allows the user to specify any pathname for those options, while being able to test for the unset (empty) value. An absolute pathname will be used unchanged and a relative pathname will be appended to '<prefix>/'. These values are then used to set the 'ETC_GITCONFIG' and 'ETC_GITATTRIBUTES' build variables which are, in turn, passed to the compiler as '-D' arguments. When the 'gitconfig' or 'gitattributes' options are not used, then use the built-in 'sysconfdir' and set the ETC_GITCONFIG build variable to the string "<sysconfdir>/gitconfig". Similarly, set ETC_ATTRIBUTES to "<sysconfdir>/gitattributes". Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19meson: correct install location of YAML.pmRamsay Jones1-1/+1
When executing an 'meson install' the YAML.pm file is incorrectly placed in the <prefix>/share/perl5/Git/SVN directory. The YAML.pm file should be placed in a 'Memoize' subdirectory instead. In order to correct the location, update the 'install_dir' of the relevant target in the 'perl/Git/SVN/Memoize/meson.build' file. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19meson.build: quote the GITWEBDIR build configurationRamsay Jones1-1/+1
The build configuration options with (non-empty) values, for example filesystem paths potentially containing spaces, have been set using the '.set_quoted()' method. However, the GITWEBDIR value has been set using the '.set()' method instead. In order to correctly quote the GITWEBDIR value, replace the '.set()' method with '.set_quoted()'. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19meson: reformat default options to workaround bug in `meson configure`Eli Schwartz1-8/+6
Since 13cb20fc46 ("meson: fix compilation with Visual Studio", 2025-01-22) it has not been possible to list build options via `meson configure`. This is due to Meson's static analysis of build options failing to handle constant folding, and thinking we set a totally invalid default `-std=`. This is reported upstream but we anyways need to work with existing versions. It turns out there is a simple solution: turn the entire default option into a conditional branch, which means Meson sees either nothing, or everything. As a result, Git users can once again see pretty-printed options before building. Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Bug: https://github.com/mesonbuild/meson/issues/14623 Signed-off-by: Eli Schwartz <eschwartz@gentoo.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19docs: replace git_config to repo_configK Jayatheerth1-9/+10
Since this document was written, the built-in API has been updated a few times, but the document was left stale. Adjust to the current best practices by calling repo_config() on the repository instance the subcommand implementation receives as a parameter, instead of calling git_config() that used to be the common practice. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19docs: clarify cmd_psuh signature and explain UNUSED macroK Jayatheerth1-5/+23
The sample program, as written, would no longer build for at least two reasons: - Since this document was first written, the convention to call a subcommand implementation has changed, and cmd_psuh() now needs to accept the fourth parameter, repository. - These days, compiler warning options for developers include one that detects and complains about unused parameters, so ones that are deliberately unused have to be marked as such. Update the old-style examples to adjust to the current practices, with explanations as needed. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-19docs: remove unused mentoring mailing list referenceK Jayatheerth1-8/+0
The git-mentoring group was initially created to help newcomers with their development itches. However, in practice, most of their questions were already being addressed directly on the mailing list, and contributors consistently received helpful responses there. Remove the mentoring group details from the Documentation. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16merge-tree: add a new --quiet flagElijah Newren3-0/+62
Git Forges may be interested in whether two branches can be merged while not being interested in what the resulting merge tree is nor which files conflicted. For such cases, add a new --quiet flag which will make use of the new mergeability_only flag added to merge-ort in the previous commit. This option allows the merge machinery to, in the outer layer of the merge: * exit early when a conflict is detected * avoid writing (most) merged blobs/trees to the object store Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16merge-ort: add a new mergeability_only optionElijah Newren2-7/+32
Git Forges may be interested in whether two branches can be merged while not being interested in what the resulting merge tree is nor which files conflicted. For such cases, add a new mergeability_only option. This option allows the merge machinery to, in the "outer layer" of the merge: * exit upon first[-ish] conflict * avoid (not prevent) writing merged blobs/trees to the object store I have a number of qualifiers there, so let me explain each: "outer layer": Note that since the recursive merge of merge bases (corresponding to call_depth > 0) can conflict without the outer final merge (corresponding to call_depth == 0) conflicting, we can't short-circuit nor avoid writing merged blobs/trees to the object store during those inner merges. "first-ish conflict": The current patch only exits early from process_entries() on the first conflict it detects, but conflicts could have been detected in a previous function call, namely detect_and_process_renames(). However: * conflicts detected by detect_and_process_renames() are quite rare conflict types * the detection would still come after regular rename detection (which is the expensive part of detect_and_process_renames()), so it is not saving us much in computation time given that process_entries() directly follows detect_and_process_renames() * [this overlaps with the next bullet point] process_entries() is the place where virtually all object writing occurs (object writing is sometimes more of a concern for Forges than computation time), so exiting early here isn't saving us much in object writes either * the code changes needed to handle an earlier exit are slightly more invasive in detect_and_process_renames() than for process_entries(). Given the rareness of the even earlier conflicts, the limited savings we'd get from exiting even earlier, and in an attempt to keep this patch simpler, we don't guarantee that we actually exit on the first conflict detected. We can always revisit this decision later if we decide that a further micro-optimization to exit slightly earlier in rare cases is worthwhile. "avoid (not prevent) writing objects": The detect_and_process_renames() call can also write objects to the object store, when rename/rename conflicts involve one (or more) files that have also been modified on both sides. Because of this alternate call path leading to handle_content_merges(), our "early exit" does not prevent writing objects entirely, even within the "outer layer" (i.e. even within call_depth == 0). I figure that's fine though, since we're already writing objects for the inner merges (i.e. for call_depth > 0), which are likely going to represent vastly more objects than files involved in rename/rename+modify/modify cases in the outer merge, on average. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16sequencer: make it clearer that commit descriptions are just commentsElijah Newren6-88/+94
Every once in a while, users report that editing the commit summaries in the todo list does not get reflected in the rebase operation, suggesting that users are (a) only using one-line commit messages, and (b) not understanding that the commit summaries are merely helpful comments to help them find the right hashes. It may be difficult to correct users' poor commit messages, but we can at least try to make it clearer that the commit summaries are not directives of some sort by inserting a comment character. Hopefully that leads to them looking a little further and noticing the hints at the bottom to use 'reword' or 'edit' directives. Yes, this change may look funny at first since it hardcodes '#' rather than using comment_line_str. However: * comment_line_str exists to allow disambiguation between lines in a commit message and lines that are instructions to users editing the commit message. No such disambiguation is needed for these comments that occur on the same line after existing directives * the exact "comment" character(s) on regular pick lines used aren't actually important; I could have used anything, including completely random variable length text for each line and it'd work because we ignore everything after 'pick' and the hash. * The whole point of this change is to signal to users that they should NOT be editing any part of the line after the hash (and if they do so, their edits will be ignored), while the whole point of comment_line_str is to allow highly flexible editing. So making it more general by using comment_line_str actually feels counterproductive. * The character for merge directives absolutely must be '#'; that has been deeply hardcoded for a long time (see below), and will break if some other comment character is used instead. In a desire to have pick and merge directives be similar, I use the same comment character for both. * Perhaps merge directives could be fixed to not be inflexible about the comment character used, if someone feels highly motivated, but I think that should be done in a separate follow-on patch. Here are (some of?) the locations where '#' has already been hardcoded for a long time for merges: 1) In check_label_or_ref_arg(): case TODO_LABEL: /* * '#' is not a valid label as the merge command uses it to * separate merge parents from the commit subject. */ 2) In do_merge(): /* * For octopus merges, the arg starts with the list of revisions to be * merged. The list is optionally followed by '#' and the oneline. */ merge_arg_len = oneline_offset = arg_len; for (p = arg; p - arg < arg_len; p += strspn(p, " \t\n")) { if (!*p) break; if (*p == '#' && (!p[1] || isspace(p[1]))) { 3) In label_oid(): if ((buf->len == the_hash_algo->hexsz && !get_oid_hex(label, &dummy)) || (buf->len == 1 && *label == '#') || hashmap_get_from_hash(&state->labels, strihash(label), label)) { /* * If the label already exists, or if the label is a * valid full OID, or the label is a '#' (which we use * as a separator between merge heads and oneline), we * append a dash and a number to make it unique. */ Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16p2000: add performance test for patch-mode commandsDerrick Stolee1-0/+3
The previous three changes contributed performance improvements to 'git apply', 'git add -p', and 'git reset -p' when using a sparse index. The improvement to 'git apply' also improved 'git checkout -p'. Add performance tests to demonstrate this (and to help validate that performance remains good in the future). In the truncated test output below, we see that the full checkout performance changes within noise expectations, but the sparse index cases improve 33% and then 96% for 'git add -p' and 41% and then 95% for 'git reset -p'. 'git checkout -p' improves immediatley by 91% because it does not need any change to its builtin. Test HEAD~4 HEAD~3 HEAD~2 HEAD~1 ------------------------------------------------------------------------------------- 2000.118: ... git add -p (full-v3) 0.79 0.79 +0.0% 0.82 +3.8% 0.82 +3.8% 2000.119: ... git add -p (full-v4) 0.74 0.76 +2.7% 0.74 +0.0% 0.76 +2.7% 2000.120: ... git add -p (sparse-v3) 1.94 1.28 -34.0% 0.07 -96.4% 0.07 -96.4% 2000.121: ... git add -p (sparse-v4) 1.93 1.28 -33.7% 0.06 -96.9% 0.06 -96.9% 2000.122: ... git checkout -p (full-v3) 1.18 1.18 +0.0% 1.18 +0.0% 1.19 +0.8% 2000.123: ... git checkout -p (full-v4) 1.10 1.12 +1.8% 1.11 +0.9% 1.11 +0.9% 2000.124: ... git checkout -p (sparse-v3) 1.31 0.11 -91.6% 0.11 -91.6% 0.11 -91.6% 2000.125: ... git checkout -p (sparse-v4) 1.29 0.11 -91.5% 0.11 -91.5% 0.11 -91.5% 2000.126: ... git reset -p (full-v3) 0.81 0.80 -1.2% 0.83 +2.5% 0.83 +2.5% 2000.127: ... git reset -p (full-v4) 0.78 0.77 -1.3% 0.77 -1.3% 0.78 +0.0% 2000.128: ... git reset -p (sparse-v3) 1.58 0.92 -41.8% 0.91 -42.4% 0.07 -95.6% 2000.129: ... git reset -p (sparse-v4) 1.58 0.92 -41.8% 0.92 -41.8% 0.07 -95.6% It is worth noting that if our test was more involved and had multiple hunks to evaluate, then the time spent in 'git apply' would dominate due to multiple index loads and writes. As it stands, we need the sparse index improvement in 'git add -p' itself to confirm this performance improvement. Since the change for 'git add -i' is identical, we avoid a second test case for that similar operation. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16reset: integrate sparse index with --patchDerrick Stolee2-5/+43
Similar to the previous change for 'git add -p', the reset builtin checked for integration with the sparse index after possibly redirecting its logic toward the interactive logic. This means that the builtin would expand the sparse index to a full one upon read. Move this check earlier within cmd_reset() to improve performance here. Add tests to guarantee that we are not universally expanding the index. Add behavior tests to check that we are doing the same operations as a full index. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16git add: make -p/-i aware of sparse indexDerrick Stolee2-3/+64
It is slow to expand a sparse index in-memory due to parsing of trees. We aim to minimize that performance cost when possible. 'git add -p' uses 'git apply' child processes to modify the index, but still there are some expansions that occur. It turns out that control flows out of cmd_add() in the interactive cases before the lines that confirm that the builtin is integrated with the sparse index. Moving that integration point earlier in cmd_add() allows 'git add -i' and 'git add -p' to operate without expanding a sparse index to a full one. Add test cases that confirm that these interactive add options work with the sparse index. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16apply: integrate with the sparse indexDerrick Stolee2-1/+59
The sparse index allows storing directory entries in the index, marked with the skip-wortkree bit and pointing to a tree object. This may be an unexpected data shape for some implementation areas, so we are rolling it out incrementally on a builtin-per-builtin basis. This change enables the sparse index for 'git apply'. The main motivation for this change is that 'git apply' is used as a child process of 'git add -p' and expanding the sparse index for each of those child processes can lead to significant performance issues. The good news is that the actual index manipulation code used by 'git apply' is already integrated with the sparse index, so the only product change is to mark the builtin as allowing the sparse index so it isn't inflated on read. The more involved part of this change is around adding tests that verify how 'git apply' behaves in a sparse-checkout environment and whether or not the index expands in certain operations. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16userdiff: extend Bash pattern to cover more shell function formsMoumita Dhar8-8/+128
The previous function regex required explicit matching of function bodies using `{`, `(`, `((`, or `[[`, which caused several issues: - It failed to capture valid functions where `{` was on the next line due to line continuation (`\`). - It did not recognize functions with single command body, such as `x () echo hello`. Replacing the function body matching logic with `.*$`, ensures that everything on the function definition line is captured. Additionally, the word regex is refined to better recognize shell syntax, including additional parameter expansion operators and command-line options. Signed-off-by: Moumita Dhar <dhar61595@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16object-file: drop support for writing objects with unknown typesJeff King2-80/+6
Since "hash-object --literally" no longer supports objects with unknown types, there are now no callers of write_object_file_literally() and its helpers. Let's drop them to simplify the code. In particular, this gets rid of some ugly copy-and-paste code from write_object_file_literally(), which is a parallel implementation of write_object_file(). When the split was originally made, the two weren't that long, but commits like 63a6745a07 (object-file: update the loose object map when writing loose objects, 2023-10-01) ended up having to duplicate some tricky code. This patch drops all of that duplication and should make things less error-prone going forward. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16hash-object: handle --literally with OPT_NEGBITJeff King1-16/+11
Since we recently removed the hash_literally() function, the hash-object --literally option has been simplified to just removing the INDEX_FORMAT_CHECK flag. Rather than pass it around as a separate bool, we can just have the option parser remove the bit from the set of flags directly. This simplifies the helper functions. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16hash-object: merge HASH_* and INDEX_* flagsJeff King1-17/+6
The hash-object command has its own custom flag bits that it sets based on command-line options. But since we dropped hash_literally() in the previous commit, the only thing we do with those flag bits is convert them directly into "index_flags" to pass to index_fd(). This extra layer of indirection makes the code harder to read and reason about. Let's just use the INDEX_* flags directly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16hash-object: stop allowing unknown typesJeff King2-33/+7
When passed the "--literally" option, hash-object will allow any arbitrary string for its "-t" type option. Such objects are only useful for testing or debugging, as they cannot be used in the normal way (e.g., you cannot fetch their contents!). Let's drop this feature, which will eventually let us simplify the object-writing code. This is technically backwards incompatible, but since such objects were never really functional, it seems unlikely that anybody will notice. We will retain the --literally flag, as it also instructs hash-object not to worry about other format issues (e.g., type-specific things that fsck would complain about). The documentation does not need to be updated, as it was always vague about which checks we're loosening (it uses only the phrase "any garbage"). The code change is a bit hard to verify from just the patch text. We can drop our local hash_literally() helper, but it was really just wrapping write_object_file_literally(). We now replace that with calling index_fd(), as we do for the non-literal code path, but dropping the INDEX_FORMAT_CHECK flag. This ends up being the same semantically as what the _literally() code path was doing (modulo handling unknown types, which is our goal). We'll be able to clean up these code paths a bit more in subsequent patches. The existing test is flipped to show that we now reject the unknown type. The additional "extra-long type" test is now redundant, as we bail early upon seeing a bogus type. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16t: add lib-loose.shJeff King4-5/+38
This commit adds a shell library for writing raw loose objects into the object database. Normally this is done with hash-object, but the specific intent here is to allow broken objects that hash-object may not support. We'll convert several cases that use "hash-object --literally" to write objects with invalid types. That works currently, but dropping this dependency will allow us to remove that feature and simplify the object-writing code. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16t/helper: add zlib test-toolJeff King5-0/+66
It's occasionally useful when testing or debugging to be able to do raw zlib inflate/deflate operations (e.g., to check the bytes of a specific loose or packed object). Even though zlib's deflate algorithm is used by many other programs, this is surprisingly hard to do in a portable way. E.g., gzip can do this if you manually munge some header bytes. But the result is somewhat arcane, and we don't assume gzip is available anyway. Likewise, pigz will handle raw zlib, but we can't assume it is available. So let's introduce a short test helper for just doing zlib operations. We'll use it in subsequent patches to add some new tests, but it would also have come in handy a few times in the past: - The hard-coded pack data from 3b910d0c5e (add tests for indexing packs with delta cycles, 2013-08-23) could probably be generated on the fly. - Likewise we could avoid the hard-coded data from 0b1493c2d4 (git_inflate(): skip zlib_post_call() sanity check on Z_NEED_DICT, 2025-02-25). Though note this would require support for more zlib options. - It would have helped with the debugging documented in 41dfbb2dbe (howto: add article on recovering a corrupted object, 2013-10-25). I'll leave refactoring existing tests for another day, but I hope the examples above show the general utility. I aimed for simplicity in the code. In particular, it will read all input into a memory buffer, rather than streaming. That makes the zlib loops harder to get wrong (which has been a source of subtle bugs in the past). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16oid_object_info(): drop type_name strbufJeff King4-12/+2
We provide a mechanism for callers to get the object type as a raw string, rather than an object_type enum. This was in theory useful for returning types that are not representable in the enum, but we consider any such type to be an error, and there are no callers that use the strbuf anymore. Let's drop support to simplify the code a bit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16fsck: stop using object_info->type_name strbufJeff King3-40/+14
When fsck-ing a loose object, we use object_info's type_name strbuf to record the parsed object type as a string. For most objects this is redundant with the object_type enum, but it does let us report the string when we encounter an object with an unknown type (for which there is no matching enum value). There are a few downsides, though: 1. The code to report these cases is not actually robust. Since we did not pass a strbuf to unpack_loose_header(), we only retrieved types from headers up to 32 bytes. In longer cases, we'd simply say "object corrupt or missing". 2. This is the last caller that uses object_info's type_name strbuf support. It would be nice to refactor it so that we can simplify that code. 3. Likewise, we'll check the hash of the object using its unknown type (again, as long as that type is short enough). That depends on the hash_object_file_literally() code, which we'd eventually like to get rid of. So we can simplify things by bailing immediately in read_loose_object() when we encounter an unknown type. This has a few user-visible effects: a. Instead of producing a single line of error output like this: error: 26ed13ce3564fbbb44e35bde42c7da717ea004a6: object is of unknown type 'bogus': .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6 we'll now issue two lines (the first from read_loose_object() when we see the unparsable header, and the second from the fsck code, since we couldn't read the object): error: unable to parse type from header 'bogus 4' of .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6 error: 26ed13ce3564fbbb44e35bde42c7da717ea004a6: object corrupt or missing: .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6 This is a little more verbose, but this sort of error should be rare (such objects are almost impossible to work with, and cannot be transferred between repositories as they are not representable in packfiles). And as a bonus, reporting the broken header in full could help with debugging other cases (e.g., a header like "blob xyzzy\0" would fail in parsing the size, but previously we'd not have showed the offending bytes). b. An object with an unknown type will be reported as corrupt, without actually doing a hash check. Again, I think this is unlikely to matter in practice since such objects are totally unusable. We'll update one fsck test to match the new error strings. And we can remove another test that covered the case of an object with an unknown type _and_ a hash corruption. Since we'll skip the hash check now in this case, the test is no longer interesting. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16oid_object_info_convert(): stop using string for object typeJeff King1-11/+4
In oid_object_info_convert(), we convert objects between their sha1 and sha256 variants. To do this, we naturally need to know the type, which we get from oid_object_info_extended() using its type_name strbuf option. But getting the value as a string (versus an object_type enum) is not helpful. Since we do not allow unknown types, the regular enum is sufficient. And the resulting code is a bit simpler, as we no longer have to manage the extra allocation nor convert the string to an enum ourselves. Note that at first glance, it might seem like we should retain the error check for "type == -1" to catch bogus types found by the underlying parser. But we don't need it, as an unknown type would have yielded an error from the call to oid_object_info_extended(), which would already have caused us to return an error. In fact, I suspect this was always impossible to trigger. Even when we were converting the string to a type enum ourselves, an invalid type would never have escaped oid_object_info_extended(), since we never passed the (now removed) OBJECT_INFO_ALLOW_UNKNOWN_TYPE option. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16cat-file: use type enum instead of buffer for -t optionJeff King1-9/+4
Now that we no longer support OBJECT_INFO_ALLOW_UNKNOWN_TYPE, there is no need to pass a strbuf into oid_object_info_extended() to record the type. The regular object_type enum is sufficient to capture all of the types we will allow. This simplifies the code a bit, and will eventually let us drop object_info's type_name strbuf support. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flagJeff King4-49/+10
Since cat-file dropped its "--allow-unknown-type" option in the previous commit, there are no more uses of the internal flag that implemented it. Let's drop it. That in turn lets us drop the strbuf parameter of unpack_loose_header(), which now is always NULL. And without that, we can drop all of the additional code to inflate larger headers into the strbuf. Arguably we could drop ULHR_TOO_LONG, as no callers really care about the distinction from ULHR_BAD. But it's easy enough to retain, and it does let us produce a slightly more specific message in one instance. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16cat-file: make --allow-unknown-type a noopJeff King3-179/+56
The cat-file command has some minor support for handling objects with "unknown" types. I.e., strings that are not "blob", "commit", "tree", or "tag". In theory this could be used for debugging or experimenting with extensions to Git. But in practice this support is not very useful: 1. You can get the type and size of such objects, but nothing else. Not even the contents! 2. Only loose objects are supported, since packfiles use numeric ids for the types, rather than strings. 3. Likewise you cannot ever transfer objects between repositories, because they cannot be represented in the packfiles used for the on-the-wire protocol. The support for these unknown types complicates the object-parsing code, and has led to bugs such as b748ddb7a4 (unpack_loose_header(): fix infinite loop on broken zlib input, 2025-02-25). So let's drop it. The first step is to remove the user-facing parts, which are accessible only via cat-file. This is technically backwards-incompatible, but given the limitations listed above, these objects couldn't possibly be useful in any workflow. However, we can't just rip out the option entirely. That would hurt a caller who ran: git cat-file -t --allow-unknown-object <oid> and fed it normal, well-formed objects. There --allow-unknown-type was doing nothing, but we wouldn't want to start bailing with an error. So to protect any such callers, we'll retain --allow-unknown-type as a noop. The code change is fairly small (but we'll able to clean up more code in follow-on patches). The test updates drop any use of the option. We still retain tests that feed the broken objects to cat-file without --allow-unknown-type, as we should continue to confirm that those objects are rejected. Note that in one spot we can drop a layer of loop, re-indenting the body; viewing the diff with "-w" helps there. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16object-file.h: fix typo in variable declarationJeff King1-1/+1
This should be "compat", not "comapt". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16json-writer: describe the usage of jw_* functionsLucas Seiki Oshiro1-0/+28
Provide an overview of the set of functions used for manipulating `json_writer`s, by describing what functions should be used for each JSON-related task. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Acked-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16json-writer: add docstrings to jw_* functionsLucas Seiki Oshiro2-4/+143
Add a docstring for each function that manipulates json_writers. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Acked-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15The fifteenth batchJunio C Hamano1-0/+8
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15Merge branch 'tb/macos-false-but-the-compiler-does-not-know-it-fix'Junio C Hamano1-1/+1
Workaround for older macOS ld. * tb/macos-false-but-the-compiler-does-not-know-it-fix: intialize false_but_the_compiler_does_not_know_it_
2025-05-15Merge branch 'jc/t6011-mv-ro-fix'Junio C Hamano1-0/+1
Test fix. * jc/t6011-mv-ro-fix: t6011: fix misconversion from perl to sed
2025-05-15Merge branch 'dd/meson-perl-custom-path'Junio C Hamano10-10/+19
Meson-based build framework update. * dd/meson-perl-custom-path: meson: allow customize perl installation path
2025-05-15Merge branch 'ps/maintenance-missing-tasks'Junio C Hamano4-31/+257
Make repository clean-up tasks "gc" can do available to "git maintenance" front-end. * ps/maintenance-missing-tasks: builtin/maintenance: introduce "rerere-gc" task builtin/gc: move rerere garbage collection into separate function builtin/maintenance: introduce "worktree-prune" task builtin/gc: move pruning of worktrees into a separate function builtin/gc: remove global variables where it is trivial to do builtin/gc: fix indentation of `cmd_gc()` parameters
2025-05-15Merge branch 'cf/wrapper-bsd-eloop'Junio C Hamano1-1/+20
The fallback implementation of open_nofollow() depended on open("symlink", O_NOFOLLOW) to set errno to ELOOP, but a few BSD derived systems use different errno, which has been worked around. * cf/wrapper-bsd-eloop: wrapper: NetBSD gives EFTYPE and FreeBSD gives EMFILE where POSIX uses ELOOP
2025-05-15commit-graph: fix memory leak when `fill_oids_from_packs()` failsLidong Yan1-0/+2
In commit-graph.c:fill_oids_from_packs, if open_pack_index failed, memory allocated and returned by add_packed_git will leak. Simply add close_pack and free(p) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15sequencer: fix memory leak if `todo_list_rearrange_squash()` failedLidong Yan1-3/+5
In sequencer.c:todo_list_rearrange_squash, if it fails, memory allocated in `next`, `tail`, `subjects` and `subject2item` will leak. Jump to cleanup label before return could fix this leak problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15mailinfo: fix pointential memory leak if `decode_header` failedLidong Yan1-21/+21
In mailinfo.c:decode_header, if convert_to_utf8 failed, the strbuf stored in dec will leak. Simply add strbuf_release and free(dec) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15sequencer: stop pretending that an assignment is a conditionJohannes Schindelin1-3/+6
In 3e81bccdf3 (sequencer: factor out todo command name parsing, 2019-06-27), a `return` statement was introduced that basically was a long sequence of conditions, combined with `&&`, except for the last condition which is not really a condition but an assignment. The point of this construct was to return 1 (i.e. `true`) from the function if all of those conditions held true, and also assign the `bol` pointer to the end of the parsed command. Some static analyzers are really unhappy about such constructs. And human readers are at least puzzled, if not confused, by seeing a single `=` inside a chain of conditions where they would have expected to see `==` instead and, based on experience, immediately suspect a typo. Let's help all of this by turning this into the more verbose, more readable form of an `if` construct that both assigns the pointer as well as returns 1 if all of the conditions hold true. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15bundle-uri: avoid using undefined output of `sscanf()`Johannes Schindelin1-5/+7
In c429bed102 (bundle-uri: store fetch.bundleCreationToken, 2023-01-31) code was introduced that assumes that an `sscanf()` call leaves its output variables unchanged unless the return value indicates success. However, the POSIX documentation makes no such guarantee: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sscanf.html So let's make sure that the output variable `maxCreationToken` is always well-defined. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15commit-graph: avoid using stale stack addressesJohannes Schindelin1-0/+9
The code is a bit too hard to reason about to fully assess whether the `fill_commit_graph_info()` function is called at all after `write_commit_graph()` returns (and hence the stack variable `topo_levels` goes out of context). Let's simply make sure that the stack address is no longer used at that stage, thereby making the code quite a bit easier to reason about. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15trace2: avoid "futile conditional"Johannes Schindelin1-19/+5
CodeQL reports empty `if` blocks that only contain a comment as "futile conditional". The comment talks about potential plans to turn this into a warning, but that seems not to have been necessary. Replace the entire construct with a concise comment. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15Avoid redundant conditionsJohannes Schindelin2-2/+2
While `if (i <= 0) ... else if (i > 0) ...` is technically equivalent to `if (i <= 0) ... else ...`, the latter is vastly easier to read because it avoids writing out a condition that is unnecessary. Let's drop such unnecessary conditions. Pointed out by CodeQL. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15fetch: avoid unnecessary work when there is no current branchJohannes Schindelin1-1/+1
As pointed out by CodeQL, `branch_get()` may return `NULL`, in which case `branch_has_merge_config()` would return early, but we can even avoid enumerating the refs prefixes in that case, saving even more CPU cycles. Technically, we should enclose these two statements in an `if (branch) {...}` block, but the indentation is already quite deep, therefore I refrained from doing that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15has_dir_name(): make code more obviousJohannes Schindelin1-42/+13
One thing that might be non-obvious to readers (or to analyzers like CodeQL) is that the function essentially does nothing when the Git index is empty, and in particular that it does not look at the value of `len_eq_last` (which would be uninitialized at that point). Let's make this much easier to understand, by returning early if the Git index is empty, and by avoiding empty `else` blocks. This commit changes indentation and is hence best viewed using `--ignore-space-change`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15upload-pack: rename `enum` to reflect the operationJohannes Schindelin1-17/+17
While 3145ea957d (upload-pack: introduce fetch server command, 2018-03-15) added support for the `fetch` command, from the server's point of view it is an upload, and hence the `enum` should really be called `upload_state` instead of `fetch_state`. Likewise, rename its values. This also helps unconfuse CodeQL which would otherwise be at sixes or sevens about having _two_ non-local definitions of the same `enum` with the same values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15commit-graph: avoid malloc'ing a local variableJohannes Schindelin1-72/+69
We do need a context to write the commit graph, but that context is only needed during the life time of `commit_graph_write()`, therefore it can easily be a stack variable. This also helps CodeQL recognize that it is safe to assign the address of other local variables to the context's fields. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15fetch: carefully clear local variable's address after useJohannes Schindelin1-0/+1
As pointed out by CodeQL, it is a potentially dangerous practice to store local variables' addresses in non-local structs. Yet this is exactly what happens with the `acked_commits` attribute that is used in `cmd_fetch()`: The pointer to a local variable is assigned to it. Now, it is Git's convention that `cmd_*()` functions are essentially only returning just before exiting the process, therefore there is little danger that this attribute is used after the code flow returns from that function. However, code in `cmd_*()` function is often so useful that it gets lifted into a library function, at which point this issue could become a real problem. Let's make sure to clear the `acked_commits` attribute out after it was used, and before the function returns (at which point the address would go stale). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15commit: simplify codeJohannes Schindelin1-1/+1
The difference of two unsigned integers is defined to be unsigned, and therefore it is misleading to check whether it is greater than zero (instead, the more natural way would be to check whether the difference is zero or not). Let's instead avoid the subtraction altogether, and compare the two operands directly, which makes the code more obvious as a side effect. Pointed out by CodeQL's rule with the ID `cpp/unsigned-difference-expression-compared-zero`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-15gitk: do not hard-code color of search results in commit listAlexander Ogorodov1-2/+2
A global variable exists that holds the color name used to highlight search results everywhere, except that in the commit list the color is still hard-coded to "yellow". Use the global variable there as well. Signed-off-by: Alexander Ogorodov <bnfour@bnfour.net>
2025-05-14replay: replace the_repository with repo parameter passed to cmd_replay ()Elijah Newren1-30/+35
Replace the_repository everywhere with repo, feed repo from cmd_replay() to all the other functions in the file that need it, and remove the UNUSED annotation on repo. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-14packed-backend: mmap large "packed-refs" file during fsckshejialuo1-12/+7
During fsck, we use "strbuf_read" to read the content of "packed-refs" without using mmap mechanism. This is a bad practice which would consume more memory than using mmap mechanism. Besides, as all code paths in "packed-backend.c" use this way, we should make "fsck" align with the current codebase. As we have introduced the helper function "allocate_snapshot_buffer", we can simply use this function to use mmap mechanism. Suggested-by: Jeff King <peff@peff.net> Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: shejialuo <shejialuo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-14packed-backend: extract snapshot allocation in `load_contents`shejialuo1-22/+31
"load_contents" would choose which way to load the content of the "packed-refs". However, we cannot directly use this function when checking the consistency due to we don't want to open the file. And we also need to reuse the logic to avoid causing repetition. Let's create a new helper function "allocate_snapshot_buffer" to extract the snapshot allocation logic in "load_contents" and update the "load_contents" to align with the behavior. Suggested-by: Jeff King <peff@peff.net> Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: shejialuo <shejialuo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-14packed-backend: fsck should warn when "packed-refs" file is emptyshejialuo4-0/+33
We assume the "packed-refs" won't be empty and instead has at least one line in it (even when there are no refs packed, there is the file header line). Because there is no terminating LF in the empty file, we will report "packedRefEntryNotTerminated(ERROR)" to the user. However, the runtime code paths would accept an empty "packed-refs" file, for example, "create_snapshot" would simply return the "snapshot" without checking the content of "packed-refs". So, we should skip checking the content of "packed-refs" when it is empty during fsck. After 694b7a1999 (repack_without_ref(): write peeled refs in the rewritten file, 2013-04-22), we would always write a header into the "packed-refs" file. So, versions of Git that are not too ancient never write such an empty "packed-refs" file. As an empty file often indicates a sign of a filesystem-level issue, the way we want to resolve this inconsistency is not make everybody totally silent but notice and report the anomaly. Let's create a "FSCK_INFO" message id "EMPTY_PACKED_REFS_FILE" to report to the users that "packed-refs" is empty. Signed-off-by: shejialuo <shejialuo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-14scalar reconfigure: improve --maintenance docsDerrick Stolee2-9/+8
The --maintenance option for 'scalar reconfigure' has three possible values. Improve the documentation by specifying the option in the -h help menu and usage information. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-14gitk: place file name arguments after options in msgfmt callJohannes Sixt1-1/+1
The build process fails in POSIXLY_CORRECT mode: $ gitk@master:1005> POSIXLY_CORRECT=1 make * new Tcl/Tk interpreter location GEN gitk-wish Generating catalog po/zh_cn.msg msgfmt --statistics --tcl po/zh_cn.po -l zh_cn -d po/ msgfmt: --tcl requires a "-l locale" specification Try 'msgfmt --help' for more information. make: *** [Makefile:76: po/zh_cn.msg] Error 1 The reason is that option arguments cannot occur after the first non-option argument. Move the file name last. Reported-by: Nathan Royce <nroycea+kernel@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-13send-email: try to get fqdn by running hostname -f on Linux and macOSAditya Garg1-1/+15
`hostname` is a popular command available on both Linux and macOS. As per the man-page[1], `hostname -f` command returns the fully qualified domain name (FQDN) of the system. The current Net::Domain perl module being used in the script for the same has been quite unrealiable in many cases. Thankfully, we now have a better check for valid_fqdn, which does reject the invalid FQDNs given by this module properly, but at the same time, it will result in a fallback to 'localhost.localdomain' being used. `hostname -f` has been quite reliable (probably even more reliable than the Net::Domain module) and before falling back to 'localhost.localdomain', we should try to use it. Interestingly, the `hostname` command is actually used by perl modules like Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets give `hostname -f` a chance as well! [1]: https://man7.org/linux/man-pages/man1/hostname.1.html [2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88 [3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93 Signed-off-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-13The fourteenth batchJunio C Hamano1-0/+11
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-13Merge branch 'kj/glob-path-with-special-char'Junio C Hamano3-1/+432
"git add 'f?o'" did not add 'foo' if 'f?o', an unusual pathname, also existed on the working tree, which has been corrected. * kj/glob-path-with-special-char: dir.c: literal match with wildcard in pathspec should still glob
2025-05-13Merge branch 'kh/docfixes'Junio C Hamano2-2/+2
Docfixes. * kh/docfixes: doc: branch: fix inline-verbatim doc: reflog: fix `drop` subheading
2025-05-13Merge branch 'js/ci-buildsystems-cleanup'Junio C Hamano10-1950/+0
Code clean-up around stale CI elements and building with Visual Studio. * js/ci-buildsystems-cleanup: config.mak.uname: drop the `vcxproj` target contrib/buildsystems: drop support for building . vcproj/.vcxproj files ci: stop linking the `prove` cache
2025-05-13Merge branch 'ps/ci-test-aggreg-fix-for-meson'Junio C Hamano1-0/+1
Test result aggregation did not work in Meson based CI jobs. * ps/ci-test-aggreg-fix-for-meson: ci: fix aggregation of test results with Meson
2025-05-13Merge branch 'en/get-tree-entry-doc'Junio C Hamano1-5/+8
Doc update. * en/get-tree-entry-doc: tree-walk.h: fix incorrect API comment
2025-05-13gitlab-ci: always run MSVC-based Meson jobPatrick Steinhardt1-1/+0
With 7304bd2bc39 (ci: wire up Visual Studio build with Meson, 2025-01-22) we have introduced a CI job that builds and tests Git with Microsoft Visual Studio via Meson. This job is only being executed by default on GitHub Workflows though -- on GitLab CI it is marked as a "manual" job, so the developer has to actively trigger these jobs. The consequence of this split is that any breakage specific to this job is only noticed by developers who mainly work with GitHub. Let's improve this situation by also running the job by default on GitLab CI. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-13git-gui: wire up support for the Meson build systemPatrick Steinhardt4-0/+261
The Git project has started to wire up Meson as a build system in Git v2.48.0. Wire up support for Meson in "git-gui" so that we can trivially include it as a subproject in Git. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: stop including GIT-VERSION-FILE filePatrick Steinhardt1-5/+2
The "GITGUI_VERSION" variable is made available by generating and including the "GIT-VERSION-FILE" file. Its value has been used in various build steps, but in the preceding commits we have refactored those to instead source the "GIT-VERSION-FILE" directly. As a result, the variable is now only used in a single recipe, and this use can be trivially replaced with sed(1). Refactor the recipe to do so and stop including "GIT-VERSION-FILE" to simplify the build process. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: extract script to generate macOS appPatrick Steinhardt3-20/+34
Extract script to generate the macOS app. This change allows us to reuse the build logic with the Meson build system. Note that as part of this change we also modify the TKEXECUTABLE variable to track its full path. Like this we don't have to propagate both the TKEXECUTABLE and TKFRAMEWORK variables into the script, and the basename can be trivially computed from TKEXECUTABLE anyway. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: extract script to generate macOS wrapperPatrick Steinhardt3-14/+40
Extract script to generate the macOS wrapper for git-gui. This change allows us to reuse the build logic with the Meson build system. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: extract script to generate "tclIndex"Patrick Steinhardt2-14/+34
Extract script to generate "tclIndex". This change allows us to reuse the build logic with the Meson build system. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: extract script to generate "git-gui"Patrick Steinhardt2-11/+30
Extract script to generate "git-gui". This change allows us to reuse the build logic with the Meson build system. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: drop no-op GITGUI_SCRIPT replacementPatrick Steinhardt1-2/+0
The value of the GITGUI_SCRIPT variable is only used in a single place as part of an sed(1) script that massages the "git-gui.sh" script. Interestingly, this specific replacement does seem to be a no-op: we replace "^ argv0=$$0" with " argv=$(GITGUI_SCRIPT)", which has a value of "$$0". The result would thus be completely unchanged. Drop the replacement and its variable. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: make output of GIT-VERSION-GEN source'ablePatrick Steinhardt1-3/+3
The output of GIT-VERSION-GEN can be sourced by our Makefile to make the version available there. The output has a couple of spaces around the equals sign, which is perfectly valid for parsing it in our Makefile. But in subsequent steps we'll also want to source the file in a couple of newly-introduced shell scripts, but having spaces around variable assignments is invalid there. Prepare for this step by dropping the spaces surrounding the equals sign. Like this, we can easily use the same file both in our Makefile and in shell scripts. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: prepare GIT-VERSION-GEN for out-of-tree buildsPatrick Steinhardt2-15/+29
The GIT-VERSION-GEN unconditionally writes version information into the source directory in the form of the "GIT-VERSION-FILE". We are about to introduce the Meson build system though, which enforces out-of-tree builds by default, and in that context we cannot continue to write version information into the source tree. Prepare the script for out-of-tree builds by treating the source directory different from the output file. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-13git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONSPatrick Steinhardt3-21/+23
The GIT-GUI-VARS file is used to track whether any of our build options has changed. Unfortunately, the format of that file does not allow us to propagate those build options to other scripts. But as we are about to introduce support for the Meson build system, we will extract a couple of scripts to deduplicate core build logic across Makefiles and Meson. With this refactoring, it will become necessary to make build options more widely accessible. Replace GIT-GUI-VARS with a new GIT-GUI-BUILD-OPTIONS file that is being populated from a template. This file can easily be sourced from build scripts in subsequent steps. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-05-12The thirteenth batchJunio C Hamano1-0/+15
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12Merge branch 'ps/meson-bin-sh'Junio C Hamano1-1/+11
Meson-based build framework update. * ps/meson-bin-sh: meson: prefer shell at "/bin/sh" meson: report detected runtime executable paths
2025-05-12Merge branch 'ng/xdiff-truly-minimal'Junio C Hamano3-2/+18
"git diff --minimal" used to give non-minimal output when its optimization kicked in, which has been disabled. * ng/xdiff-truly-minimal: xdiff: disable cleanup_records heuristic with --minimal
2025-05-12Merge branch 'ds/fix-thin-fix'Junio C Hamano7-28/+216
"git index-pack --fix-thin" used to abort to prevent a cycle in delta chains from forming in a corner case even when there is no such cycle. * ds/fix-thin-fix: index-pack: allow revisiting REF_DELTA chains t5309: create failing test for 'git index-pack' test-tool: add pack-deltas helper
2025-05-12Merge branch 'jc/ci-skip-unavailable-external-software'Junio C Hamano1-13/+8
Further refinement on CI messages when an optional external software is unavailable (e.g. due to third-party service outage). * jc/ci-skip-unavailable-external-software: ci: download JGit from maven, not eclipse.org ci: update the message for unavailble third-party software
2025-05-12Merge branch 'ps/object-store-cleanup'Junio C Hamano41-289/+278
Further code clean-up in the object-store layer. * ps/object-store-cleanup: object-store: drop `repo_has_object_file()` treewide: convert users of `repo_has_object_file()` to `has_object()` object-store: allow fetching objects via `has_object()` object-store: move function declarations to their respective subsystems object-store: move and rename `odb_pack_keep()` object-store: drop `loose_object_path()` object-store: move `struct packed_git` into "packfile.h"
2025-05-12Merge branch 'ag/send-email-outlook'Junio C Hamano2-1/+45
Update send-email to work better with Outlook's smtp server. * ag/send-email-outlook: send-email: add --[no-]outlook-id-fix option send-email: retrieve Message-ID from outlook SMTP server
2025-05-12raw_object_store: drop extra pointer to replace_mapJeff King5-10/+8
We store the replacement data in an oidmap, which is itself a pointer in the raw_object_store struct. But there's no need for an extra pointer indirection here. It is always allocated and initialized along with the containing struct, and we never check it for NULL-ness. Let's embed the map directly in the struct, which is simpler and avoids extra pointer chasing. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12oidmap: add size functionJeff King3-2/+6
Callers which want to know how many items are in an oidmap have to look at the underlying hashmap struct, leaking an implementation detail. Let's provide a type-appropriate wrapper and use it. Note in the call from lookup_replace_object(), the caller was actually looking at the hashmap's tablesize parameter (the allocated size of the table) rather than hashmap_get_size(), the number of items in the table. This probably should have been checking the number of items all along, but the two are functionally equivalent here since we only add to the map and never remove anything. Thus if there was any allocation, it was because there is at least one item. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12oidmap: rename oidmap_free() to oidmap_clear()Jeff King7-9/+10
This function does not free the oidmap struct itself; it just drops all items from the map (using hashmap_clear_() internally). It should be called oidmap_clear(), per CodingGuidelines. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failedLidong Yan1-4/+4
In pack-bitmap.c:load_bitmap_entries_v1, the function `read_bitmap_1` allocates a bitmap and reads index data into it. However, if any of the validation checks following the allocation fail, the allocated bitmap is not freed, resulting in a memory leak. To avoid this, the validation checks should be performed before the bitmap is allocated. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12reftable: fix perf regression when reading blocks of unwanted typePatrick Steinhardt4-17/+19
In fd888311fbc (reftable/table: move reading block into block reader, 2025-04-07), we have refactored how reftable blocks are read so that most of the logic is contained in the "block.c" subsystem itself. Most importantly, the whole logic to read the data itself is now contained in that subsystem. This change caused a significant performance regression though when reading blocks that aren't of the specific type one is searching for: Benchmark 1: update-ref: create 100k refs (revision = fd888311fbc~) Time (mean ± σ): 2.171 s ± 0.028 s [User: 1.189 s, System: 0.977 s] Range (min … max): 2.117 s … 2.206 s 10 runs Benchmark 2: update-ref: create 100k refs (revision = fd888311fbc) Time (mean ± σ): 3.418 s ± 0.030 s [User: 2.371 s, System: 1.037 s] Range (min … max): 3.377 s … 3.473 s 10 runs Summary update-ref: create 100k refs (revision = fd888311fbc~) ran 1.57 ± 0.02 times faster than update-ref: create 100k refs (revision = fd888311fbc) The root caute of the performance regression is that we changed when exactly blocks of an uninteresting type are being discarded. Previous to the refactoring in the mentioned commit we'd load the block data, read its type, notice that it's not the wanted type and discard the block. After the commit though we don't discard the block immediately, but we fully decode it only to realize that it's not the desired type. We then discard the block again, but have already performed a bunch of pointless work. Fix the regression by making `reftable_block_init()` return early in case the block is not of the desired type. This fixes the performance hit: Benchmark 1: update-ref: create 100k refs (revision = HEAD~) Time (mean ± σ): 2.712 s ± 0.018 s [User: 1.990 s, System: 0.716 s] Range (min … max): 2.682 s … 2.741 s 10 runs Benchmark 2: update-ref: create 100k refs (revision = HEAD) Time (mean ± σ): 1.670 s ± 0.012 s [User: 0.991 s, System: 0.676 s] Range (min … max): 1.652 s … 1.693 s 10 runs Summary update-ref: create 100k refs (revision = HEAD) ran 1.62 ± 0.02 times faster than update-ref: create 100k refs (revision = HEAD~) Note that the baseline performance is lower than in the original due to a couple of unrelated performance improvements that have landed since the original commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12builtin/am: fix memory leak in `split_mail_stgit_series`Lidong Yan1-1/+3
In builtin/am.c:split_mail_stgit_series, if `fopen` failed, `series_dir_buf` allocated by `xstrdup` will leak. Add `free` in `!fp` if branch will prevent the leak. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12t1001: replace 'test -f' with 'test_path_is_file'Rodrigo Carvalho1-1/+1
'test_path_is_file' is a modern path checking method in Git's development. Replace the basic shell command 'test -f' with this approach. Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12git-var doc: fix usage of $ENV_VAR vs ENV_VARJean-Noël Avila1-21/+19
When refering to environment variables in the documentation, use the ENV_VARIABLE format instead of $ENV_VARIABLE. The latter is used in the documentation to refer to the actual value of the variable, not the name of the variable. Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12git-verify-* doc: update mark-up of synopsis option descriptionsJunio C Hamano3-34/+26
To unify mark-up used in our documentation to a newer convention, started by 22293895 (doc: apply synopsis simplification on git-clone and git-init, 2024-09-24), update the documentation pages for 'git verify-commit', 'git verify-tag', and 'git verify-pack' to * use [synopsis], not [verse] in the SYNOPSIS section * enclose `--option=<value>` in backquotes * do not describe non-option arguments in the OPTIONS section Signed-off-by: Junio C Hamano <gitster@pobox.com> Helped-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12git-{var,write-tree} docs: update mark-up of synopsis option descriptionsJunio C Hamano2-12/+12
To unify mark-up used in our documentation to a newer convention, started by 22293895 (doc: apply synopsis simplification on git-clone and git-init, 2024-09-24), update the documentation for 'git var' and 'git write-tree' to * use [synopsis], not [verse] in the SYNOPSIS section * enclose `--option=<value>` in backquotes Signed-off-by: Junio C Hamano <gitster@pobox.com> Helped-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12git-daemon doc: update mark-up of synopsis option descriptionsJunio C Hamano1-90/+91
To unify mark-up used in our documentation to a newer convention, started by 22293895 (doc: apply synopsis simplification on git-clone and git-init, 2024-09-24), update the documentation of 'git daemon' to * use [synopsis], not [verse] in the SYNOPSIS section * enclose `--option=<value>` in backquotes Also, split '--[no-]option' into '--option' and '--no-option' to make it easier to grep for them. Signed-off-by: Junio C Hamano <gitster@pobox.com> Helped-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12reftable/writer: fix memory leak when `writer_index_hash()` failsLidong Yan1-1/+3
In reftable/writer.c:writer_index_hash(), if `reftable_buf_add` failed, key allocated by `reftable_malloc` will not be insert into `obj_index_tree` thus leaks. Simple add reftable_free(key) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-12reftable/writer: fix memory leak when `padded_write()` failsLidong Yan1-1/+3
In reftable/writer.c:padded_write(), if w->writer failed, zeroed allocated in `reftable_calloc` will leak. w->writer could be `reftable_write_data` in reftable/stack.c, and could fail due to some write error. Simply add reftable_free(zeroed) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-10gitk: Legacy widgets doesn't have comboboxYOKOTA Hiroshi1-4/+2
Use "proc makedroplist" function to support combobox on legacy widgets mode. "proc makedroplist" uses "ttk::combobox" for themed mode, and uses "tk_optionMenu" for legacy mode to get rid of the problem. Signed-off-by: YOKOTA Hiroshi <yokota.hgml@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-09Makefile: avoid constant rebuilds with compilation databasebrian m. carlson1-1/+1
Many contributors to software use a Language Server Protocol implementation to allow their editor to learn structural information about the code they write and provide additional features, such as jumping to the declaration or definition of a function or type. In C, the usual implementation is clangd, which requires compiling with clang. Because C and C++ projects lack a standard file system layout and build system, unlike languages such as Rust and Go, clangd requires a compilation database to be generated by the clang compiler in order to pass the proper compilation flags and discover all of the files necessary to make the LSP work. This is done by setting GENERATE_COMPILATION_DATABASE to "yes". However, when that's enabled and the user runs "make" a second time, all of the files are re-compiled, which is inconvenient for contributors to Git, since it makes small changes or rebases recompile the entirety of the codebase. This happens because the directory holding the compilation database is updated anytime an object is built, so its modification date will always be newer than the first object built. To solve this, use the same trick we do just above for the .depend directory and filter the compilation database directory out if it already exists, which avoids making it a target to be built. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Helped-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-09sequencer: rework reflog message handlingPhillip Wood2-27/+34
It has been reported that "git rebase --rebase-merges" can create corrupted reflog entries like e9c962f2ea0 HEAD@{8}: <binary>�: Merged in <branch> (pull request #4441) This is due to a use-after-free bug that happens because reflog_message() uses a static `struct strbuf` and is not called to update the current reflog message stored in `ctx->reflog_message` when creating the merge. This means `ctx->reflog_message` points to a stale reflog message that has been freed by subsequent call to reflog_message() by a command such as `reset` that used the return value directly rather than storing the result in `ctx->reflog_message`. Fix this by creating the reflog message nearer to where the commit is created and storing it in a local variable which is passed as an additional parameter to run_git_commit() rather than storing the message in `struct replay_ctx`. This makes it harder to forget to call `reflog_message()` before creating a commit and using a variable with a narrower scope means that a stale value cannot carried across a from one iteration of the loop to the next which should prevent any similar use-after-free bugs in the future. A existing test is modified to demonstrate that merges are now created with the correct reflog message. Reported-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-09sequencer: move reflog message functionsPhillip Wood1-33/+33
In the next commit these functions will be called from pick_one_commit() so move them above that function to avoid a forward declaration. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-09Merge branch 'master' of https://github.com/j6t/gitkJunio C Hamano3-126/+1553
* 'master' of https://github.com/j6t/gitk: gitk: add Tamil translation gitk: limit PATH search to bare executable names gitk: _search_exe is no longer needed gitk: override $PATH search only on Windows gitk: adjust indentation to match the style used in this script
2025-05-09Merge branch 'master' of https://github.com/j6t/git-guiJunio C Hamano6-2732/+23
* 'master' of https://github.com/j6t/git-gui: git-gui: treat the message template file as a built file git-gui: heed core.commentChar/commentString git-gui: po/README: update repository location and maintainer
2025-05-09Merge branch 'js/po-update-workflow'Johannes Sixt4-2731/+12
* js/po-update-workflow: git-gui: treat the message template file as a built file git-gui: po/README: update repository location and maintainer Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-09Merge branch 'at/translation-tamil'Johannes Sixt2-0/+1458
* at/translation-tamil: gitk: add Tamil translation Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-08The twelfth batchJunio C Hamano1-0/+10
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-08Merge branch 'js/diff-codeql-false-positive-workaround'Junio C Hamano1-1/+1
Work around false positive given by CodeQL. * js/diff-codeql-false-positive-workaround: diff: check range before dereferencing an array element
2025-05-08Merge branch 'ps/mv-contradiction-fix'Junio C Hamano2-7/+81
"git mv a a/b dst" would ask to move the directory 'a' itself, as well as its contents, in a single destination directory, which is a contradicting request that is impossible to satisfy. This case is now detected and the command errors out. * ps/mv-contradiction-fix: builtin/mv: convert assert(3p) into `BUG()` builtin/mv: bail out when trying to move child and its parent
2025-05-08Merge branch 'en/hashmap-clear-fix'Junio C Hamano1-2/+3
hashmap API clean-up to ensure hashmap_clear() leaves a cleared map in a reusable state. * en/hashmap-clear-fix: hashmap: ensure hashmaps are reusable after hashmap_clear()
2025-05-08docs: add credential helper for outlook and gmail in OAuth list of helpersAditya Garg1-0/+4
This commit adds the `git-credential-outlook` and `git-credential-gmail` helpers to the list of OAuth helpers. Signed-off-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-08docs: improve send-email documentationAditya Garg1-8/+59
OAuth2.0 is a new authentication method that is being used by many email providers, including Outlook and Gmail. Recently, the Authen::SASL perl module has been updated to support OAuth2.0 authentication, thus making the git-send-email script be able to use this authentication method as well. So lets improve the documentation to reflect this change. I also had a hard time finding a reliable OAuth2.0 access token generator for Outlook and Gmail. So I added a link to the such generators which I developed myself after seaching through lots of code and API documentation to make things easier for others. Signed-off-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-08send-mail: improve checks for valid_fqdnAditya Garg1-1/+3
The current implementation of a valid Fully Qualified Domain Name is not that strict. It just checks whether it has a dot (.) and if using macOS, it should not end with .local. As per RFC1035[1], from what I understood, the following checks need to be done: - The domain must contain atleast one dot - Each label (separated by dots) must be 1-63 characters long - Labels must start and end with an alphanumeric character - Labels can contain alphanumeric characters and hyphens Here are some examples of valid and invalid labels: 'example.com', # Valid 'sub.example.com', # Valid 'my-domain.org', # Valid 'localhost', # Invalid (no dot) 'MacBook..', # Invalid (double dots) '-example.com', # Invalid (starts with a hyphen) 'example-.com', # Invalid (ends with a hyphen) 'example..com', # Invalid (double dots) 'example', # Invalid (no TLD) 'example.local', # Invalid on macOS 'valid-domain.co.uk', # Valid '123.example.com', # Valid 'example.com.', # Invalid (trailing dot) 'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars) Due to current implementation, I was not able to send emails from Ubuntu. Upon debugging, I found that the SMTP domain being passed to Outlook's servers was not valid. Net::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook.. Net::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name Net::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook.. Notice that an invalid domain name "MacBook.." is sent by git-send-email. We have a fallback code that checks output from Net::Domain::domainname() or asking domain method of an Net::SMTP instance to detect a misconfigured hostname and replace it with fallback "localhost.localdomain", but the valid_fqdn apparently is failing to say "MacBook.." is not a valid fqdn. With this patch, the rule used in valid_fqdn is tightened, the beginning part of the SMTP exchange looked like this: Net::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain Net::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [1]: https://datatracker.ietf.org/doc/html/rfc1035 Signed-off-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-08meson: allow customize perl installation pathĐoàn Trần Công Danh10-10/+19
Some distros, notably Fedora, want to install non-core Perl libraries into specific directory, namely /usr/share/perl5/vendor_perl. The Makefile build system allows this by overriding perllibdir variable, let's make meson works on par with our Makefile. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07scalar reconfigure: add --maintenance=<mode> optionDerrick Stolee3-6/+47
When users want to enable the latest and greatest configuration options recommended by Scalar after a Git upgrade, 'scalar reconfigure --all' is a great option that iterates over all repos in the multi-valued 'scalar.repos' config key. However, this feature previously forced users to enable background maintenance. In some environments this is not preferred. Add a new --maintenance=<mode> option to 'scalar reconfigure' that provides options for enabling (default), disabling, or leaving background maintenance config as-is. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07scalar clone: add --no-maintenance optionDerrick Stolee3-5/+22
When creating a new enlistment via 'scalar clone', the default is to set up situations that work for most user scenarios. Background maintenance is one of those highly-recommended options for most users. However, when using 'scalar clone' to create an enlistment in a different situation, such as prepping a VM image, it may be valuable to disable background maintenance so the manual maintenance steps do not get blocked by concurrent background maintenance activities. Add a new --no-maintenance option to 'scalar clone'. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07scalar register: add --no-maintenance optionDerrick Stolee3-4/+25
When registering a repository with Scalar to get the latest opinionated configuration, the 'scalar register' command will also set up background maintenance. This is a recommended feature for most user scenarios. However, this is not always recommended in some scenarios where background modifications may interfere with foreground activities. Specifically, setting up a clone for use in automation may require doing certain maintenance steps in the foreground that could become blocked by concurrent background maintenance operations. Allow the user to specify --no-maintenance to 'scalar register'. This requires updating the method prototype for register_dir(), so use the default of enabling this value when otherwise specified. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07scalar: customize register_dir()'s behaviorDerrick Stolee1-7/+22
In advance of adding a --[no-]maintenance option to several 'scalar' subcommands, extend the register_dir() method to include an option for how it should handle background maintenance. It's important that we understand the context of toggle_maintenance() that will enable _or disable_ maintenance depending on its input value. Add a doc comment with this information. Similarly, update register_dir() to either enable maintenance or leave it alone. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07git-gui: treat the message template file as a built fileJohannes Sixt4-2728/+9
Follow the lead of 5377abc0c9d5 ("po/git.pot: don't check in result of "make pot"", 2022-05-26) in the Git repository and do not track git-gui.pot anymore. Instead, translators are expected to integrate an up-to-date version from the master branch into their translation file using make ALL_POFILES=po/xx.po update-po Update README to describe the new process. It is now understood that different translations need not be based on the same message template file, but rather individual translators should base their translation on the most up-to-date code. Remove the section that addresses the i18n coordinator as it does not apply when no common base is required among translators. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2025-05-07builtin/maintenance: introduce "rerere-gc" taskPatrick Steinhardt4-0/+94
While git-gc(1) knows to garbage collect the rerere cache, git-maintenance(1) does not yet have a task for this cleanup. Introduce a new "rerere-gc" task to plug this gap. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07builtin/gc: move rerere garbage collection into separate functionPatrick Steinhardt1-5/+11
In a subsequent commit we are going to introduce a new "rerere-gc" task for git-maintenance(1). To prepare for this, refactor the code that spawns `git rerere gc` into a separate function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07builtin/maintenance: introduce "worktree-prune" taskPatrick Steinhardt4-0/+128
While git-gc(1) knows to prune stale worktrees, git-maintenance(1) does not yet have a task for this cleanup. Introduce a new "worktree-prune" task to plug this gap. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-07builtin/gc: move pruning of worktrees into a separate functionPatrick Steinhardt1-10/+15
In a subsequent commit we will introduce a new "worktree-prune" task for git-maintenance(1). To prepare for this, refactor the code that spawns `git worktree prune` into a separate function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>