aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2022-07-13Merge branch 'ab/test-quoting-fix'Junio C Hamano5-7/+8
Fixes for tests when the source directory has unusual characters in its path, e.g. whitespaces, double-quotes, etc. * ab/test-quoting-fix: config tests: fix harmless but broken "rm -r" cleanup test-lib.sh: fix prepend_var() quoting issue tests: add missing double quotes to included library paths
2022-07-13Merge branch 'ds/t5510-brokequote'Junio C Hamano1-1/+5
Test fix. * ds/t5510-brokequote: t5510: replace 'origin' with URL more carefully
2022-07-13Merge branch 'tb/pack-objects-remove-pahole-comment'Junio C Hamano1-10/+0
Comment fix. * tb/pack-objects-remove-pahole-comment: pack-objects.h: remove outdated pahole results
2022-07-13Merge branch 'en/t6429-test-must-be-empty-fix'Junio C Hamano1-1/+1
A test fix. * en/t6429-test-must-be-empty-fix: t6429: fix use of non-existent function
2022-07-11Sync with Git 2.37.1Junio C Hamano10-19/+134
2022-07-11The first batch after Git 2.37Junio C Hamano1-0/+31
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-11Merge branch 'ds/vscode-settings'Junio C Hamano1-2/+6
* ds/vscode-settings: vscode: improve tab size and wrapping
2022-07-11Merge branch 'cr/setup-bug-typo'Junio C Hamano1-1/+1
Typofix in a BUG() message. * cr/setup-bug-typo: setup: fix function name in a BUG() message
2022-07-11Merge branch 'rs/archive-with-internal-gzip'Junio C Hamano4-28/+100
Teach "git archive" to (optionally and then by default) avoid spawning an external "gzip" process when creating ".tar.gz" (and ".tgz") archives. * rs/archive-with-internal-gzip: archive-tar: use internal gzip by default archive-tar: use OS_CODE 3 (Unix) for internal gzip archive-tar: add internal gzip implementation archive-tar: factor out write_block() archive: rename archiver data field to filter_command archive: update format documentation
2022-07-11Merge branch 'ds/branch-checked-out'Junio C Hamano5-45/+224
Introduce a helper to see if a branch is already being worked on (hence should not be newly checked out in a working tree), which performs much better than the existing find_shared_symref() to replace many uses of the latter. * ds/branch-checked-out: branch: drop unused worktrees variable fetch: stop passing around unused worktrees variable branch: fix branch_checked_out() leaks branch: use branch_checked_out() when deleting refs fetch: use new branch_checked_out() and add tests branch: check for bisects and rebases branch: add branch_checked_out() helper
2022-07-11Merge branch 'jk/optim-promisor-object-enumeration'Junio C Hamano1-1/+2
Collection of what is referenced by objects in promisor packs have been optimized to inspect these objects in the in-pack order. * jk/optim-promisor-object-enumeration: is_promisor_object(): walk promisor packs in pack-order
2022-07-11Merge branch 'ac/bitmap-format-doc'Junio C Hamano2-96/+108
Adjust technical/bitmap-format to be formatted by AsciiDoc, and add some missing information to the documentation. * ac/bitmap-format-doc: bitmap-format.txt: add information for trailing checksum bitmap-format.txt: fix some formatting issues bitmap-format.txt: feed the file to asciidoc to generate html
2022-07-11Merge branch 'pb/diff-doc-raw-format'Junio C Hamano2-6/+6
Update "git diff/log --raw" format documentation. * pb/diff-doc-raw-format: diff-index.txt: update raw output format in examples diff-format.txt: correct misleading wording diff-format.txt: dst can be 0* SHA-1 when path is deleted, too
2022-07-11Merge branch 'jk/revisions-doc-markup-fix'Junio C Hamano1-1/+1
Documentation mark-up fix. * jk/revisions-doc-markup-fix: revisions.txt: escape "..." to avoid asciidoc horizontal ellipsis
2022-07-11Merge branch 'rs/combine-diff-with-incompatible-options'Junio C Hamano1-0/+7
Certain diff options are currently ignored when combined-diff is shown; mark them as incompatible with the feature. * rs/combine-diff-with-incompatible-options: combine-diff: abort if --output is given combine-diff: abort if --ignore-matching-lines is given
2022-07-04Git 2.37.1v2.37.1Junio C Hamano3-2/+19
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-04Merge 'js/add-i-delete' into maint-2.37Junio C Hamano2-2/+19
Rewrite of "git add -i" in C that appeared in Git 2.25 didn't correctly record a removed file to the index, which is an old regression but has become widely known because the C version has become the default in the latest release. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-02A regression fix for 2.37Junio C Hamano3-2/+11
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-02Merge branch 'js/add-i-delete'Junio C Hamano2-2/+19
Rewrite of "git add -i" in C that appeared in Git 2.25 didn't correctly record a removed file to the index, which was fixed. * js/add-i-delete: add --interactive: allow `update` to stage deleted files
2022-06-30t6429: fix use of non-existent functionElijah Newren1-1/+1
This test had a line reading ! test_file_is_empty actual which was meant to be ! test_must_be_empty actual The test worked despite the error, because even though test_file_is_empty is a non-existent function, the '!' negated the return value and made it pass. It'd be better to avoid the negation, so something like test_file_not_empty actual would be better, but perhaps it makes even more sense to specify the number of lines of expected output to make the test a bit tighter. Reported-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Elijah Newren <newren@palantir.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-30config tests: fix harmless but broken "rm -r" cleanupÆvar Arnfjörð Bjarmason1-2/+3
The "test_when_finished" cleanup phase added in 4179b4897f2 (config: allow overriding of global and system configuration, 2021-04-19) has never worked as intended, firstly the ".config/git" is a directory, so we'd need the "-r" flag, but more importantly the $HOME variable wasn't properly quoted. We'd thus end up trying to remove the "trash" part of "trash directory", which wouldn't fail with "-f", since "rm -f" won't fail on non-existing files. It's possible that this would have caused an actual failure if someone had a $HOME with a space character in it, such that our "rm -f" would fail to remove an existing directory, but in practice that probably never happened. Let's fix both the quoting issue, and the other issue cleanup issue in 4179b4897f2, which is that we were attempting to clean up ~/.config/git, but weren't cleaing up ~/.gitconfig. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-30test-lib.sh: fix prepend_var() quoting issueÆvar Arnfjörð Bjarmason1-2/+2
Fix a quoting issue in the function introduced in b9638d7286f (test-lib: make $GIT_BUILD_DIR an absolute path, 2022-02-27), running the test suite where the git checkout was on a path with e.g. a space in it would fail. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-30tests: add missing double quotes to included library pathsÆvar Arnfjörð Bjarmason3-3/+3
Fix inclusion errors which would occur if the $TEST_DIRECTORY had $IFS whitespace in it. See d42bab442d7 (core.fsyncmethod: tests for batch mode, 2022-04-04) and a242c150ebb (vimdiff: integrate layout tests in the unit tests framework ('t' folder), 2022-03-30) for the two relevant commits. Both were first released with v2.37.0-rc0 (and were also part of v2.37.0). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-28pack-objects.h: remove outdated pahole resultsTaylor Blau1-10/+0
The size and padding of `struct object_entry` is an important factor in determining the memory usage of `pack-objects`. For this reason, 3b13a5f263 (pack-objects: reorder members to shrink struct object_entry, 2018-04-14) added a comment containing some information from pahole indicating the size and padding of that struct. Unfortunately, this comment hasn't been updated since 9ac3f0e5b3 (pack-objects: fix performance issues on packing large deltas, 2018-07-22), despite the size of this struct changing many times since that commit. To see just how often the size of object_entry changes, I skimmed the first-parent history with this script: for sha in $(git rev-list --first-parent --reverse 9ac3f0e..) do echo -n "$sha " git checkout -q $sha make -s pack-objects.o 2>/dev/null pahole -C object_entry pack-objects.o | sed -n \ -e 's/\/\* size: \([0-9]*\).*/size \1/p' \ -e 's/\/\*.*padding: \([0-9]*\).*/padding \1/p' | xargs done | uniq -f1 In between each merge, the size of object_entry changes too often to record every instance here. But the important merges (along with their corresponding sizes and bit paddings) in chronological order are: ad635e82d6 (Merge branch 'nd/pack-objects-pack-struct', 2018-05-23) size 80 padding 4 29d9e3e2c4 (Merge branch 'nd/pack-deltify-regression-fix', 2018-08-22) size 80 padding 9 3ebdef2e1b (Merge branch 'jk/pack-delta-reuse-with-bitmap', 2018-09-17) size 80 padding 8 33e4ae9c50 (Merge branch 'bc/sha-256', 2019-01-29) size 96 padding 8 (indicating that the current size of the struct is 96 bytes, with 8 padding bits). Even though this comment was written in a good spirit, it is updated infrequently enough that it serves to confuse rather than to encourage contributors to update the appropriate values when the modify the definition of object_entry. For that reason, eliminate the confusion by removing the comment altogether. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-28add --interactive: allow `update` to stage deleted filesJohannes Schindelin2-2/+19
The scripted version of `git add -i` used `git update-index --add --remove`, but the built-in version implemented only the `--add` part. This fixes https://github.com/msys2/MSYS2-packages/issues/3066 Reported-by: Christoph Reiter <reiter.christoph@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-27vscode: improve tab size and wrappingDerrick Stolee1-2/+6
The contrib/vscode/init.sh script initializes the .vscode directory with some helpful metadata so VS Code handles Git code better. One big issue that VS Code has is detecting the tab width based on file type. ".txt" files were not covered by this script before, so add them with the appropriate tab widths. This prevents inserting spaces instead of tabs and keeps the tab width to eight instead of four or two. While we are here, remove the "editor.wordWrap" settings. The editor's word wrap is only cosmetic: it does not actually insert newlines when your typing goes over the column limit. This can make it appear like you have properly wrapped code, but it is incorrect. Further, existing code that is over the column limit is wrapped even if your editor window is wider than the limit. This can make reading such code more difficult. Without these lines, VS Code renders the lines accurately, without "ghost" newlines. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-27Sync with Git 2.36.2Junio C Hamano9-19/+117
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-27Git 2.37v2.37.0Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-27Merge branch 'jc/revert-show-parent-info'Junio C Hamano2-1/+3
* jc/revert-show-parent-info: revert: config documentation fixes
2022-06-27Merge tag 'l10n-2.37.0-rnd1' of https://github.com/git-l10n/git-poJunio C Hamano14-161382/+114332
l10n-2.37.0-rnd1 * tag 'l10n-2.37.0-rnd1' of https://github.com/git-l10n/git-po: l10n: sv.po: Update Swedish translation (5367t0f0u) l10n: ru.po: update Russian translation l10n: zh_TW: v2.37.0 round 1 l10n: vi(5367t): Updated translation l10n: fr v2.37 round 1 l10n: Update Catalan translation l10n: po-id for 2.37 (first batch) l10n: tr: v2.37.0 round #1 l10n: README: fix typo l10n: TEAMS: Change German translation team leader l10n: de.po: Update German translation l10n: bg.po: Updated Bulgarian translation (5367t) l10n: zh_CN: v2.37.0 round 1 l10n: es: update translation
2022-06-27revert: config documentation fixesRené Scharfe2-1/+3
43966ab315 (revert: optionally refer to commit in the "reference" format, 2022-05-26) added the documentation file config/revert.txt. Actually include it in config.txt. Make is used with a bare infinitive after the object; remove the "to". Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-26l10n: sv.po: Update Swedish translation (5367t0f0u)Peter Krefting1-15781/+7654
Run msgmerge with --no-location to drop file locations to decrease the size of future patches. Also removed old translations. Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
2022-06-26l10n: ru.po: update Russian translationDimitriy Ryazantcev1-12978/+10334
Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2022-06-26Merge branch 'l10n/zh_TW/220623' of github.com:l10n-tw/git-poJiang Xin1-13955/+12996
* 'l10n/zh_TW/220623' of github.com:l10n-tw/git-po: l10n: zh_TW: v2.37.0 round 1
2022-06-25l10n: zh_TW: v2.37.0 round 1Yi-Jyun Pan1-13955/+12996
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
2022-06-25Merge branch 'master' of github.com:vnwildman/gitJiang Xin1-12953/+7839
* 'master' of github.com:vnwildman/git: l10n: vi(5367t): Updated translation
2022-06-25l10n: vi(5367t): Updated translationTran Ngoc Quan1-12953/+7839
Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2022-06-24l10n: fr v2.37 round 1Jean-Noël Avila1-13724/+7931
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2022-06-24l10n: Update Catalan translationJordi Mas1-13360/+8338
Signed-off-by: Jordi Mas <jmas@softcatala.org>
2022-06-23Merge branch 'ab/credentials-in-url-more'Junio C Hamano1-1/+1
* ab/credentials-in-url-more: Documentation/config/transfer.txt: fix typo
2022-06-23Documentation/config/transfer.txt: fix typoTaylor Blau1-1/+1
Commit 7281c196b1 (transfer doc: move fetch.credentialsInUrl to "transfer" config namespace, 2022-06-15) propagates a typo from 6dcbdc0d66 (remote: create fetch.credentialsInUrl config, 2022-06-06), where "other" is misspelled as "oher". Fix the typo accordingly. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-23Merge branch 'po-id' of github.com:bagasme/git-poJiang Xin1-12673/+12990
* 'po-id' of github.com:bagasme/git-po: l10n: po-id for 2.37 (first batch)
2022-06-23Git 2.36.2v2.36.2Johannes Schindelin2-5/+11
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.35.4Johannes Schindelin11-12/+282
* maint-2.35: Git 2.35.4 Git 2.34.4 Git 2.33.4 Git 2.32.3 Git 2.31.4 Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.35.4v2.35.4Johannes Schindelin3-2/+9
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.34.4Johannes Schindelin10-12/+275
* maint-2.34: Git 2.34.4 Git 2.33.4 Git 2.32.3 Git 2.31.4 Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.34.4v2.34.4Johannes Schindelin3-2/+8
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.33.4Johannes Schindelin9-12/+269
* maint-2.33: Git 2.33.4 Git 2.32.3 Git 2.31.4 Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.33.4v2.33.4Johannes Schindelin3-2/+8
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.32.3Johannes Schindelin8-12/+263
* maint-2.32: Git 2.32.3 Git 2.31.4 Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.32.3v2.32.3Johannes Schindelin3-2/+8
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.31.4Johannes Schindelin7-12/+257
* maint-2.31: Git 2.31.4 Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.31.4v2.31.4Johannes Schindelin3-2/+8
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23Sync with 2.30.5Johannes Schindelin6-12/+251
* maint-2.30: Git 2.30.5 setup: tighten ownership checks post CVE-2022-24765 git-compat-util: allow root to access both SUDO_UID and root owned t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-06-23Git 2.30.5v2.30.5Johannes Schindelin3-2/+14
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23setup: tighten ownership checks post CVE-2022-24765Carlo Marcelo Arenas Belón1-11/+60
8959555cee7 (setup_git_directory(): add an owner check for the top-level directory, 2022-03-02), adds a function to check for ownership of repositories using a directory that is representative of it, and ways to add exempt a specific repository from said check if needed, but that check didn't account for owership of the gitdir, or (when used) the gitfile that points to that gitdir. An attacker could create a git repository in a directory that they can write into but that is owned by the victim to work around the fix that was introduced with CVE-2022-24765 to potentially run code as the victim. An example that could result in privilege escalation to root in *NIX would be to set a repository in a shared tmp directory by doing (for example): $ git -C /tmp init To avoid that, extend the ensure_valid_ownership function to be able to check for all three paths. This will have the side effect of tripling the number of stat() calls when a repository is detected, but the effect is expected to be likely minimal, as it is done only once during the directory walk in which Git looks for a repository. Additionally make sure to resolve the gitfile (if one was used) to find the relevant gitdir for checking. While at it change the message printed on failure so it is clear we are referring to the repository by its worktree (or gitdir if it is bare) and not to a specific directory. Helped-by: Junio C Hamano <junio@pobox.com> Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
2022-06-23Merge branch 'cb/path-owner-check-with-sudo'Junio C Hamano4-1/+179
With a recent update to refuse access to repositories of other people by default, "sudo make install" and "sudo git describe" stopped working. This series intends to loosen it while keeping the safety. * cb/path-owner-check-with-sudo: t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-06-23l10n: po-id for 2.37 (first batch)Bagas Sanjaya1-12673/+12990
Update following components: - apply.c - builtin/bisect--helper.c - builtin/fetch.c - builtin/fsck.c - builtin/log.c - builtin/notes.c - builtin/push.c - builtin/submodule--helper.c - builtin/worktree.c - index-pack.c - init-db.c - remote.c Translate following new components: - attr.c - builtin/name-rev.c - builtin/pack-objects.c - builtin/pack-refs.c - builtin/prune.c - builtin/update-server-info.c - object-file.c - object-name.c - object.c - pack-bitmap.c - pack-mtimes.c - pack-revindex.c - pack-write.c - packfile.c Besides above, fix minor grammatical issues. Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2022-06-23l10n: tr: v2.37.0 round #1Emir SARI1-12895/+7746
Signed-off-by: Emir SARI <emir_sari@icloud.com>
2022-06-23Merge branch 'master' of github.com:ruester/git-po-deJiang Xin2-13111/+7964
* 'master' of github.com:ruester/git-po-de: l10n: TEAMS: Change German translation team leader l10n: de.po: Update German translation
2022-06-23Merge branch 'master' of github.com:alshopov/git-poJiang Xin1-13314/+8766
* 'master' of github.com:alshopov/git-po: l10n: bg.po: Updated Bulgarian translation (5367t)
2022-06-23Merge branch 'fz/po-zh_CN' of github.com:fangyi-zhou/git-poJiang Xin1-12744/+13006
* 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po: l10n: zh_CN: v2.37.0 round 1
2022-06-23l10n: README: fix typoArthur Milchior1-1/+1
This 10-year old typo was introduced at 75b182ae (Update l10n guide: change the repository URL, etc, 2012-03-02). The word "l10" should be "l10n". Signed-off-by: Arthur Milchior <arthur@milchior.fr> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2022-06-22revisions.txt: escape "..." to avoid asciidoc horizontal ellipsisJeff King1-1/+1
In asciidoc's HTML output of the "gitrevisions" and "git-rev-parse" documentation, the header: The ... (three-dot) Symmetric Difference Notation is rendered using "&8230;", a horizontal ellipsis. This is visually ugly, but also hard to search for or cut-and-paste. We really mean three ascii dots (0x2e) here, so let's make sure it renders as such. The simplest way to do that is just escaping the leading dot, as the instances in the rest of the section do. Arguably this should all be converted to use backticks, which would let us drop the quoting here and elsewhere (e.g., {carat}). But that does change the rendering slightly. So let's fix the bug first, and we can decide on migrating the whole section separately. Note that this produces an empty doc-diff of the manpages. Curiously, asciidoc produces the same ellipsis entity in the XML file, but docbook then converts it back into three literal dots for the roff output! So the roff manpages have been correct all along (which may be a reason nobody noticed this until now). Reported-by: Arthur Milchior Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-22l10n: TEAMS: Change German translation team leaderMatthias Rüster1-3/+3
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2022-06-22l10n: de.po: Update German translationMatthias Rüster1-13108/+7961
Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
2022-06-22Git 2.37-rc2v2.37.0-rc2Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-22Merge branch 'tb/cruft-packs'Junio C Hamano1-2/+1
Docfix. * tb/cruft-packs: gc: simplify --cruft description
2022-06-22l10n: bg.po: Updated Bulgarian translation (5367t)Alexander Shopov1-13314/+8766
Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2022-06-22l10n: zh_CN: v2.37.0 round 1Fangyi Zhou1-12744/+13006
Reviewed-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Fangyi Zhou <me@fangyi.io>
2022-06-22Merge branch 'master' of github.com:git/gitJiang Xin3-17/+19
* 'master' of github.com:git/git: name-rev: prefix annotate-stdin with '--' in message git-prompt: fix expansion of branch colour codes git-prompt: make colourization consistent
2022-06-21t5510: replace 'origin' with URL more carefullyDerrick Stolee1-1/+5
The many test_configured_prune tests in t5510-fetch.sh test many combinations of --prune, --prune-tags, and using 'origin' or an explicit URL. Some machinery was introduced in e1790f9245f (fetch tests: fetch <url> <spec> as well as fetch [<remote>], 2018-02-09) to replace 'origin' with this explicit URL. This URL is a "file:///" URL for the root of the $TRASH_DIRECTORY. However, if the current build tree has an '@' symbol, the replacement using perl fails. It drops the '@' as well as anything else in that directory name. You can observe this locally by cloning git.git into a "victim@03" directory and running the test script. As we are writing in Perl anyway, pass in the shell variables involved to the script as arguments and perform necessary string transformations inside it, instead of assuming that it is sufficient to enclose the $remote_url variable inside a pair of single quotes. Reported-by: Randall Becker <rsbecker@nexbridge.com> Original-patch-by: Derrick Stolee <derrickstolee@github.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-21Merge branch 'jp/prompt-clear-before-upstream-mark'Junio C Hamano2-16/+18
Bash command line prompt (in contrib/) update. * jp/prompt-clear-before-upstream-mark: git-prompt: fix expansion of branch colour codes git-prompt: make colourization consistent
2022-06-21combine-diff: abort if --output is givenRené Scharfe1-0/+3
The code for combined diffs currently only writes to stdout. Abort and report that fact instead of silently ignoring the --output option. The (empty) output file has already been created at that point, though. Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-21combine-diff: abort if --ignore-matching-lines is givenRené Scharfe1-0/+4
The code for combined diffs doesn't currently support ignoring changes that match a regex. Abort and report that fact instead of running into a segfault. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-21gc: simplify --cruft descriptionRené Scharfe1-2/+1
Remove duplicate "loose objects". Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-21branch: drop unused worktrees variableJeff King1-4/+0
After b489b9d9aa (branch: use branch_checked_out() when deleting refs, 2022-06-14), we no longer look at our local "worktrees" variable, since branch_checked_out() handles it under the hood. The compiler didn't notice the unused variable because we call functions to initialize and free it (so it's not totally unused, it just doesn't do anything useful). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-21fetch: stop passing around unused worktrees variableJeff King1-15/+9
In 12d47e3b1f (fetch: use new branch_checked_out() and add tests, 2022-06-14), fetch's update_local_ref() function stopped using its "worktrees" parameter. It doesn't need it, since the branch_checked_out() function examines the global worktrees under the hood. So we can not only drop the unused parameter from that function, but also from its entire call chain. And as we do so all the way up to do_fetch(), we can see that nobody uses it at all, and we can drop the local variable there entirely. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-20name-rev: prefix annotate-stdin with '--' in messageAlexander Shopov1-1/+1
This is an option rather than command. Make the message convey this similar to the other messages in the file. Signed-off-by: Alexander Shopov <ash@kambanaria.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-18Merge branch 'master' of github.com:git/gitJiang Xin36-142/+169
* 'master' of github.com:git/git: (22 commits) Git 2.37-rc1 git-compat-util: allow root to access both SUDO_UID and root owned i18n: fix mismatched camelCase config variables Another batch of fixes before -rc1 bug_fl(): correctly initialize trace2 va_list relative_url(): fix incorrect condition pack-mtimes: avoid closing a bogus file descriptor read_index_from(): avoid memory leak submodule--helper: avoid memory leak when fetching submodules submodule-config: avoid memory leak fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()` cache-tree: remove cache_tree_find_path() pack-write: drop always-NULL parameter t5329: test 'git gc --cruft' without '--prune=now' t2107: test 'git update-index --verbose' perf-lib: fix missing test titles in output transfer doc: move fetch.credentialsInUrl to "transfer" config namespace fetch doc: note "pushurl" caveat about "credentialsInUrl", elaborate ci(github): also mark up compile errors ci(github): use grouping also in the `win-build` job ...
2022-06-17Git 2.37-rc1v2.37.0-rc1Junio C Hamano2-4/+3
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-17Merge branch 'cb/path-owner-check-with-sudo-plus'Junio C Hamano3-18/+11
"sudo git foo" used to consider a repository owned by the original user a safe one to access; it now also considers a repository owned by root a safe one, too (after all, if an attacker can craft a malicious repository owned by root, the box is 0wned already). * cb/path-owner-check-with-sudo-plus: git-compat-util: allow root to access both SUDO_UID and root owned
2022-06-17setup: fix function name in a BUG() messageCleber Rosa1-1/+1
The reference given to users when the result of setup_git_directory_gently_1() is unexpected is incorrect. Signed-off-by: Cleber Rosa <crosa@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-17git-compat-util: allow root to access both SUDO_UID and root ownedCarlo Marcelo Arenas Belón3-18/+11
Previous changes introduced a regression which will prevent root for accessing repositories owned by thyself if using sudo because SUDO_UID takes precedence. Loosen that restriction by allowing root to access repositories owned by both uid by default and without having to add a safe.directory exception. A previous workaround that was documented in the tests is no longer needed so it has been removed together with its specially crafted prerequisite. Helped-by: Johanness Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-17i18n: fix mismatched camelCase config variablesJiang Xin11-11/+11
Some config variables are combinations of multiple words, and we typically write them in camelCase forms in manpage and translatable strings. It's not easy to find mismatches for these camelCase config variables during code reviews, but occasionally they are identified during localization translations. To check for mismatched config variables, I introduced a new feature in the helper program for localization[^1]. The following mismatched config variables have been identified by running the helper program, such as "git-po-helper check-pot". Lowercase in manpage should use camelCase: * Documentation/config/http.txt: http.pinnedpubkey Lowercase in translable strings should use camelCase: * builtin/fast-import.c: pack.indexversion * builtin/gc.c: gc.logexpiry * builtin/index-pack.c: pack.indexversion * builtin/pack-objects.c: pack.indexversion * builtin/repack.c: pack.writebitmaps * commit.c: i18n.commitencoding * gpg-interface.c: user.signingkey * http.c: http.postbuffer * submodule-config.c: submodule.fetchjobs Mismatched camelCases, choose the former: * Documentation/config/transfer.txt: transfer.credentialsInUrl remote.c: transfer.credentialsInURL [^1]: https://github.com/git-l10n/git-po-helper Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-17Another batch of fixes before -rc1Junio C Hamano2-2/+5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-17Merge branch 'jk/bug-fl-va-list-fix'Junio C Hamano2-5/+7
Fix buggy va_list usage in recent code. * jk/bug-fl-va-list-fix: bug_fl(): correctly initialize trace2 va_list
2022-06-17Merge branch 'ab/credentials-in-url-more'Junio C Hamano6-30/+56
Rename fetch.credentialsInUrl to transfer.credentialsInUrl as the single configuration variable should work both in pushing and fetching. * ab/credentials-in-url-more: transfer doc: move fetch.credentialsInUrl to "transfer" config namespace fetch doc: note "pushurl" caveat about "credentialsInUrl", elaborate
2022-06-17Merge branch 'js/ci-github-workflow-markup'Junio C Hamano3-4/+27
Recent CI update hides certain failures in test jobs, which has been corrected. * js/ci-github-workflow-markup: ci(github): also mark up compile errors ci(github): use grouping also in the `win-build` job ci(github): bring back the 'print test failures' step
2022-06-17Merge branch 'js/misc-fixes'Junio C Hamano6-11/+17
Assorted fixes to problems found by Coverity. * js/misc-fixes: relative_url(): fix incorrect condition pack-mtimes: avoid closing a bogus file descriptor read_index_from(): avoid memory leak submodule--helper: avoid memory leak when fetching submodules submodule-config: avoid memory leak fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`
2022-06-17Merge branch 'jc/cocci-cleanup'Junio C Hamano1-12/+0
Remove a coccinelle rule that is no longer relevant. * jc/cocci-cleanup: cocci: retire is_null_sha1() rule
2022-06-17Merge branch 'ds/more-test-coverage'Junio C Hamano5-47/+34
Improve test coverage with a handful of tests. * ds/more-test-coverage: cache-tree: remove cache_tree_find_path() pack-write: drop always-NULL parameter t5329: test 'git gc --cruft' without '--prune=now' t2107: test 'git update-index --verbose'
2022-06-17Merge branch 'jk/perf-lib-test-titles'Junio C Hamano1-1/+1
Show test titles to the performance test output again. * jk/perf-lib-test-titles: perf-lib: fix missing test titles in output
2022-06-17Merge branch 'master' of github.com:git/gitJiang Xin1-1/+1
* 'master' of github.com:git/git: builtin/rebase: remove a redundant space in l10n string
2022-06-16bug_fl(): correctly initialize trace2 va_listJeff King2-5/+7
The code added 0cc05b044f (usage.c: add a non-fatal bug() function to go with BUG(), 2022-06-02) sets up two va_list variables: one to output to stderr, and one to trace2. But the order of initialization is wrong: va_list ap, cp; va_copy(cp, ap); va_start(ap, fmt); We copy the contents of "ap" into "cp" before it is initialized, meaning it is full of garbage. The two should be swapped. However, there's another bug, noticed by Johannes Schindelin: we forget to call va_end() for the copy. So instead of just fixing the copy's initialization, let's do two separate start/end pairs. This is allowed by the standard, and we don't need to use copy here since we have access to the original varargs. Matching the pairs with the calls makes it more obvious that everything is being done correctly. Note that we do call bug_fl() in the tests, but it didn't trigger this problem because our format string doesn't have any placeholders. So even though we were passing a garbage va_list through the stack, nobody ever needed to look at it. We can easily adjust one of the trace2 tests to trigger this, both for bug() and for BUG(). The latter isn't broken, but it's nice to exercise both a bit more. Without the fix in this patch (but with the test change), the bug() case causes a segfault. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16relative_url(): fix incorrect conditionJohannes Schindelin1-1/+1
In 63e95beb085c (submodule: port resolve_relative_url from shell to C, 2016-04-15), we added a loop over `url` where we are looking for `../` or `./` components. The loop condition we used is the pointer `url` itself, which is clearly not what we wanted. Pointed out by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16pack-mtimes: avoid closing a bogus file descriptorJohannes Schindelin1-1/+2
In 94cd775a6c52 (pack-mtimes: support reading .mtimes files, 2022-05-20), code was added to close the file descriptor corresponding to the mtimes file. However, it is possible that opening that file failed, in which case we are closing a file descriptor with the value `-1`. Let's guard that `close()` call. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16read_index_from(): avoid memory leakJohannes Schindelin1-3/+3
In 998330ac2e7c (read-cache: look for shared index files next to the index, too, 2021-08-26), we added code that allocates memory to store the base path of a shared index, but we never released that memory. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16submodule--helper: avoid memory leak when fetching submodulesJohannes Schindelin1-0/+1
In c51f8f94e5b3 (submodule--helper: run update procedures from C, 2021-08-24), we added code that first obtains the default remote, and then adds that to a `strvec`. However, we never released the default remote's memory. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16submodule-config: avoid memory leakJohannes Schindelin1-4/+4
In 961b130d20c9 (branch: add --recurse-submodules option for branch creation, 2022-01-28), a funny pattern was introduced where first some struct is `xmalloc()`ed, then we resize an array whose element type is the same struct, and then the first struct's contents are copied into the last element of that array. Crucially, the `xmalloc()`ed memory never gets released. Let's avoid that memory leak and that memory allocation dance altogether by first reallocating the array, then using a pointer to the last array element to go forward. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`Johannes Schindelin1-2/+6
Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16cache-tree: remove cache_tree_find_path()Derrick Stolee2-29/+0
This reverts 080ab56a46 (cache-tree: implement cache_tree_find_path(), 2022-05-23). The cache_tree_find_path() method was never actually called in the topic that added it. I cannot find any reference to it in any of my forks, so this appears to not be needed at the moment. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16pack-write: drop always-NULL parameterDerrick Stolee1-11/+6
write_mtimes_file() takes an mtimes parameter as its first option, but the only caller passes a NULL constant. Drop this parameter to simplify logic. This can be reverted if that parameter is needed in the future. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16t5329: test 'git gc --cruft' without '--prune=now'Derrick Stolee1-1/+3
Replace a 'git repack --cruft -d' with the wrapper 'git gc --cruft' to exercise some logic in builtin/gc.c that adds the '--cruft' option to the underlying 'git repack' command. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16t2107: test 'git update-index --verbose'Derrick Stolee1-6/+25
The '--verbose' option reports what is being added and removed from the index, but has not been tested up to this point. Augment the tests in t2107 to check the '--verbose' option in some scenarios. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16perf-lib: fix missing test titles in outputJeff King1-1/+1
Commit 5dccd9155f (t/perf: add iteration setup mechanism to perf-lib, 2022-04-04) modified the parameter parsing of test_wrapper() such that the test title was no longer in $1, and is instead in $test_title_. We correctly pass the new variable to the code which outputs the title to the log, but missed the spot in test_wrapper() where the title is written to the ".descr" file which is used to produce the final output table. As a result, all of the titles are missing from that table (or worse, using whatever was left in $1): $ ./p0000-perf-lib-sanity.sh [...] Test this tree ------------------------------ 0000.1: 0.01(0.01+0.00) 0000.2: 0.01(0.00+0.01) 0000.4: 0.00(0.00+0.00) 0000.5: true 0.00(0.00+0.00) 0000.7: 0.00(0.00+0.00) 0000.8: 0.00(0.00+0.00) After this patch, we get the pre-5dccd9155f output: Test this tree -------------------------------------------------------------------------- 0000.1: test_perf_default_repo works 0.00(0.00+0.00) 0000.2: test_checkout_worktree works 0.01(0.00+0.01) 0000.4: export a weird var 0.00(0.00+0.00) 0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś 0.00(0.00+0.00) 0000.7: important variables available in subshells 0.00(0.00+0.00) 0000.8: test-lib-functions correctly loaded in subshells 0.00(0.00+0.00) Signed-off-by: Jeff King <peff@peff.net> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16bitmap-format.txt: add information for trailing checksumAbhradeep Chakraborty1-0/+4
Bitmap file has a trailing checksum at the end of the file. However there is no information in the bitmap-format documentation about it. Add a trailer section to include the trailing checksum info in the `Documentation/technical/bitmap-format.txt` file. Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16bitmap-format.txt: fix some formatting issuesAbhradeep Chakraborty1-96/+103
The asciidoc generated html for `Documentation/technical/bitmap- format.txt` is broken. This is mainly because `-` is used for nested lists (which is not allowed in asciidoc) instead of `*`. Fix these and also reformat it for better readability of the html page. Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16bitmap-format.txt: feed the file to asciidoc to generate htmlAbhradeep Chakraborty1-0/+1
Documentation/Makefile does not include bitmap-format.txt to generate a html page using asciidoc. Teach Documentation/Makefile to also generate a html page for Documentation/technical/bitmap-format.txt file. Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16builtin/rebase: remove a redundant space in l10n stringFangyi Zhou1-1/+1
Found in l10n. Signed-off-by: Fangyi Zhou <me@fangyi.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16is_promisor_object(): walk promisor packs in pack-orderJeff King1-1/+2
When we generate the list of promisor objects, we walk every pack with a .promisor file and examine its objects for any links to other objects. By default, for_each_packed_object() will go in pack .idx order. This is the worst case with respect to our delta base cache. If we have a delta chain of A->B->C->D, then visiting A may require reconstructing both B and C, unless we also visited B recently, in which case we may have cached its value. Because .idx order is based on sha1, it's random with respect to the actual object contents and deltas, and thus we're unlikely to get many cache hits. If we instead traverse in pack order, then we get the optimal case: packs are written to keep delta families together, and to place bases before their children. Even on a modest repository like git.git, this has a noticeable speedup on p5600.4, which runs "fsck" on a partial clone with blob:none (so lots of trees which need to be walked, and which delta well): Test HEAD^ HEAD ------------------------------------------------------- 5600.4: 17.87(17.83+0.04) 15.42(15.35+0.06) -13.7% On a larger repository like linux.git, the speedup is even more pronounced: Test HEAD^ HEAD ----------------------------------------------------------- 5600.4: 322.47(322.01+0.42) 186.41(185.76+0.63) -42.2% Any other operations that call is_promisor_object(), like "rev-list --exclude-promisor-objects", would similarly benefit, but the invocations in p5600 don't actually trigger any such cases. Note that we may pay a small price to build a rev-index in-memory to do the pack-order traversal. But it's still a big net win, and even that small cost goes away if you are using pack.writeReverseIndex. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-16l10n: es: update translationAlex Henrie1-13893/+8767
* fix more translation mistakes * consistently translate "amend" as "enmendar" * consistently translate "chunk" as "fragmento" * consistently translate "prune" as "recortar" or "recorte" * consistently translate "push" as "empujar" or "empuje" * consistently translate "rephrase" as "refrasear" or "refraseo" * consistently translate "squash" as "aplastar" or "aplastamiento" Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
2022-06-15Fixes and updates post -rc0Junio C Hamano1-5/+16
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15Merge branch 'fs/ssh-default-key-command-doc'Junio C Hamano1-3/+6
Doc update. * fs/ssh-default-key-command-doc: gpg docs: explain better use of ssh.defaultKeyCommand
2022-06-15Merge branch 'po/rebase-preserve-merges'Junio C Hamano1-5/+9
Various error messages that talk about the removal of "--preserve-merges" in "rebase" have been strengthened, and "rebase --abort" learned to get out of a state that was left by an earlier use of the option. * po/rebase-preserve-merges: rebase: translate a die(preserve-merges) message rebase: note `preserve` merges may be a pull config option rebase: help users when dying with `preserve-merges` rebase.c: state preserve-merges has been removed
2022-06-15Merge branch 'jc/revert-show-parent-info'Junio C Hamano6-5/+85
"git revert" learns "--reference" option to use more human-readable reference to the commit it reverts in the message template it prepares for the user. * jc/revert-show-parent-info: revert: --reference should apply only to 'revert', not 'cherry-pick' revert: optionally refer to commit in the "reference" format
2022-06-15archive-tar: use internal gzip by defaultRené Scharfe3-20/+20
Drop the dependency on gzip(1) and use our internal implementation to create tar.gz and tgz files. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15archive-tar: use OS_CODE 3 (Unix) for internal gzipRené Scharfe1-0/+7
gzip(1) encodes the OS it runs on in the 10th byte of its output. It uses the following OS_CODE values according to its tailor.h [1]: 0 - MS-DOS 3 - UNIX 5 - Atari ST 6 - OS/2 10 - TOPS-20 11 - Windows NT The gzip.exe that comes with Git for Windows uses OS_CODE 3 for some reason, so this value is used on practically all supported platforms when generating tgz archives using gzip(1). Zlib uses a bigger set of values according to its zutil.h [2], aligned with section 4.4.2 of the ZIP specification, APPNOTE.txt [3]: 0 - MS-DOS 1 - Amiga 3 - UNIX 4 - VM/CMS 5 - Atari ST 6 - OS/2 7 - Macintosh 8 - Z-System 10 - Windows NT 11 - MVS (OS/390 - Z/OS) 13 - Acorn Risc 16 - BeOS 18 - OS/400 19 - OS X (Darwin) Thus the internal gzip implementation in archive-tar.c sets different OS_CODE header values on major platforms Windows and macOS. Git for Windows uses its own zlib-based variant since v2.20.1 by default and thus embeds OS_CODE 10 in tgz archives. The tar archive for a commit is generated consistently on all systems (by the same Git version). The OS_CODE in the gzip header does not influence extraction. Avoid leaking OS information and make tgz archives constistent and reproducable (with the same Git and libz versions) by using OS_CODE 3 everywhere. At least on macOS 12.4 this produces the same output as gzip(1) for the examples I tried: # before $ git -c tar.tgz.command='git archive gzip' archive --format=tgz v2.36.0 | shasum 3abbffb40b7c63cf9b7d91afc682f11682f80759 - # with this patch $ git -c tar.tgz.command='git archive gzip' archive --format=tgz v2.36.0 | shasum dc6dc6ba9636d522799085d0d77ab6a110bcc141 - $ git archive --format=tar v2.36.0 | gzip -cn | shasum dc6dc6ba9636d522799085d0d77ab6a110bcc141 - [1] https://git.savannah.gnu.org/cgit/gzip.git/tree/tailor.h [2] https://github.com/madler/zlib/blob/master/zutil.h [3] https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15archive-tar: add internal gzip implementationRené Scharfe3-2/+62
Git uses zlib for its own object store, but calls gzip when creating tgz archives. Add an option to perform the gzip compression for the latter using zlib, without depending on the external gzip binary. Plug it in by making write_block a function pointer and switching to a compressing variant if the filter command has the magic value "git archive gzip". Does that indirection slow down tar creation? Not really, at least not in this test: $ hyperfine -w3 -L rev HEAD,origin/main -p 'git checkout {rev} && make' \ './git -C ../linux archive --format=tar HEAD # {rev}' Benchmark #1: ./git -C ../linux archive --format=tar HEAD # HEAD Time (mean ± σ): 4.044 s ± 0.007 s [User: 3.901 s, System: 0.137 s] Range (min … max): 4.038 s … 4.059 s 10 runs Benchmark #2: ./git -C ../linux archive --format=tar HEAD # origin/main Time (mean ± σ): 4.047 s ± 0.009 s [User: 3.903 s, System: 0.138 s] Range (min … max): 4.038 s … 4.066 s 10 runs How does tgz creation perform? $ hyperfine -w3 -L command 'gzip -cn','git archive gzip' \ './git -c tar.tgz.command="{command}" -C ../linux archive --format=tgz HEAD' Benchmark #1: ./git -c tar.tgz.command="gzip -cn" -C ../linux archive --format=tgz HEAD Time (mean ± σ): 20.404 s ± 0.006 s [User: 23.943 s, System: 0.401 s] Range (min … max): 20.395 s … 20.414 s 10 runs Benchmark #2: ./git -c tar.tgz.command="git archive gzip" -C ../linux archive --format=tgz HEAD Time (mean ± σ): 23.807 s ± 0.023 s [User: 23.655 s, System: 0.145 s] Range (min … max): 23.782 s … 23.857 s 10 runs Summary './git -c tar.tgz.command="gzip -cn" -C ../linux archive --format=tgz HEAD' ran 1.17 ± 0.00 times faster than './git -c tar.tgz.command="git archive gzip" -C ../linux archive --format=tgz HEAD' So the internal implementation takes 17% longer on the Linux repo, but uses 2% less CPU time. That's because the external gzip can run in parallel on its own processor, while the internal one works sequentially and avoids the inter-process communication overhead. What are the benefits? Only an internal sequential implementation can offer this eco mode, and it allows avoiding the gzip(1) requirement. This implementation uses the helper functions from our zlib.c instead of the convenient gz* functions from zlib, because the latter doesn't give the control over the generated gzip header that the next patch requires. Original-patch-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15archive-tar: factor out write_block()René Scharfe1-4/+9
All tar archive writes have the same size and are done to the same file descriptor. Move them to a common function, write_block(), to reduce code duplication and make it easy to change the destination. Original-patch-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15archive: rename archiver data field to filter_commandRené Scharfe2-6/+6
The void pointer "data" in struct archiver is only used to store filter commands to pass tar archives to, like gzip. Rename it accordingly and also turn it into a char pointer to document the fact that it's a string reference. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15archive: update format documentationRené Scharfe1-10/+10
Mention all formats in the --format section, use backtick quoting for literal values throughout, clarify the description of the configuration option. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15tests: add LIBCURL prerequisite to tests needing libcurlÆvar Arnfjörð Bjarmason4-5/+6
Add and use a LIBCURL prerequisite for tests added in 6dcbdc0d661 (remote: create fetch.credentialsInUrl config, 2022-06-06). These tests would get as far as emitting a couple of the warnings we were testing for, but would then die as we had no "git-remote-https" program compiled. It would be more consistent with other prerequisites (e.g. PERL for NO_PERL) to name this "CURL", but since e9184b0789a (t5561: skip tests if curl is not available, 2018-04-03) we've had that prerequisite defined for checking of we have the curl(1) program. The existing "CURL" prerequisite is only used in one place, and we should probably name it "CURL_PROGRAM", then rename "LIBCURL" to "CURL" as a follow-up, but for now (pre-v2.37.0) let's aim for the most minimal fix possible. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15push: fix capitalisation of the option name autoSetupMergeFangyi Zhou1-1/+1
This was found during l10n process by Jiang Xin. Reported-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Fangyi Zhou <me@fangyi.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15transfer doc: move fetch.credentialsInUrl to "transfer" config namespaceÆvar Arnfjörð Bjarmason6-51/+53
Rename the "fetch.credentialsInUrl" configuration variable introduced in 6dcbdc0d661 (remote: create fetch.credentialsInUrl config, 2022-06-06) to "transfer". There are existing exceptions, but generally speaking the "<namespace>.<var>" configuration should only apply to command described in the "namespace" (and its sub-commands, so e.g. "clone.*" or "fetch.*" might also configure "git-remote-https"). But in the case of "fetch.credentialsInUrl" we've got a configuration variable that configures the behavior of all of "clone", "push" and "fetch", someone adjusting "fetch.*" configuration won't expect to have the behavior of "git push" altered, especially as we have the pre-existing "{transfer,fetch,receive}.fsckObjects", which configures different parts of the transfer dialog. So let's move this configuration variable to the "transfer" namespace before it's exposed in a release. We could add all of "{transfer,fetch,pull}.credentialsInUrl" at some other time, but once we have "fetch" configure "pull" such an arrangement would would be a confusing mess, as we'd at least need to have "fetch" configure "push" (but not the other way around), or change existing behavior. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15fetch doc: note "pushurl" caveat about "credentialsInUrl", elaborateÆvar Arnfjörð Bjarmason2-7/+31
Amend the documentation and release notes entry for the "fetch.credentialsInUrl" feature added in 6dcbdc0d661 (remote: create fetch.credentialsInUrl config, 2022-06-06), it currently doesn't detect passwords in `remote.<name>.pushurl` configuration. We shouldn't lull users into a false sense of security, so we need to mention that prominently. This also elaborates and clarifies the "exposes the password in multiple ways" part of the documentation. As noted in [1] a user unfamiliar with git's implementation won't know what to make of that scary claim, e.g. git hypothetically have novel git-specific ways of exposing configured credentials. The reality is that this configuration is intended as an aid for users who can't fully trust their OS's or system's security model, so lets say that's what this is intended for, and mention the most common ways passwords stored in configuration might inadvertently get exposed. 1. https://lore.kernel.org/git/220524.86ilpuvcqh.gmgdl@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15branch: fix branch_checked_out() leaksDerrick Stolee2-10/+43
The branch_checked_out() method populates a strmap linking a refname to a worktree that has that branch checked out. While unlikely, it is possible that a bug or filesystem manipulation could create a scenario where the same ref is checked out in multiple places. Further, there are some states in an interactive rebase where HEAD and REBASE_HEAD point to the same ref, leading to multiple insertions into the strmap. In either case, the strmap_put() method returns the old value which is leaked. Update branch_checked_out() to consume that pointer and free it. Add a test in t2407 that checks this erroneous case. The test "checks itself" by first confirming that the filesystem manipulations it makes trigger the branch_checked_out() logic, and then sets up similar manipulations to make it look like there are multiple worktrees pointing to the same ref. While TEST_PASSES_SANITIZE_LEAK would be helpful to demonstrate the leakage and prevent it in the future, t2407 uses helpers such as 'git clone' that cause the test to fail under that mode. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15branch: use branch_checked_out() when deleting refsDerrick Stolee2-5/+7
This is the last current use of find_shared_symref() that can easily be replaced by branch_checked_out(). The benefit of this switch is that the code is a bit simpler, but also it is faster on repeated calls. The remaining uses of find_shared_symref() are non-trivial to remove, so we probably should not continue in that direction: * builtin/notes.c uses find_shared_symref() with "NOTES_MERGE_REF" instead of "HEAD", so it doesn't have an immediate analogue with branch_checked_out(). Perhaps we should consider extending it to include that symref in addition to HEAD, BISECT_HEAD, and REBASE_HEAD. * receive-pack.c checks to see if a worktree has a checkout for the ref that is being updated. The tricky part is that it can actually decide to update the worktree directly instead of just skipping the update. This all depends on the receive.denyCurrentBranch config option. The implementation currenty cares about receiving the worktree in the result, so the current branch_checked_out() prototype is insufficient currently. This is something to investigate later, though, since a large number of refs could be updated at the same time and using the strmap implementation of branch_checked_out() could be beneficial. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15fetch: use new branch_checked_out() and add testsDerrick Stolee2-14/+55
When fetching refs from a remote, it is possible that the refspec will cause use to overwrite a ref that is checked out in a worktree. The existing logic in builtin/fetch.c uses a possibly-slow mechanism. Update those sections to use the new, more efficient branch_checked_out() helper. These uses were not previously tested, so add a test case that can be used for these kinds of collisions. There is only one test now, but more tests will be added as other consumers of branch_checked_out() are added. Note that there are two uses in builtin/fetch.c, but only one of the messages is tested. This is because the tested check is run before completing the fetch, and the untested check is not reachable without concurrent updates to the filesystem. Thus, it is beneficial to keep that extra check for the sake of defense-in-depth. However, we should not attempt to test the check, as the effort required is too complicated to be worth the effort. This use in update_local_ref() also requires a change in the error message because we no longer have access to the worktree struct, only the path of the worktree. This error is so rare that making a distinction between the two is not critical. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15branch: check for bisects and rebasesDerrick Stolee2-8/+49
The branch_checked_out() helper was added by the previous change, but it used an over-simplified view to check if a branch is checked out. It only focused on the HEAD symref, but ignored whether a bisect or rebase was happening. Teach branch_checked_out() to check for these things, and also add tests to ensure that we do not lose this functionality in the future. Now that this test coverage exists, we can safely refactor validate_new_branchname() to use branch_checked_out(). Note that we need to prepend "refs/heads/" to the 'state.branch' after calling wt_status_check_*(). We also need to duplicate wt->path so the value is not freed at the end of the call. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15branch: add branch_checked_out() helperDerrick Stolee3-0/+72
The validate_new_branchname() method contains a check to see if a branch is checked out in any non-bare worktree. This is intended to prevent a force push that will mess up an existing checkout. This helper is not suitable to performing just that check, because the method will die() when the branch is checked out instead of returning an error code. Create a new branch_checked_out() helper that performs the most basic form of this check. To ensure we can call branch_checked_out() in a loop with good performance, do a single preparation step that iterates over all worktrees and stores their current HEAD branches in a strmap. The branch_checked_out() helper can then discover these branches using a hash lookup. This helper is currently missing some key functionality. Namely: it doesn't look for active rebases or bisects which mean that the branch is "checked out" even though HEAD doesn't point to that ref. This functionality will be added in a coming change. We could use branch_checked_out() in validate_new_branchname(), but this missing functionality would be a regression. However, we have no tests that cover this case! Add a new test script that will be expanded with these cross-worktree ref updates. The current tests would still pass if we refactored validate_new_branchname() to use this version of branch_checked_out(). The next change will fix that functionality and add the proper test coverage. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-15add -i tests: mark "TODO" depending on GIT_TEST_ADD_I_USE_BUILTINÆvar Arnfjörð Bjarmason3-3/+15
Fix an issue that existed before 0527ccb1b55 (add -i: default to the built-in implementation, 2021-11-30), but which became the default with that change, we should not be marking tests that are known to pass as "TODO" tests. When GIT_TEST_ADD_I_USE_BUILTIN=1 was made the default we started passing the tests added in 0f0fba2cc87 (t3701: add a test for advanced split-hunk editing, 2019-12-06) and 1bf01040f0c (add -p: demonstrate failure when running 'edit' after a split, 2015-04-16). Thus we've been emitting this sort of output: $ prove ./t3701-add-interactive.sh ./t3701-add-interactive.sh .. ok All tests successful. Test Summary Report ------------------- ./t3701-add-interactive.sh (Wstat: 0 Tests: 70 Failed: 0) TODO passed: 45, 47 Files=1, Tests=70, 2 wallclock secs ( 0.03 usr 0.00 sys + 0.86 cusr 0.33 csys = 1.22 CPU) Result: PASS Which isn't just cosmetic, but due to issues with test_expect_failure (see [1]) we could e.g. be hiding something as bad as a segfault in the new implementation. It makes sense catch that, especially before we put out a release with the built-in "add -i", so let's generalize the check we were already doing in 0527ccb1b55 with a new "ADD_I_USE_BUILTIN" prerequisite. 1. https://lore.kernel.org/git/patch-1.7-4624abc2591-20220318T002951Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13Git 2.37-rc0v2.37.0-rc0Junio C Hamano1-0/+37
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13Merge branch 'gc/document-config-worktree-scope'Junio C Hamano2-1/+10
Doc update. * gc/document-config-worktree-scope: config: document and test the 'worktree' scope
2022-06-13Merge branch 'js/wait-or-whine-can-fail'Junio C Hamano1-1/+2
We used to log an error return from wait_or_whine() as process termination of the waited child, which was incorrect. * js/wait-or-whine-can-fail: run-command: don't spam trace2_child_exit()
2022-06-13Merge branch 'ab/remote-free-fix'Junio C Hamano1-7/+4
Use-after-free (with another forget-to-free) fix. * ab/remote-free-fix: remote.c: don't dereference NULL in freeing loop remote.c: remove braces from one-statement "for"-loops
2022-06-13Merge branch 'sn/fsmonitor-missing-clock'Junio C Hamano1-2/+3
Sample watchman interface hook sometimes failed to produce correctly formatted JSON message, which has been corrected. * sn/fsmonitor-missing-clock: fsmonitor: query watchman with right valid json
2022-06-13Merge branch 'zh/read-cache-copy-name-entry-fix'Junio C Hamano1-2/+0
Remove redundant copying (with index v3 and older) or possible over-reading beyond end of mmapped memory (with index v4) has been corrected. * zh/read-cache-copy-name-entry-fix: read-cache.c: reduce unnecessary cache entry name copying
2022-06-13Merge branch 'tb/show-ref-optim'Junio C Hamano1-9/+8
"git show-ref --heads" (and "--tags") still iterated over all the refs only to discard refs outside the specified area, which has been corrected. * tb/show-ref-optim: builtin/show-ref.c: avoid over-iterating with --heads, --tags
2022-06-13Merge branch 'ds/credentials-in-url'Junio C Hamano4-0/+117
The "fetch.credentialsInUrl" configuration variable controls what happens when a URL with embedded login credential is used. * ds/credentials-in-url: remote: create fetch.credentialsInUrl config
2022-06-13Merge branch 'jt/unparse-commit-upon-graft-change'Junio C Hamano3-1/+34
Updating the graft information invalidates the list of parents of in-core commit objects that used to be in the graft file. * jt/unparse-commit-upon-graft-change: commit,shallow: unparse commits if grafts changed
2022-06-13Merge branch 'ab/hooks-regression-fix'Junio C Hamano6-29/+155
In Git 2.36 we revamped the way how hooks are invoked. One change that is end-user visible is that the output of a hook is no longer directly connected to the standard output of "git" that spawns the hook, which was noticed post release. This is getting corrected. * ab/hooks-regression-fix: hook API: fix v2.36.0 regression: hooks should be connected to a TTY run-command: add an "ungroup" option to run_process_parallel()
2022-06-13Merge branch 'tl/ls-tree-oid-only'Junio C Hamano3-3/+204
Add tests for a regression fixed earlier. * tl/ls-tree-oid-only: ls-tree: test for the regression in 9c4d58ff2c3
2022-06-13Merge branch 'pb/range-diff-with-submodule'Junio C Hamano2-1/+52
"git -c diff.submodule=log range-diff" did not show anything for submodules that changed in the ranges being compared, and "git -c diff.submodule=diff range-diff" did not work correctly. Fix this by including the "--submodule=short" output unconditionally to be compared. * pb/range-diff-with-submodule: range-diff: show submodule changes irrespective of diff.submodule
2022-06-13diff-index.txt: update raw output format in examplesPhilippe Blain1-3/+3
The two examples in the doc for 'git diff-index' were not updated when the raw output format was changed in 81e50eabf0 ([PATCH] The diff-raw format updates., 2005-05-21) (first example) and in b6d8f309d9 ([PATCH] diff-raw format update take #2., 2005-05-23) and 7cb6ac1e4b (diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value, 2017-12-03) (second example). Update the output, inventing some characters to complete the source hash in the second example. Also correct the destination mode in the second example, which was wrongly '100664' since the addition of the example in c64b9b8860 (Reference documentation for the core git commands., 2005-05-05). Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13diff-format.txt: correct misleading wordingPhilippe Blain1-3/+3
Near the end of the "Raw output format" section, an example shows the output of 'git diff-files' for a tracked file modified on disk but not yet added to the index. However the wording is: <sha1> is shown as all 0's if a file is new on the filesystem and it is out of sync with the index. which is confusing since it can be understood to mean that 'file' is a new, yet untracked file, in which case 'git diff-files' does not care about it at all. When this example was introduced all the way back in c64b9b8860 (Reference documentation for the core git commands., 2005-05-05), 'old' and 'new' referred to the two entities being compared, depending on the command being used (diff-index, diff-tree or diff-files - which at the time were diff-cache, diff-tree and show-diff). The wording used at the time was: <new-sha1> is shown as all 0's if new is a file on the filesystem and it is out of sync with the cache. This section was reworked in 81e50eabf0 ([PATCH] The diff-raw format updates., 2005-05-21) and the mention of the meaning of 'new' and 'old' was removed. Then in f73ae1fc5d (Some typos and light editing of various manpages, 2005-10-05), the wording was changed to what it is now. In addition, in b6d8f309d9 ([PATCH] diff-raw format update take #2., 2005-05-23), the section was further reworked and did not use '<sha1>' anymore, making the example the sole user of this token. Rework the introductory sentence of the example to instead refer to 'sha1 for "dst"', which is what the text description above it uses, and fix the wording so that we do not mention a "new file". While at it, also tweak the wording used in the description of the raw format to explicitely state that all 0's are used for the destination hash if the working tree is out of sync with the index, instead of the more vague "look at worktree". Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13diff-format.txt: dst can be 0* SHA-1 when path is deleted, tooPhilippe Blain1-1/+1
"dst" can legitimately be "0\{40\}" for a creation patch, e.g. when the stat information is stale, but it falls into "look at work tree" case. The original description in b6d8f309 ([PATCH] diff-raw format update take #2., 2005-05-23) forgot that deletion also makes the "dst" 0* SHA-1. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13ci(github): also mark up compile errorsJohannes Schindelin1-2/+8
When GCC produces those helpful errors, we will want to present them in the GitHub workflow runs in the most helpful manner. To that end, we want to use workflow commands to render errors and warnings: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions In the previous commit, we ensured that grouping is used for the build in all jobs, and this allows us to piggy-back onto the `group` function to transmogrify the output. Note: If `set -o pipefail` was available, we could do this in a little more elegant way. But since some of the steps are run using `dash`, we have to do a little `{ ...; echo $? >exit.status; } | ...` dance. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-13ci(github): use grouping also in the `win-build` jobJohannes Schindelin1-1/+1
We already do the same when building Git in all the other jobs. This will allow us to piggy-back on top of grouping to mark up compiler errors in the next commit. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-10Ninth batchJunio C Hamano1-0/+18
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-10Merge branch 'ab/bug-if-bug'Junio C Hamano12-70/+231
A new bug() and BUG_if_bug() API is introduced to make it easier to uniformly log "detect multiple bugs and abort in the end" pattern. * ab/bug-if-bug: cache-tree.c: use bug() and BUG_if_bug() receive-pack: use bug() and BUG_if_bug() parse-options.c: use optbug() instead of BUG() "opts" check parse-options.c: use new bug() API for optbug() usage.c: add a non-fatal bug() function to go with BUG() common-main.c: move non-trace2 exit() behavior out of trace2.c
2022-06-10Merge branch 'jy/gitweb-xhtml5'Junio C Hamano2-1/+18
Update the doctype written in gitweb output to xhtml5. * jy/gitweb-xhtml5: gitweb: switch to an XHTML5 DOCTYPE
2022-06-10Merge branch 'jh/builtin-fsmonitor-part3'Junio C Hamano28-149/+2439
More fsmonitor--daemon. * jh/builtin-fsmonitor-part3: (30 commits) t7527: improve implicit shutdown testing in fsmonitor--daemon fsmonitor--daemon: allow --super-prefix argument t7527: test Unicode NFC/NFD handling on MacOS t/lib-unicode-nfc-nfd: helper prereqs for testing unicode nfc/nfd t/helper/hexdump: add helper to print hexdump of stdin fsmonitor: on macOS also emit NFC spelling for NFD pathname t7527: test FSMonitor on case insensitive+preserving file system fsmonitor: never set CE_FSMONITOR_VALID on submodules t/perf/p7527: add perf test for builtin FSMonitor t7527: FSMonitor tests for directory moves fsmonitor: optimize processing of directory events fsm-listen-darwin: shutdown daemon if worktree root is moved/renamed fsm-health-win32: force shutdown daemon if worktree root moves fsm-health-win32: add polling framework to monitor daemon health fsmonitor--daemon: stub in health thread fsmonitor--daemon: rename listener thread related variables fsmonitor--daemon: prepare for adding health thread fsmonitor--daemon: cd out of worktree root fsm-listen-darwin: ignore FSEvents caused by xattr changes on macOS unpack-trees: initialize fsmonitor_has_run_once in o->result ...
2022-06-10Merge branch 'gc/zero-length-branch-config-fix'Junio C Hamano2-4/+26
A misconfigured 'branch..remote' led to a bug in configuration parsing. * gc/zero-length-branch-config-fix: remote.c: reject 0-length branch names remote.c: don't BUG() on 0-length branch names
2022-06-10Merge branch 'ab/env-array'Junio C Hamano25-125/+127
Rename .env_array member to .env in the child_process structure. * ab/env-array: run-command API users: use "env" not "env_array" in comments & names run-command API: rename "env_array" to "env"
2022-06-10Merge branch 'cb/buggy-gcc-12-workaround'Junio C Hamano1-1/+0
With a more targetted workaround in http.c in another topic, we may be able to lift this blanket "GCC12 dangling-pointer warning is broken and unsalvageable" workaround. * cb/buggy-gcc-12-workaround: Revert -Wno-error=dangling-pointer
2022-06-10git-prompt: fix expansion of branch colour codesJoakim Petersen2-15/+15
Because of the wrapping of the branch name variable $b, the colour codes in the variable don't get applied, but are instead printed directly in the output. Move the wrapping of $b to before colour codes are inserted to correct this. Revert move of branch name colour codes in tests, as the branch name is now coloured after the wrapping instead of before. Signed-off-by: Joakim Petersen <joak-pet@online.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-08gpg docs: explain better use of ssh.defaultKeyCommandFabian Stelzer1-3/+6
Using `ssh-add -L` for gpg.ssh.defaultKeyCommand is not a good recommendation. It might switch keys depending on the order of known keys and it only supports ssh-* and no ecdsa or other keys. Clarify that we expect a literal key prefixed by `key::`, give valid example use cases and refer to `user.signingKey` as the preferred option. Signed-off-by: Fabian Stelzer <fs@gigacodes.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-08ci(github): bring back the 'print test failures' stepJohannes Schindelin2-1/+18
Git now shows better information in the GitHub workflow runs when a test case failed. However, when a test case was implemented incorrectly and therefore does not even run, nothing is shown. Let's bring back the step that prints the full logs of the failed tests, and to improve the user experience, print out an informational message for readers so that they do not have to know/remember where to see the full logs. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-08Sync with 'maint'Junio C Hamano1-0/+50
2022-06-08Prepare for 2.36.2Junio C Hamano2-1/+51
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-08Merge branch 'jc/clone-remote-name-leak-fix' into maintJunio C Hamano1-1/+3
"git clone --origin X" leaked piece of memory that held value read from the clone.defaultRemoteName configuration variable, which has been plugged. source: <xmqqlevl4ysk.fsf@gitster.g> * jc/clone-remote-name-leak-fix: clone: plug a miniscule leak
2022-06-08Merge branch 'ds/midx-normalize-pathname-before-comparison' into maintJunio C Hamano4-17/+49
The path taken by "git multi-pack-index" command from the end user was compared with path internally prepared by the tool withut first normalizing, which lead to duplicated paths not being noticed, which has been corrected. source: <pull.1221.v2.git.1650911234.gitgitgadget@gmail.com> * ds/midx-normalize-pathname-before-comparison: cache: use const char * for get_object_directory() multi-pack-index: use --object-dir real path midx: use real paths in lookup_multi_pack_index()
2022-06-08Merge branch 'ah/rebase-keep-base-fix' into maintJunio C Hamano3-29/+60
"git rebase --keep-base <upstream> <branch-to-rebase>" computed the commit to rebase onto incorrectly, which has been corrected. source: <20220421044233.894255-1-alexhenrie24@gmail.com> * ah/rebase-keep-base-fix: rebase: use correct base for --keep-base when a branch is given
2022-06-08Merge branch 'pw/test-malloc-with-sanitize-address' into maintJunio C Hamano2-3/+7
Avoid problems from interaction between malloc_check and address sanitizer. source: <pull.1210.git.1649507317350.gitgitgadget@gmail.com> * pw/test-malloc-with-sanitize-address: tests: make SANITIZE=address imply TEST_NO_MALLOC_CHECK
2022-06-08Merge branch 'rs/commit-summary-wo-break-rewrite' into maintJunio C Hamano2-1/+31
The commit summary shown after making a commit is matched to what is given in "git status" not to use the break-rewrite heuristics. source: <c35bd0aa-2e46-e710-2b39-89f18bad0097@web.de> * rs/commit-summary-wo-break-rewrite: commit, sequencer: turn off break_opt for commit summary
2022-06-08Merge branch 'mg/detect-compiler-in-c-locale' into maintJunio C Hamano1-1/+1
Build procedure fixup. source: <f306f43f375bc9b9c98e85260587442e5d9ef0ba.1652094958.git.git@grubix.eu> * mg/detect-compiler-in-c-locale: detect-compiler: make detection independent of locale
2022-06-08Merge branch 'cb/ci-make-p4-optional' into maintJunio C Hamano1-10/+16
macOS CI jobs have been occasionally flaky due to tentative version skew between perforce and the homebrew packager. Instead of failing the whole CI job, just let it skip the p4 tests when this happens. source: <20220512223940.238367-1-gitster@pobox.com> * cb/ci-make-p4-optional: ci: use https, not http to download binaries from perforce.com ci: reintroduce prevention from perforce being quarantined in macOS ci: avoid brew for installing perforce ci: make failure to find perforce more user friendly
2022-06-08Merge branch 'ab/valgrind-fixes' into maintJunio C Hamano7-14/+39
A bit of test framework fixes with a few fixes to issues found by valgrind. source: <20220512223218.237544-1-gitster@pobox.com> * ab/valgrind-fixes: commit-graph.c: don't assume that stat() succeeds object-file: fix a unpack_loose_header() regression in 3b6a8db3b03 log test: skip a failing mkstemp() test under valgrind tests: using custom GIT_EXEC_PATH breaks --valgrind tests
2022-06-08Merge branch 'jc/archive-add-file-normalize-mode' into maintJunio C Hamano1-1/+1
"git archive --add-file=<path>" picked up the raw permission bits from the path and propagated to zip output in some cases, without normalization, which has been corrected (tar output did not have this issue). source: <xmqqmtfme8v6.fsf@gitster.g> * jc/archive-add-file-normalize-mode: archive: do not let on-disk mode leak to zip archives
2022-06-08Merge branch 'jc/show-branch-g-current' into maintJunio C Hamano2-0/+18
The "--current" option of "git show-branch" should have been made incompatible with the "--reflog" mode, but this was not enforced, which has been corrected. source: <xmqqh76mf7s4.fsf_-_@gitster.g> * jc/show-branch-g-current: show-branch: -g and --current are incompatible
2022-06-08Merge branch 'jc/update-ozlabs-url' into maintJunio C Hamano1-1/+4
Update URL to the gitk repository. * jc/update-ozlabs-url: SubmittingPatches: use more stable git.ozlabs.org URL
2022-06-08Merge branch 'jc/http-clear-finished-pointer' into maintJunio C Hamano1-0/+26
Meant to go with js/ci-gcc-12-fixes. source: <xmqq7d68ytj8.fsf_-_@gitster.g> * jc/http-clear-finished-pointer: http.c: clear the 'finished' member once we are done with it
2022-06-08Merge branch 'js/ci-gcc-12-fixes' into maintJunio C Hamano3-1/+11
Fixes real problems noticed by gcc 12 and works around false positives. source: <pull.1238.git.1653351786.gitgitgadget@gmail.com> * js/ci-gcc-12-fixes: dir.c: avoid "exceeds maximum object size" error with GCC v12.x nedmalloc: avoid new compile error compat/win32/syslog: fix use-after-realloc
2022-06-07config: document and test the 'worktree' scopeGlen Choo2-1/+10
Test that "git config --show-scope" shows the "worktree" scope, and add it to the list of scopes in Documentation/git-config.txt. "git config --help" does not need to be updated because it already mentions "worktree". Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07cocci: retire is_null_sha1() ruleJunio C Hamano1-12/+0
Since 8d4d86b0 (cache: remove null_sha1, 2019-08-18) removed the is_null_sha1() function, rewrite rules to correct callers of the function to use is_null_oid() instead has become irrelevant, as any new callers of the function will get caught by the compiler much more quickly without spending cycles on Coccinelle. Remove these rules. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07Eighth batchJunio C Hamano1-0/+13
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07Merge branch 'jc/all-negative-pathspec'Junio C Hamano2-1/+182
A git subcommand like "git add -p" spawns a separate git process while relaying its command line arguments. A pathspec with only negative elements was mistakenly passed with an empty string, which has been corrected. * jc/all-negative-pathspec: pathspec: correct an empty string used as a pathspec element
2022-06-07Merge branch 'js/scalar-diagnose'Junio C Hamano6-22/+435
Implementation of "scalar diagnose" subcommand. * js/scalar-diagnose: scalar: teach `diagnose` to gather loose objects information scalar: teach `diagnose` to gather packfile info scalar diagnose: include disk space information scalar: implement `scalar diagnose` scalar: validate the optional enlistment argument archive --add-virtual-file: allow paths containing colons archive: optionally add "virtual" files
2022-06-07Merge branch 'rs/document-archive-prefix'Junio C Hamano1-4/+12
The documentation on the interaction between "--add-file" and "--prefix" options of "git archive" has been improved. * rs/document-archive-prefix: archive: improve documentation of --prefix
2022-06-07Merge branch 'fh/transport-push-leakfix'Junio C Hamano1-127/+133
Leakfix. * fh/transport-push-leakfix: transport: free local and remote refs in transport_push() transport: unify return values and exit point from transport_push() transport: remove unnecessary indenting in transport_push()
2022-06-07Merge branch 'js/ci-github-workflow-markup'Junio C Hamano8-139/+297
Update the GitHub workflow support to make it quicker to get to the failing test. * js/ci-github-workflow-markup: ci: call `finalize_test_case_output` a little later ci(github): mention where the full logs can be found ci: use `--github-workflow-markup` in the GitHub workflow ci(github): avoid printing test case preamble twice ci(github): skip the logs of the successful test cases ci: optionally mark up output in the GitHub workflow ci/run-build-and-tests: add some structure to the GitHub workflow output ci: make it easier to find failed tests' logs in the GitHub workflow ci/run-build-and-tests: take a more high-level view test(junit): avoid line feeds in XML attributes tests: refactor --write-junit-xml code ci: fix code style
2022-06-07Merge branch 'ab/plug-leak-in-revisions'Junio C Hamano117-190/+500
Plug the memory leaks from the trickiest API of all, the revision walker. * ab/plug-leak-in-revisions: (27 commits) revisions API: add a TODO for diff_free(&revs->diffopt) revisions API: have release_revisions() release "topo_walk_info" revisions API: have release_revisions() release "date_mode" revisions API: call diff_free(&revs->pruning) in revisions_release() revisions API: release "reflog_info" in release revisions() revisions API: clear "boundary_commits" in release_revisions() revisions API: have release_revisions() release "prune_data" revisions API: have release_revisions() release "grep_filter" revisions API: have release_revisions() release "filter" revisions API: have release_revisions() release "cmdline" revisions API: have release_revisions() release "mailmap" revisions API: have release_revisions() release "commits" revisions API users: use release_revisions() for "prune_data" users revisions API users: use release_revisions() with UNLEAK() revisions API users: use release_revisions() in builtin/log.c revisions API users: use release_revisions() in http-push.c revisions API users: add "goto cleanup" for release_revisions() stash: always have the owner of "stash_info" free it revisions API users: use release_revisions() needing REV_INFO_INIT revision.[ch]: document and move code declared around "init" ...
2022-06-07Merge branch 'yw/cmake-updates'Junio C Hamano1-4/+18
CMake updates. * yw/cmake-updates: cmake: remove (_)UNICODE def on Windows in CMakeLists.txt cmake: add pcre2 support cmake: fix CMakeLists.txt on Linux
2022-06-07run-command: don't spam trace2_child_exit()Josh Steadmon1-1/+2
In rare cases[1], wait_or_whine() cannot determine a child process's status (and will return -1 in this case). This can cause Git to issue trace2 child_exit events despite the fact that the child may still be running. In pathological cases, we've seen > 80 million exit events in our trace logs for a single child process. Fix this by only issuing trace2 events in finish_command_in_signal() if we get a value other than -1 from wait_or_whine(). This can lead to missing child_exit events in such a case, but that is preferable to duplicating events on a scale that threatens to fill the user's filesystem with invalid trace logs. [1]: This can happen when: * waitpid() returns -1 and errno != EINTR * waitpid() returns an invalid PID * the status set by waitpid() has neither the WIFEXITED() nor WIFSIGNALED() flags Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07hook API: fix v2.36.0 regression: hooks should be connected to a TTYÆvar Arnfjörð Bjarmason2-0/+32
Fix a regression reported[1] against f443246b9f2 (commit: convert {pre-commit,prepare-commit-msg} hook to hook.h, 2021-12-22): Due to using the run_process_parallel() API in the earlier 96e7225b310 (hook: add 'run' subcommand, 2021-12-22) we'd capture the hook's stderr and stdout, and thus lose the connection to the TTY in the case of e.g. the "pre-commit" hook. As a preceding commit notes GNU parallel's similar --ungroup option also has it emit output faster. While we're unlikely to have hooks that emit truly massive amounts of output (or where the performance thereof matters) it's still informative to measure the overhead. In a similar "seq" test we're now ~30% faster: $ cat .git/hooks/seq-hook; git hyperfine -L rev origin/master,HEAD~0 -s 'make CFLAGS=-O3' './git hook run seq-hook' #!/bin/sh seq 100000000 Benchmark 1: ./git hook run seq-hook' in 'origin/master Time (mean ± σ): 787.1 ms ± 13.6 ms [User: 701.6 ms, System: 534.4 ms] Range (min … max): 773.2 ms … 806.3 ms 10 runs Benchmark 2: ./git hook run seq-hook' in 'HEAD~0 Time (mean ± σ): 603.4 ms ± 1.6 ms [User: 573.1 ms, System: 30.3 ms] Range (min … max): 601.0 ms … 606.2 ms 10 runs Summary './git hook run seq-hook' in 'HEAD~0' ran 1.30 ± 0.02 times faster than './git hook run seq-hook' in 'origin/master' 1. https://lore.kernel.org/git/CA+dzEBn108QoMA28f0nC8K21XT+Afua0V2Qv8XkR8rAeqUCCZw@mail.gmail.com/ Reported-by: Anthony Sottile <asottile@umich.edu> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> [jc: minor fix-up to tests for consistency] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07remote.c: don't dereference NULL in freeing loopÆvar Arnfjörð Bjarmason1-1/+1
Fix a bug in fd3cb0501e1 (remote: move static variables into per-repository struct, 2021-11-17) where we'd free(remote->pushurl[i]) after having NULL'd out remote->pushurl. itself. We free "remote->pushurl" in the next "for"-loop, so doing this appears to have been a copy/paste error. Before this change GCC 12's -fanalyzer would correctly note that we'd dereference NULL in this case, this change fixes that: remote.c: In function ‘remote_clear’: remote.c:153:17: error: dereference of NULL ‘*remote.pushurl’ [CWE-476] [-Werror=analyzer-null-dereference] 153 | free((char *)remote->pushurl[i]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [...] Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07remote.c: remove braces from one-statement "for"-loopsÆvar Arnfjörð Bjarmason1-6/+3
Remove braces that don't follow the CodingGuidelines from code added in fd3cb0501e1 (remote: move static variables into per-repository struct, 2021-11-17). A subsequent commit will edit code adjacent to this. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07run-command: add an "ungroup" option to run_process_parallel()Ævar Arnfjörð Bjarmason4-29/+123
Extend the parallel execution API added in c553c72eed6 (run-command: add an asynchronous parallel child processor, 2015-12-15) to support a mode where the stdout and stderr of the processes isn't captured and output in a deterministic order, instead we'll leave it to the kernel and stdio to sort it out. This gives the API same functionality as GNU parallel's --ungroup option. As we'll see in a subsequent commit the main reason to want this is to support stdout and stderr being connected to the TTY in the case of jobs=1, demonstrated here with GNU parallel: $ parallel --ungroup 'test -t {} && echo TTY || echo NTTY' ::: 1 2 TTY TTY $ parallel 'test -t {} && echo TTY || echo NTTY' ::: 1 2 NTTY NTTY Another is as GNU parallel's documentation notes a potential for optimization. As demonstrated in next commit our results with "git hook run" will be similar, but generally speaking this shows that if you want to run processes in parallel where the exact order isn't important this can be a lot faster: $ hyperfine -r 3 -L o ,--ungroup 'parallel {o} seq ::: 10000000 >/dev/null ' Benchmark 1: parallel seq ::: 10000000 >/dev/null Time (mean ± σ): 220.2 ms ± 9.3 ms [User: 124.9 ms, System: 96.1 ms] Range (min … max): 212.3 ms … 230.5 ms 3 runs Benchmark 2: parallel --ungroup seq ::: 10000000 >/dev/null Time (mean ± σ): 154.7 ms ± 0.9 ms [User: 136.2 ms, System: 25.1 ms] Range (min … max): 153.9 ms … 155.7 ms 3 runs Summary 'parallel --ungroup seq ::: 10000000 >/dev/null ' ran 1.42 ± 0.06 times faster than 'parallel seq ::: 10000000 >/dev/null ' A large part of the juggling in the API is to make the API safer for its maintenance and consumers alike. For the maintenance of the API we e.g. avoid malloc()-ing the "pp->pfd", ensuring that SANITIZE=address and other similar tools will catch any unexpected misuse. For API consumers we take pains to never pass the non-NULL "out" buffer to an API user that provided the "ungroup" option. The resulting code in t/helper/test-run-command.c isn't typical of such a user, i.e. they'd typically use one mode or the other, and would know whether they'd provided "ungroup" or not. We could also avoid the strbuf_init() for "buffered_output" by having "struct parallel_processes" use a static PARALLEL_PROCESSES_INIT initializer, but let's leave that cleanup for later. Using a global "run_processes_parallel_ungroup" variable to enable this option is rather nasty, but is being done here to produce as minimal of a change as possible for a subsequent regression fix. This change is extracted from a larger initial version[1] which ends up with a better end-state for the API, but in doing so needed to modify all existing callers of the API. Let's defer that for now, and narrowly focus on what we need for fixing the regression in the subsequent commit. It's safe to do this with a global variable because: A) hook.c is the only user of it that sets it to non-zero, and before we'll get any other API users we'll refactor away this method of passing in the option, i.e. re-roll [1]. B) Even if hook.c wasn't the only user we don't have callers of this API that concurrently invoke this parallel process starting API itself in parallel. As noted above "A" && "B" are rather nasty, and we don't want to live with those caveats long-term, but for now they should be an acceptable compromise. 1. https://lore.kernel.org/git/cover-v2-0.8-00000000000-20220518T195858Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07fsmonitor: query watchman with right valid jsonSon Luong Ngoc1-2/+3
In rare circumstances where the current git index does not carry the last_update_token, the fsmonitor v2 hook will be invoked with an empty string which would caused the final rendered json to be invalid. ["query", "/path/to/my/git/repository/", { "since": , "fields": ["name"], "expression": ["not", ["dirname", ".git"]] }] Which will left user with the following error message > git status failed to parse command from stdin: line 2, column 13, position 67: unexpected token near ',' Watchman: command returned no output. Falling back to scanning... Hide the "since" field in json query when "last_update_token" is empty. Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Son Luong Ngoc <sluongng@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-07git-prompt: make colourization consistentJoakim Petersen2-19/+21
The short upstream state indicator inherits the colour of the last short state indicator before it (if there is one), and the sparsity state indicator inherits this colour as well. This behaviour was introduced by 0ec7c23cdc6 (git-prompt: make upstream state indicator location consistent, 2022-02-27), while before this change the aforementioned indicators were white/the default text colour. Some examples to illustrate this behaviour (assuming all indicators are enabled and colourization is on): * If there is something in the stash, both the '$' and the short upstream state indicator following it will be blue. * If the local tree has new, untracked files and there is nothing in the stash, both the '%' and the short upstream state indicator will be red. * If all local changes are added to the index and the stash is empty, both the '+' and the short upstream state indicator following it will be green. * If the local tree is clean and there is nothing in the stash, the short upstream state indicator will be white/${default text colour}. This appears to be an unintended side-effect of the change, and makes little sense semantically (e.g. why is it bad to be in sync with upstream when you have uncommitted local changes?). The cause of the change in colourization is that previously, the short upstream state indicator appeared immediately after the rebase/revert/bisect/merge state indicator (note the position of $p in $gitstring): local f="$h$w$i$s$u" local gitstring="$c$b${f:+$z$f}${sparse}$r$p" Said indicator is prepended with the clear colour code, and the short upstream state indicator is thus also uncoloured. Now, the short upstream state indicator follows the sequence of colourized indicators, without any clearing of colour (again note the position of $p, now in $f): local f="$h$w$i$s$u$p" local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" If the user is in a sparse checkout, the sparsity state indicator follows a similar pattern to the short upstream state indicator. However, clearing colour of the colourized indicators changes how the sparsity state indicator is colourized, as it currently inherits (and before the change referenced also inherited) the colour of the last short state indicator before it. Reading the commit message of the change that introduced the sparsity state indicator, afda36dbf3b (git-prompt: include sparsity state as well, 2020-06-21), it appears this colourization also was unintended, so clearing the colour for said indicator further increases consistency. Make the colourization of these state indicators consistent by making all colourized indicators clear their own colour. Make colouring of $c dependent on it not being empty, as it is no longer being used to colour the branch name. Move clearing of $b's prefix to before colourization so it gets cleared properly when colour codes are inserted into it. These changes make changing the layout of the prompt less prone to unintended colour changes in the future. Change coloured Bash prompt tests to reflect the colourization changes: * Move the colour codes to wrap the expected content of the expanded $__git_ps1_branch_name in all tests. * Insert a clear-colour code after the symbol for the first indicator in "prompt - bash color pc mode - dirty status indicator - dirty index and worktree", to reflect that all indicators should clear their own colour. Signed-off-by: Joakim Petersen <joak-pet@online.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06range-diff: show submodule changes irrespective of diff.submodulePhilippe Blain2-1/+52
After generating diffs for each range to be compared using a 'git log' invocation, range-diff.c::read_patches looks for the "diff --git" header in those diffs to recognize the beginning of a new change. In a project with submodules, and with 'diff.submodule=log' set in the config, this header is missing for the diff of a changed submodule, so any submodule changes are quietly ignored in the range-diff. When 'diff.submodule=diff' is set in the config, the "diff --git" header is also missing for the submodule itself, but is shown for submodule content changes, which can easily confuse 'git range-diff' and lead to errors such as: error: git apply: bad git-diff - inconsistent old filename on line 1 error: could not parse git header 'diff --git path/to/submodule/and/some/file/within ' error: could not parse log for '@{u}..@{1}' Force the submodule diff format to its default ("short") when invoking 'git log' to generate the patches for each range, such that submodule changes are always detected. Add a test, including an invocation with '--creation-factor=100' to force the second commit in the range not to be considered a complete rewrite, in order to verify we do indeed get the "short" format. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06commit,shallow: unparse commits if grafts changedJonathan Tan3-1/+34
When a commit is parsed, it pretends to have a different (possibly empty) list of parents if there is graft information for that commit. But there is a bug that could occur when a commit is parsed, the graft information is updated (for example, when a shallow file is rewritten), and the same commit is subsequently used: the parents of the commit do not conform to the updated graft information, but the information at the time of parsing. This is usually not an issue, as a commit is usually introduced into the repository at the same time as its graft information. That means that when we try to parse that commit, we already have its graft information. But it is an issue when fetching a shallow point directly into a repository with submodules. The function assign_shallow_commits_to_refs() parses all sought objects (including the shallow point, which we are directly fetching). In update_shallow() in fetch-pack.c, assign_shallow_commits_to_refs() is called before commit_shallow_file(), which means that the shallow point would have been parsed before graft information is updated. Once a commit is parsed, it is no longer sensitive to any graft information updates. This parsed commit is subsequently used when we do a revision walk to search for submodules to fetch, meaning that the commit is considered to have parents even though it is a shallow point (and therefore should be treated as having no parents). Therefore, whenever graft information is updated, mark the commits that were previously grafts and the commits that are newly grafts as unparsed. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06rebase: translate a die(preserve-merges) messagePhilip Oakley1-2/+2
This is a user facing message for a situation seen in the wild. Translate it. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06rebase: note `preserve` merges may be a pull config optionPhilip Oakley1-1/+3
The `--preserve-merges` option was removed by v2.34.0. However users may not be aware that it is also a Pull configuration option, which is still offered by major IDE vendors such as Visual Studio. Extend the `--preserve-merges` die message to also direct users to the possible use of the `preserve` option in the `pull.rebase` config. This is an additional 'belt and braces' information statement. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06rebase: help users when dying with `preserve-merges`Philip Oakley1-2/+4
Git would die if a "rebase --preserve-merges" was in progress. Users could neither --quit, --abort, nor --continue the rebase. Make the `rebase --abort` option available to allow users to remove traces of any preserve-merges rebase, even if they had upgraded during a rebase. One trigger case was an unexpectedly difficult to resolve conflict, as reported on the `git-users` group. (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM) Other potential use-cases include git-experts using the portable 'Git on a stick' to help users with an older git version. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06rebase.c: state preserve-merges has been removedPhilip Oakley1-2/+2
Since feebd2d256 (rebase: hide --preserve-merges option, 2019-10-18) this option is now removed as stated in the subsequent release notes. Fix and reflow the option tip. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06read-cache.c: reduce unnecessary cache entry name copyingZheNing Hu1-2/+0
575fa8a3 (read-cache: read data in a hash-independent way, 2019-02-19) added a new code to copy from the on-disk data into the name member of the in-core cache entry, which is already done immediately after that in a way that takes prefix-compression into account. Remove this code, as it is not just unnecessary, but also can be reading beyond the on-disk data, when we are copying very long prefix string from the previous entry. Signed-off-by: ZheNing Hu <adlternative@gmail.com> [jc: rewrote the log message with Réne's findings] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06builtin/show-ref.c: avoid over-iterating with --heads, --tagsTaylor Blau1-9/+8
When `show-ref` is combined with the `--heads` or `--tags` options, it can avoid iterating parts of a repository's references that it doesn't care about. But it doesn't take advantage of this potential optimization. When this command was introduced back in 358ddb62cf (Add "git show-ref" builtin command, 2006-09-15), `for_each_ref_in()` did exist. But since most repositories don't have many (any?) references that aren't branches or tags already, this makes little difference in practice. Though for repositories with a large imbalance of branches and tags (or, more likely in the case of server operators, many hidden references), this can make quite a difference. Take, for example, a repository with 500,000 "hidden" references (all of the form "refs/__hidden__/N"), and a single branch: git commit --allow-empty -m "base" && seq 1 500000 | sed 's,\(.*\),create refs/__hidden__/\1 HEAD,' | git update-ref --stdin && git pack-refs --all Outputting the existence of that single branch currently takes on the order of ~50ms on my machine. The vast majority of this time is wasted iterating through references that we know we're going to discard. Instead, teach `show-ref` that it can iterate just "refs/heads" and/or "refs/tags" when given `--heads` and/or `--tags`, respectively. A few small interesting things to note: - When given either option, we can avoid the general-purpose for_each_ref() call altogether, since we know that it won't give us any references that we wouldn't filter out already. - We can make two separate calls to `for_each_fullref_in()` (and avoid, say, the more specialized `for_each_fullref_in_prefixes()`, since we know that the set of references enumerated by each is disjoint, so we'll never see the same reference appear in both calls. - We have to use the "fullref" variant (instead of just `for_each_branch_ref()` and `for_each_tag_ref()`), since we expect fully-qualified reference names to appear in `show-ref`'s output. When either of `heads_only` or `tags_only` is set, we can eliminate the strcmp() calls in `builtin/show-ref.c::show_ref()` altogether, since we know that `show_ref()` will never see a non-branch or tag reference. Unfortunately, we can't use `for_each_fullref_in_prefixes()` to enhance `show-ref`'s pattern matching, since `show-ref` patterns match on the _suffix_ (e.g., the pattern "foo" shows "refs/heads/foo", "refs/tags/foo", and etc, not "foo/*"). Nonetheless, in our synthetic example above, this provides a significant speed-up ("git" is roughly v2.36, "git.compile" is this patch): $ hyperfine -N 'git show-ref --heads' 'git.compile show-ref --heads' Benchmark 1: git show-ref --heads Time (mean ± σ): 49.9 ms ± 6.2 ms [User: 45.6 ms, System: 4.1 ms] Range (min … max): 46.1 ms … 73.6 ms 43 runs Benchmark 2: git.compile show-ref --heads Time (mean ± σ): 2.8 ms ± 0.4 ms [User: 1.4 ms, System: 1.2 ms] Range (min … max): 1.3 ms … 5.6 ms 957 runs Summary 'git.compile show-ref --heads' ran 18.03 ± 3.38 times faster than 'git show-ref --heads' Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-06-06remote: create fetch.credentialsInUrl configDerrick Stolee4-0/+117
Users sometimes provide a "username:password" combination in their plaintext URLs. Since Git stores these URLs in plaintext in the .git/config file, this is a very insecure way of storing these credentials. Credential managers are a more secure way of storing this information. System administrators might want to prevent this kind of use by users on their machines. Create a new "fetch.credentialsInUrl" config option and teach Git to warn or die when seeing a URL with this kind of information. The warning anonymizes the sensitive information of the URL to be clear about the issue. This change currently defaults the behavior to "allow" which does nothing with these URLs. We can consider changing this behavior to "warn" by default if we wish. At that time, we may want to add some advice about setting fetch.credentialsInUrl=ignore for users who still want to follow this pattern (and not receive the warning). An earlier version of this change injected the logic into url_normalize() in urlmatch.c. While most code paths that parse URLs eventually normalize the URL, that normalization does not happen early enough in the stack to avoid attempting connections to the URL first. By inserting a check into the remote validation, we identify the issue before making a connection. In the old code path, this was revealed by testing the new t5601-clone.sh test under --stress, resulting in an instance where the return code was 13 (SIGPIPE) instead of 128 from the die(). However, we can reuse the parsing information from url_normalize() in order to benefit from its well-worn parsing logic. We can use the struct url_info that is created in that method to replace the password with "<redacted>" in our error messages. This comes with a slight downside that the normalized URL might look slightly different from the input URL (for instance, the normalized version adds a closing slash). This should not hinder users figuring out what the problem is and being able to fix the issue. As an attempt to ensure the parsing logic did not catch any unintentional cases, I modified this change locally to to use the "die" option by default. Running the test suite succeeds except for the explicit username:password URLs used in t5550-http-fetch-dumb.sh and t5541-http-push-smart.sh. This means that all other tested URLs did not trigger this logic. The tests show that the proper error messages appear (or do not appear), but also count the number of error messages. When only warning, each process validates the remote URL and outputs a warning. This happens twice for clone, three times for fetch, and once for push. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>