Compare
4ee3b87aaaf3f35e840b3d6d1cff46cfbc419d07..ab902cf3aa76c3e654cb8b6bb7194e6e32197375
l10n: AGENTS.md: use JSON intermediates in workflow
Make/l10n compiles every po/*.po file. The AGENTS.md workflow keeps its intermediate files in po/, so any .po file written there can be picked up by a normal `make` run and cause build failures. Switch the workflow to use GETTEXT JSON for pending/input/review work files instead of PO, and rename the remaining PO scratch file to l10n-done.po.tmp so Make/l10n ignores it. This only affects the helper scripts documented in po/AGENTS.md. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> · 2026-09-17 09:45 UTC
37 files changed,
+672
−731
- .github/workflows/main.yml
- .mailmap
- Documentation/RelNotes/2.56.0.adoc
- Documentation/git-pack-refs.adoc
- Documentation/git-refs.adoc
- Documentation/pack-refs-options.adoc
- GIT-VERSION-GEN
- Makefile
- builtin/commit.c
- builtin/fsck.c
- builtin/history.c
- ci/lib.sh
- config.mak.uname
- dir.c
- odb.c
- odb.h
- odb/source-files.c
- odb/source-inmemory.c
- odb/source-loose.c
- odb/source-packed.c
- odb/source.h
- pack-bitmap.c
- pack-bitmap.h
- po/AGENTS.md
- sequencer.c
- sequencer.h
- src/cargo-meson.sh
- t/t1450-fsck.sh
- t/t3404-rebase-interactive.sh
- t/t3507-cherry-pick-conflict.sh
- t/t4151-am-abort.sh
- t/t5319-multi-pack-index.sh
- t/t5325-reverse-index.sh
- t/t5326-multi-pack-bitmaps.sh
- t/t6132-pathspec-exclude.sh
- t/unit-tests/u-dir.c
- wt-status.h
modified .github/workflows/main.yml
| @@ -116,6 +116,30 @@ jobs: | |||
| 116 | 116 | steps: | |
| 117 | 117 | - uses: actions/checkout@v6 | |
| 118 | 118 | - uses: git-for-windows/setup-git-for-windows-sdk@v2 | |
| 119 | + | - name: Install GCC-compatible Rust target | |
| 120 | + | shell: bash | |
| 121 | + | run: | | |
| 122 | + | # The hosted Windows runners ship a rustup-managed Rust whose | |
| 123 | + | # default toolchain targets the MSVC ABI. That produces a | |
| 124 | + | # `gitcore.lib` which the MinGW GCC used by the rest of the | |
| 125 | + | # build cannot link. Install the precompiled `std` for a | |
| 126 | + | # GCC-compatible target triple matching the MSYS2 subsystem; | |
| 127 | + | # the Makefile selects the same triple via $(MSYSTEM) and | |
| 128 | + | # passes it to `cargo build --target`. | |
| 129 | + | case "$MSYSTEM" in | |
| 130 | + | CLANGARM64) target=aarch64-pc-windows-gnullvm ;; | |
| 131 | + | CLANG64) target=x86_64-pc-windows-gnullvm ;; | |
| 132 | + | CLANG32) target=i686-pc-windows-gnullvm ;; | |
| 133 | + | UCRT64) target=x86_64-pc-windows-gnu ;; | |
| 134 | + | MINGW64) target=x86_64-pc-windows-gnu ;; | |
| 135 | + | MINGW32) target=i686-pc-windows-gnu ;; | |
| 136 | + | *) echo "::error::Unsupported MSYSTEM: $MSYSTEM"; exit 1 ;; | |
| 137 | + | esac && | |
| 138 | + | rustup target add "$target" && | |
| 139 | + | ||
| 140 | + | # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH | |
| 141 | + | CARGO="$(type -p cargo.exe)" && | |
| 142 | + | echo "export PATH=\$PATH:${CARGO%/cargo.exe}" >>/etc/profile | |
| 119 | 143 | - name: build | |
| 120 | 144 | shell: bash | |
| 121 | 145 | env: | |
modified .mailmap
| @@ -312,6 +312,7 @@ YONETANI Tomokazu <y0n3t4n1@gmail.com> <qhwt+git@les.ath.cx> | |||
| 312 | 312 | YONETANI Tomokazu <y0n3t4n1@gmail.com> <y0netan1@dragonflybsd.org> | |
| 313 | 313 | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | |
| 314 | 314 | Yi-Jyun Pan <pan93412@gmail.com> | |
| 315 | + | Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> | |
| 315 | 316 | # the two anonymous contributors are different persons: | |
| 316 | 317 | anonymous <linux@horizon.com> | |
| 317 | 318 | anonymous <linux@horizon.net> | |
modified Documentation/RelNotes/2.56.0.adoc
| @@ -546,6 +546,25 @@ Performance, Internal Implementation, Development Support etc. | |||
| 546 | 546 | interfered with "git rebase" etc. too much. The conditions "rerere | |
| 547 | 547 | gc" gets triggered have been tweaked. | |
| 548 | 548 | ||
| 549 | + | * Windows build switches from MINGW64 to URCR64 runtime starting Git | |
| 550 | + | 2.56.0; switch the cmake based build at the same time. | |
| 551 | + | ||
| 552 | + | * The mechanism to register in-memory alternate object sources has | |
| 553 | + | been removed, as submodule object databases are now accessed | |
| 554 | + | natively via their own repository structures. This simplifies | |
| 555 | + | object database management and prepares the codebase for migrating | |
| 556 | + | alternate tracking into the files backend. | |
| 557 | + | ||
| 558 | + | * The consistency checks for the object database (fsck) have been | |
| 559 | + | decoupled from the generic builtin implementation and moved into the | |
| 560 | + | backend-specific object source layers, making them pluggable for | |
| 561 | + | different object storage formats. | |
| 562 | + | ||
| 563 | + | * When cross-compiling with Cargo, the output artifact is placed in a | |
| 564 | + | target-specific subdirectory, which causes the build system to fail | |
| 565 | + | to locate it. The build system has been updated to respect the | |
| 566 | + | 'CARGO_BUILD_TARGET' environment variable. | |
| 567 | + | ||
| 549 | 568 | ||
| 550 | 569 | Fixes since v2.55 | |
| 551 | 570 | ----------------- | |
| @@ -848,12 +867,6 @@ Fixes since v2.55 | |||
| 848 | 867 | Additionally, an obsolete variable used for retired Azure Pipelines | |
| 849 | 868 | environments has been removed. | |
| 850 | 869 | ||
| 851 | - | * Teach 'am', 'revert', and 'rebase' that running 'commit --amend' or a | |
| 852 | - | partial 'commit <paths>' makes no sense during operations that stop | |
| 853 | - | and return control to the user to resolve conflicts left in the | |
| 854 | - | working tree, just like 'cherry-pick' and 'merge' do. | |
| 855 | - | (merge cc499d40e5 en/no-amend-during-conflicts later to maint). | |
| 856 | - | ||
| 857 | 870 | * The error path in 'git submodule--helper' has been updated to plug a | |
| 858 | 871 | memory leak when a repository handle could not be obtained, | |
| 859 | 872 | leveraging an updated idempotent repo_clear(). | |
| @@ -869,7 +882,8 @@ Fixes since v2.55 | |||
| 869 | 882 | (merge ec602484bd kh/doc-datamodel later to maint). | |
| 870 | 883 | ||
| 871 | 884 | * Running "git history" in a corrupt repository can (unsurprisingly) | |
| 872 | - | segfault when a necessary tree object is not found. | |
| 885 | + | segfault when a necessary tree object is not found, which has been | |
| 886 | + | made to die more gracefully. | |
| 873 | 887 | (merge 76621488e8 jc/history-missing-tree-errorfix later to maint). | |
| 874 | 888 | ||
| 875 | 889 | * The development helper script to lint gitlink references in the | |
| @@ -883,6 +897,14 @@ Fixes since v2.55 | |||
| 883 | 897 | branch-switch message. | |
| 884 | 898 | (merge 2ba77ea828 hn/checkout-m-autostash-refine later to maint). | |
| 885 | 899 | ||
| 900 | + | * The memory leak caused by not unusing the commit buffer returned by | |
| 901 | + | repo_logmsg_reencode() during the rewording operation in 'git | |
| 902 | + | history' has been plugged. | |
| 903 | + | ||
| 904 | + | * The pathspec matching logic has been updated to avoid out-of-bounds | |
| 905 | + | memory accesses when a negative pathspec is shorter than the common | |
| 906 | + | prefix of positive pathspecs. | |
| 907 | + | ||
| 886 | 908 | * Other code cleanup, docfix, build fix, etc. | |
| 887 | 909 | (merge 026636128f ss/submittingpatches-typofix later to maint). | |
| 888 | 910 | (merge d2af22cc21 jc/rerere-doc-typofix later to maint). | |
modified Documentation/git-pack-refs.adoc
| @@ -7,8 +7,8 @@ git-pack-refs - Pack heads and tags for efficient repository access | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git pack-refs' [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 10 | + | [synopsis] | |
| 11 | + | git pack-refs [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 12 | 12 | ||
| 13 | 13 | DESCRIPTION | |
| 14 | 14 | ----------- | |
| @@ -52,8 +52,8 @@ BUGS | |||
| 52 | 52 | ---- | |
| 53 | 53 | ||
| 54 | 54 | Older documentation written before the packed-refs mechanism was | |
| 55 | - | introduced may still say things like ".git/refs/heads/<branch> file | |
| 56 | - | exists" when it means "branch <branch> exists". | |
| 55 | + | introduced may still say things like ".git/refs/heads/_<branch>_ file | |
| 56 | + | exists" when it means "branch _<branch>_ exists". | |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | 59 | GIT | |
modified Documentation/git-refs.adoc
| @@ -54,40 +54,40 @@ These limitations may eventually be lifted. | |||
| 54 | 54 | `verify`:: | |
| 55 | 55 | Verify reference database consistency. | |
| 56 | 56 | ||
| 57 | - | list:: | |
| 57 | + | `list`:: | |
| 58 | 58 | List references in the repository with support for filtering, | |
| 59 | 59 | formatting, and sorting. This subcommand is an alias for | |
| 60 | 60 | linkgit:git-for-each-ref[1] and offers identical functionality. | |
| 61 | 61 | ||
| 62 | - | exists:: | |
| 62 | + | `exists`:: | |
| 63 | 63 | Check whether the given reference exists. Returns an exit code of 0 if | |
| 64 | 64 | it does, 2 if it is missing, and 1 in case looking up the reference | |
| 65 | 65 | failed with an error other than the reference being missing. This does | |
| 66 | 66 | not verify whether the reference resolves to an actual object. | |
| 67 | 67 | ||
| 68 | - | optimize:: | |
| 68 | + | `optimize`:: | |
| 69 | 69 | Optimizes references to improve repository performance and reduce disk | |
| 70 | 70 | usage. This subcommand is an alias for linkgit:git-pack-refs[1] and | |
| 71 | 71 | offers identical functionality. | |
| 72 | 72 | ||
| 73 | - | create:: | |
| 73 | + | `create`:: | |
| 74 | 74 | Create the given reference, which must not already exist, pointing at | |
| 75 | 75 | `<new-value>`. | |
| 76 | 76 | ||
| 77 | - | delete:: | |
| 77 | + | `delete`:: | |
| 78 | 78 | Delete the given reference. This subcommand mirrors `git update-ref -d` | |
| 79 | 79 | (see linkgit:git-update-ref[1]). When `<old-value>` is given, the | |
| 80 | 80 | reference is only deleted after verifying that it currently contains | |
| 81 | 81 | `<old-value>`. | |
| 82 | 82 | ||
| 83 | - | update:: | |
| 83 | + | `update`:: | |
| 84 | 84 | Update the given reference to point at `<new-value>`. If `<old-value>` | |
| 85 | 85 | is given, the reference is only updated after verifying that it | |
| 86 | 86 | currently contains `<old-value>`. As a special case, an all-zeroes | |
| 87 | 87 | `<new-value>` deletes the branch, whereas an all-zeroes `<old-value>` | |
| 88 | 88 | ensures that the branch does not yet exist. | |
| 89 | 89 | ||
| 90 | - | rename:: | |
| 90 | + | `rename`:: | |
| 91 | 91 | Rename the reference `<oldref>` to `<newref>`. The old reference must | |
| 92 | 92 | exist and the new reference must not yet exist, and both must have a | |
| 93 | 93 | well-formed name (see linkgit:git-check-ref-format[1]). | |
modified Documentation/pack-refs-options.adoc
| @@ -1,4 +1,4 @@ | |||
| 1 | - | --all:: | |
| 1 | + | `--all`:: | |
| 2 | 2 | ||
| 3 | 3 | The command by default packs all tags and refs that are already | |
| 4 | 4 | packed, and leaves other refs | |
| @@ -8,12 +8,12 @@ This option causes all refs to be packed as well, with the exception | |||
| 8 | 8 | of hidden refs, broken refs, and symbolic refs. Useful for a repository | |
| 9 | 9 | with many branches of historical interests. | |
| 10 | 10 | ||
| 11 | - | --no-prune:: | |
| 11 | + | `--no-prune`:: | |
| 12 | 12 | ||
| 13 | 13 | The command usually removes loose refs under `$GIT_DIR/refs` | |
| 14 | 14 | hierarchy after packing them. This option tells it not to. | |
| 15 | 15 | ||
| 16 | - | --auto:: | |
| 16 | + | `--auto`:: | |
| 17 | 17 | ||
| 18 | 18 | Pack refs as needed depending on the current state of the ref database. The | |
| 19 | 19 | behavior depends on the ref format used by the repository and may change in the | |
| @@ -29,7 +29,7 @@ future. | |||
| 29 | 29 | maintains the property that N is at least twice as big as N+1. Only | |
| 30 | 30 | tables that violate this property are compacted. | |
| 31 | 31 | ||
| 32 | - | --include <pattern>:: | |
| 32 | + | `--include <pattern>`:: | |
| 33 | 33 | ||
| 34 | 34 | Pack refs based on a `glob(7)` pattern. Repetitions of this option | |
| 35 | 35 | accumulate inclusion patterns. If a ref is both included in `--include` and | |
| @@ -38,7 +38,7 @@ tags from being included by default. Symbolic refs and broken refs will never | |||
| 38 | 38 | be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear | |
| 39 | 39 | and reset the list of patterns. | |
| 40 | 40 | ||
| 41 | - | --exclude <pattern>:: | |
| 41 | + | `--exclude <pattern>`:: | |
| 42 | 42 | ||
| 43 | 43 | Do not pack refs matching the given `glob(7)` pattern. Repetitions of this option | |
| 44 | 44 | accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of | |
modified GIT-VERSION-GEN
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | - | DEF_VER=v2.56.0-rc0 | |
| 3 | + | DEF_VER=v2.56.0-rc2 | |
| 4 | 4 | ||
| 5 | 5 | LF=' | |
| 6 | 6 | ' | |
modified Makefile
| @@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib | |||
| 959 | 959 | else | |
| 960 | 960 | RUST_LIB_NAME = libgitcore.a | |
| 961 | 961 | endif | |
| 962 | - | RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME) | |
| 962 | + | RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME) | |
| 963 | 963 | endif | |
| 964 | 964 | ||
| 965 | 965 | GITLIBS = common-main.o $(LIB_FILE) | |
modified builtin/commit.c
| @@ -515,25 +515,13 @@ static const char *prepare_index(const char **argv, const char *prefix, | |||
| 515 | 515 | */ | |
| 516 | 516 | commit_style = COMMIT_PARTIAL; | |
| 517 | 517 | ||
| 518 | - | switch (sequencer_ongoing_operation(the_repository, whence)) { | |
| 519 | - | case ONGOING_NONE: | |
| 520 | - | break; | |
| 521 | - | case ONGOING_MERGE: | |
| 522 | - | die(_("cannot do a partial commit during a merge.")); | |
| 523 | - | case ONGOING_CHERRY_PICK: | |
| 524 | - | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 525 | - | case ONGOING_REBASE_NOW_EMPTY: | |
| 526 | - | /* | |
| 527 | - | * A pick that became empty is not a conflict, and creating | |
| 528 | - | * a new commit (partial or not) poses no problem. | |
| 529 | - | */ | |
| 530 | - | break; | |
| 531 | - | case ONGOING_REVERT: | |
| 532 | - | die(_("cannot do a partial commit during a revert.")); | |
| 533 | - | case ONGOING_AM: | |
| 534 | - | die(_("cannot do a partial commit during an am session.")); | |
| 535 | - | case ONGOING_REBASE_CONFLICT: | |
| 536 | - | die(_("cannot do a partial commit while resolving conflicts during a rebase.")); | |
| 518 | + | if (whence != FROM_COMMIT) { | |
| 519 | + | if (whence == FROM_MERGE) | |
| 520 | + | die(_("cannot do a partial commit during a merge.")); | |
| 521 | + | else if (is_from_cherry_pick(whence)) | |
| 522 | + | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 523 | + | else if (is_from_rebase(whence)) | |
| 524 | + | die(_("cannot do a partial commit during a rebase.")); | |
| 537 | 525 | } | |
| 538 | 526 | ||
| 539 | 527 | if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec)) | |
| @@ -905,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 905 | 893 | */ | |
| 906 | 894 | else if (whence == FROM_MERGE) | |
| 907 | 895 | hook_arg1 = "merge"; | |
| 908 | - | else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) { | |
| 896 | + | else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { | |
| 909 | 897 | hook_arg1 = "commit"; | |
| 910 | 898 | hook_arg2 = "CHERRY_PICK_HEAD"; | |
| 911 | 899 | } | |
| @@ -1098,7 +1086,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 1098 | 1086 | if (amend) | |
| 1099 | 1087 | fputs(_(empty_amend_advice), stderr); | |
| 1100 | 1088 | else if (is_from_cherry_pick(whence) || | |
| 1101 | - | is_from_rebase_now_empty(whence)) { | |
| 1089 | + | whence == FROM_REBASE_PICK) { | |
| 1102 | 1090 | fputs(_(empty_cherry_pick_advice), stderr); | |
| 1103 | 1091 | if (whence == FROM_CHERRY_PICK_SINGLE) | |
| 1104 | 1092 | fputs(_(empty_cherry_pick_advice_single), stderr); | |
| @@ -1338,30 +1326,15 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1338 | 1326 | use_editor = 0; | |
| 1339 | 1327 | ||
| 1340 | 1328 | /* Sanity check options */ | |
| 1341 | - | if (amend) { | |
| 1342 | - | if (!current_head) | |
| 1343 | - | die(_("You have nothing to amend.")); | |
| 1344 | - | /* | |
| 1345 | - | * Refuse to amend in the middle of any operation that is | |
| 1346 | - | * meant to record its result as a new commit on top of HEAD | |
| 1347 | - | * rather than by rewriting HEAD. | |
| 1348 | - | */ | |
| 1349 | - | switch (sequencer_ongoing_operation(s->repo, whence)) { | |
| 1350 | - | case ONGOING_NONE: | |
| 1351 | - | break; | |
| 1352 | - | case ONGOING_MERGE: | |
| 1329 | + | if (amend && !current_head) | |
| 1330 | + | die(_("You have nothing to amend.")); | |
| 1331 | + | if (amend && whence != FROM_COMMIT) { | |
| 1332 | + | if (whence == FROM_MERGE) | |
| 1353 | 1333 | die(_("You are in the middle of a merge -- cannot amend.")); | |
| 1354 | - | case ONGOING_CHERRY_PICK: | |
| 1334 | + | else if (is_from_cherry_pick(whence)) | |
| 1355 | 1335 | die(_("You are in the middle of a cherry-pick -- cannot amend.")); | |
| 1356 | - | case ONGOING_REBASE_NOW_EMPTY: | |
| 1357 | - | die(_("The now-empty commit has been dropped -- cannot amend.")); | |
| 1358 | - | case ONGOING_REVERT: | |
| 1359 | - | die(_("You are in the middle of a revert -- cannot amend.")); | |
| 1360 | - | case ONGOING_AM: | |
| 1361 | - | die(_("You are in the middle of an am session -- cannot amend.")); | |
| 1362 | - | case ONGOING_REBASE_CONFLICT: | |
| 1363 | - | die(_("You are resolving conflicts during a rebase -- cannot amend.")); | |
| 1364 | - | } | |
| 1336 | + | else if (whence == FROM_REBASE_PICK) | |
| 1337 | + | die(_("You are in the middle of a rebase -- cannot amend.")); | |
| 1365 | 1338 | } | |
| 1366 | 1339 | if (fixup_message && squash_message) | |
| 1367 | 1340 | die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup"); | |
| @@ -1380,7 +1353,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1380 | 1353 | if (amend && !use_message && !fixup_message) | |
| 1381 | 1354 | use_message = "HEAD"; | |
| 1382 | 1355 | if (!use_message && !is_from_cherry_pick(whence) && | |
| 1383 | - | !is_from_rebase_now_empty(whence) && renew_authorship) | |
| 1356 | + | !is_from_rebase(whence) && renew_authorship) | |
| 1384 | 1357 | die(_("--reset-author can be used only with -C, -c or --amend.")); | |
| 1385 | 1358 | if (use_message) { | |
| 1386 | 1359 | use_message_buffer = read_commit_message(use_message); | |
| @@ -1389,7 +1362,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1389 | 1362 | author_message_buffer = use_message_buffer; | |
| 1390 | 1363 | } | |
| 1391 | 1364 | } | |
| 1392 | - | if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) && | |
| 1365 | + | if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) && | |
| 1393 | 1366 | !renew_authorship) { | |
| 1394 | 1367 | author_message = "CHERRY_PICK_HEAD"; | |
| 1395 | 1368 | author_message_buffer = read_commit_message(author_message); | |
| @@ -1914,7 +1887,7 @@ int cmd_commit(int argc, | |||
| 1914 | 1887 | if (!reflog_msg) | |
| 1915 | 1888 | reflog_msg = is_from_cherry_pick(whence) | |
| 1916 | 1889 | ? "commit (cherry-pick)" | |
| 1917 | - | : is_from_rebase_now_empty(whence) | |
| 1890 | + | : is_from_rebase(whence) | |
| 1918 | 1891 | ? "commit (rebase)" | |
| 1919 | 1892 | : "commit"; | |
| 1920 | 1893 | commit_list_insert(current_head, &parents); | |
modified builtin/fsck.c
| @@ -7,13 +7,11 @@ | |||
| 7 | 7 | #include "blob.h" | |
| 8 | 8 | #include "tag.h" | |
| 9 | 9 | #include "refs.h" | |
| 10 | - | #include "pack.h" | |
| 11 | 10 | #include "cache-tree.h" | |
| 12 | 11 | #include "fsck.h" | |
| 13 | 12 | #include "parse-options.h" | |
| 14 | 13 | #include "progress.h" | |
| 15 | 14 | #include "packfile.h" | |
| 16 | - | #include "object-file.h" | |
| 17 | 15 | #include "object-name.h" | |
| 18 | 16 | #include "odb.h" | |
| 19 | 17 | #include "odb/streaming.h" | |
| @@ -24,8 +22,6 @@ | |||
| 24 | 22 | #include "run-command.h" | |
| 25 | 23 | #include "sparse-index.h" | |
| 26 | 24 | #include "worktree.h" | |
| 27 | - | #include "pack-revindex.h" | |
| 28 | - | #include "pack-bitmap.h" | |
| 29 | 25 | ||
| 30 | 26 | #define REACHABLE 0x0001 | |
| 31 | 27 | #define SEEN 0x0002 | |
| @@ -37,10 +33,8 @@ static int show_root; | |||
| 37 | 33 | static int show_tags; | |
| 38 | 34 | static int show_unreachable; | |
| 39 | 35 | static int include_reflogs = 1; | |
| 40 | - | static int check_full = 1; | |
| 41 | 36 | static int connectivity_only; | |
| 42 | 37 | static int check_strict; | |
| 43 | - | static int keep_cache_objects; | |
| 44 | 38 | static struct fsck_options fsck_walk_options; | |
| 45 | 39 | static struct fsck_options fsck_obj_options; | |
| 46 | 40 | static int errors_found; | |
| @@ -48,17 +42,11 @@ static int write_lost_and_found; | |||
| 48 | 42 | static int verbose; | |
| 49 | 43 | static int show_progress = -1; | |
| 50 | 44 | static int show_dangling = 1; | |
| 51 | - | static int name_objects; | |
| 52 | - | static int check_references = 1; | |
| 53 | 45 | static timestamp_t now; | |
| 54 | 46 | #define ERROR_OBJECT 01 | |
| 55 | 47 | #define ERROR_REACHABLE 02 | |
| 56 | - | #define ERROR_PACK 04 | |
| 57 | 48 | #define ERROR_REFS 010 | |
| 58 | 49 | #define ERROR_COMMIT_GRAPH 020 | |
| 59 | - | #define ERROR_MULTI_PACK_INDEX 040 | |
| 60 | - | #define ERROR_PACK_REV_INDEX 0100 | |
| 61 | - | #define ERROR_BITMAP 0200 | |
| 62 | 50 | ||
| 63 | 51 | static const char *describe_object(const struct object_id *oid) | |
| 64 | 52 | { | |
| @@ -401,14 +389,27 @@ static void check_connectivity(struct repository *repo) | |||
| 401 | 389 | } | |
| 402 | 390 | } | |
| 403 | 391 | ||
| 404 | - | static int fsck_obj(struct repository *repo, | |
| 405 | - | struct object *obj, void *buffer, unsigned long size) | |
| 392 | + | static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, | |
| 393 | + | unsigned long size, void *buffer, int *eaten, void *cb_data) | |
| 406 | 394 | { | |
| 395 | + | struct repository *repo = cb_data; | |
| 396 | + | struct object *obj; | |
| 407 | 397 | int err; | |
| 408 | 398 | ||
| 409 | - | if (obj->flags & SEEN) | |
| 410 | - | return 0; | |
| 411 | - | obj->flags |= SEEN; | |
| 399 | + | /* | |
| 400 | + | * Note, buffer may be NULL if type is OBJ_BLOB. See | |
| 401 | + | * verify_packfile(), data_valid variable for details. | |
| 402 | + | */ | |
| 403 | + | obj = parse_object_buffer(repo, oid, type, size, buffer, eaten); | |
| 404 | + | if (!obj) { | |
| 405 | + | errors_found |= ERROR_OBJECT; | |
| 406 | + | err = error(_("%s: object corrupt or missing"), | |
| 407 | + | oid_to_hex(oid)); | |
| 408 | + | goto out; | |
| 409 | + | } | |
| 410 | + | ||
| 411 | + | obj->flags &= ~REACHABLE; | |
| 412 | + | obj->flags |= HAS_OBJ | SEEN; | |
| 412 | 413 | ||
| 413 | 414 | if (verbose) | |
| 414 | 415 | fprintf_ln(stderr, _("Checking %s %s"), | |
| @@ -417,6 +418,7 @@ static int fsck_obj(struct repository *repo, | |||
| 417 | 418 | ||
| 418 | 419 | if (fsck_walk(obj, NULL, &fsck_obj_options)) | |
| 419 | 420 | objerror(repo, obj, _("broken links")); | |
| 421 | + | ||
| 420 | 422 | err = fsck_object(obj, buffer, size, &fsck_obj_options); | |
| 421 | 423 | if (err) | |
| 422 | 424 | goto out; | |
| @@ -442,32 +444,11 @@ static int fsck_obj(struct repository *repo, | |||
| 442 | 444 | } | |
| 443 | 445 | ||
| 444 | 446 | out: | |
| 445 | - | if (obj->type == OBJ_TREE) | |
| 447 | + | if (obj && obj->type == OBJ_TREE) | |
| 446 | 448 | free_tree_buffer((struct tree *)obj); | |
| 447 | 449 | return err; | |
| 448 | 450 | } | |
| 449 | 451 | ||
| 450 | - | static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, | |
| 451 | - | unsigned long size, void *buffer, int *eaten, void *cb_data) | |
| 452 | - | { | |
| 453 | - | struct repository *repo = cb_data; | |
| 454 | - | struct object *obj; | |
| 455 | - | ||
| 456 | - | /* | |
| 457 | - | * Note, buffer may be NULL if type is OBJ_BLOB. See | |
| 458 | - | * verify_packfile(), data_valid variable for details. | |
| 459 | - | */ | |
| 460 | - | obj = parse_object_buffer(repo, oid, type, size, buffer, eaten); | |
| 461 | - | if (!obj) { | |
| 462 | - | errors_found |= ERROR_OBJECT; | |
| 463 | - | return error(_("%s: object corrupt or missing"), | |
| 464 | - | oid_to_hex(oid)); | |
| 465 | - | } | |
| 466 | - | obj->flags &= ~(REACHABLE | SEEN); | |
| 467 | - | obj->flags |= HAS_OBJ; | |
| 468 | - | return fsck_obj(repo, obj, buffer, size); | |
| 469 | - | } | |
| 470 | - | ||
| 471 | 452 | static int default_refs; | |
| 472 | 453 | ||
| 473 | 454 | static void fsck_handle_reflog_oid(struct repository *repo, | |
| @@ -713,103 +694,6 @@ static void process_refs(struct repository *repo, struct snapshot *snap) | |||
| 713 | 694 | } | |
| 714 | 695 | } | |
| 715 | 696 | ||
| 716 | - | struct for_each_loose_cb { | |
| 717 | - | struct repository *repo; | |
| 718 | - | struct progress *progress; | |
| 719 | - | }; | |
| 720 | - | ||
| 721 | - | static int fsck_loose(const struct object_id *oid, const char *path, | |
| 722 | - | void *cb_data) | |
| 723 | - | { | |
| 724 | - | struct for_each_loose_cb *data = cb_data; | |
| 725 | - | struct object *obj; | |
| 726 | - | enum object_type type = OBJ_NONE; | |
| 727 | - | size_t size; | |
| 728 | - | void *contents = NULL; | |
| 729 | - | int eaten; | |
| 730 | - | struct object_info oi = OBJECT_INFO_INIT; | |
| 731 | - | struct object_id real_oid = *null_oid(data->repo->hash_algo); | |
| 732 | - | int err = 0; | |
| 733 | - | ||
| 734 | - | oi.sizep = &size; | |
| 735 | - | oi.typep = &type; | |
| 736 | - | ||
| 737 | - | if (read_loose_object(data->repo, path, oid, &real_oid, &contents, &oi) < 0) { | |
| 738 | - | if (contents && !oideq(&real_oid, oid)) | |
| 739 | - | err = error(_("%s: hash-path mismatch, found at: %s"), | |
| 740 | - | oid_to_hex(&real_oid), path); | |
| 741 | - | else | |
| 742 | - | err = error(_("%s: object corrupt or missing: %s"), | |
| 743 | - | oid_to_hex(oid), path); | |
| 744 | - | } | |
| 745 | - | if (err < 0) { | |
| 746 | - | errors_found |= ERROR_OBJECT; | |
| 747 | - | free(contents); | |
| 748 | - | return 0; /* keep checking other objects */ | |
| 749 | - | } | |
| 750 | - | ||
| 751 | - | if (!contents && type != OBJ_BLOB) | |
| 752 | - | BUG("read_loose_object streamed a non-blob"); | |
| 753 | - | ||
| 754 | - | obj = parse_object_buffer(data->repo, oid, type, size, | |
| 755 | - | contents, &eaten); | |
| 756 | - | ||
| 757 | - | if (!obj) { | |
| 758 | - | errors_found |= ERROR_OBJECT; | |
| 759 | - | error(_("%s: object could not be parsed: %s"), | |
| 760 | - | oid_to_hex(oid), path); | |
| 761 | - | if (!eaten) | |
| 762 | - | free(contents); | |
| 763 | - | return 0; /* keep checking other objects */ | |
| 764 | - | } | |
| 765 | - | ||
| 766 | - | obj->flags &= ~(REACHABLE | SEEN); | |
| 767 | - | obj->flags |= HAS_OBJ; | |
| 768 | - | if (fsck_obj(data->repo, obj, contents, size)) | |
| 769 | - | errors_found |= ERROR_OBJECT; | |
| 770 | - | ||
| 771 | - | if (!eaten) | |
| 772 | - | free(contents); | |
| 773 | - | return 0; /* keep checking other objects, even if we saw an error */ | |
| 774 | - | } | |
| 775 | - | ||
| 776 | - | static int fsck_cruft(const char *basename, const char *path, | |
| 777 | - | void *data UNUSED) | |
| 778 | - | { | |
| 779 | - | if (!starts_with(basename, "tmp_obj_")) | |
| 780 | - | fprintf_ln(stderr, _("bad sha1 file: %s"), path); | |
| 781 | - | return 0; | |
| 782 | - | } | |
| 783 | - | ||
| 784 | - | static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *data) | |
| 785 | - | { | |
| 786 | - | struct for_each_loose_cb *cb_data = data; | |
| 787 | - | struct progress *progress = cb_data->progress; | |
| 788 | - | display_progress(progress, nr + 1); | |
| 789 | - | return 0; | |
| 790 | - | } | |
| 791 | - | ||
| 792 | - | static void fsck_source(struct repository *repo, struct odb_source *source) | |
| 793 | - | { | |
| 794 | - | struct progress *progress = NULL; | |
| 795 | - | struct for_each_loose_cb cb_data = { | |
| 796 | - | .repo = source->odb->repo, | |
| 797 | - | .progress = progress, | |
| 798 | - | }; | |
| 799 | - | ||
| 800 | - | if (verbose) | |
| 801 | - | fprintf_ln(stderr, _("Checking object directory")); | |
| 802 | - | ||
| 803 | - | if (show_progress) | |
| 804 | - | progress = start_progress(repo, | |
| 805 | - | _("Checking object directories"), 256); | |
| 806 | - | ||
| 807 | - | for_each_loose_file_in_source(source, fsck_loose, | |
| 808 | - | fsck_cruft, fsck_subdir, &cb_data); | |
| 809 | - | display_progress(progress, 256); | |
| 810 | - | stop_progress(&progress); | |
| 811 | - | } | |
| 812 | - | ||
| 813 | 697 | static int fsck_cache_tree(struct repository *repo, struct cache_tree *it, const char *index_path) | |
| 814 | 698 | { | |
| 815 | 699 | int i; | |
| @@ -918,40 +802,6 @@ static int mark_object_for_connectivity(const struct object_id *oid, | |||
| 918 | 802 | return 0; | |
| 919 | 803 | } | |
| 920 | 804 | ||
| 921 | - | static int check_pack_rev_indexes(struct repository *r, int show_progress) | |
| 922 | - | { | |
| 923 | - | struct progress *progress = NULL; | |
| 924 | - | struct packed_git *p; | |
| 925 | - | uint32_t pack_count = 0; | |
| 926 | - | int res = 0; | |
| 927 | - | ||
| 928 | - | if (show_progress) { | |
| 929 | - | repo_for_each_pack(r, p) | |
| 930 | - | pack_count++; | |
| 931 | - | progress = start_delayed_progress(r, | |
| 932 | - | "Verifying reverse pack-indexes", pack_count); | |
| 933 | - | pack_count = 0; | |
| 934 | - | } | |
| 935 | - | ||
| 936 | - | repo_for_each_pack(r, p) { | |
| 937 | - | int load_error = load_pack_revindex_from_disk(p); | |
| 938 | - | ||
| 939 | - | if (load_error < 0) { | |
| 940 | - | error(_("unable to load rev-index for pack '%s'"), p->pack_name); | |
| 941 | - | res = ERROR_PACK_REV_INDEX; | |
| 942 | - | } else if (!load_error && | |
| 943 | - | !load_pack_revindex(r, p) && | |
| 944 | - | verify_pack_revindex(p)) { | |
| 945 | - | error(_("invalid rev-index for pack '%s'"), p->pack_name); | |
| 946 | - | res = ERROR_PACK_REV_INDEX; | |
| 947 | - | } | |
| 948 | - | display_progress(progress, ++pack_count); | |
| 949 | - | } | |
| 950 | - | stop_progress(&progress); | |
| 951 | - | ||
| 952 | - | return res; | |
| 953 | - | } | |
| 954 | - | ||
| 955 | 805 | static void fsck_refs(struct repository *r) | |
| 956 | 806 | { | |
| 957 | 807 | struct child_process refs_verify = CHILD_PROCESS_INIT; | |
| @@ -986,30 +836,38 @@ static char const * const fsck_usage[] = { | |||
| 986 | 836 | NULL | |
| 987 | 837 | }; | |
| 988 | 838 | ||
| 989 | - | static struct option fsck_opts[] = { | |
| 990 | - | OPT__VERBOSE(&verbose, N_("be verbose")), | |
| 991 | - | OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")), | |
| 992 | - | OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")), | |
| 993 | - | OPT_BOOL(0, "tags", &show_tags, N_("report tags")), | |
| 994 | - | OPT_BOOL(0, "root", &show_root, N_("report root nodes")), | |
| 995 | - | OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")), | |
| 996 | - | OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")), | |
| 997 | - | OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")), | |
| 998 | - | OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")), | |
| 999 | - | OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")), | |
| 1000 | - | OPT_BOOL(0, "lost-found", &write_lost_and_found, | |
| 1001 | - | N_("write dangling objects in .git/lost-found")), | |
| 1002 | - | OPT_BOOL(0, "progress", &show_progress, N_("show progress")), | |
| 1003 | - | OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")), | |
| 1004 | - | OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")), | |
| 1005 | - | OPT_END(), | |
| 1006 | - | }; | |
| 1007 | - | ||
| 1008 | 839 | int cmd_fsck(int argc, | |
| 1009 | 840 | const char **argv, | |
| 1010 | 841 | const char *prefix, | |
| 1011 | 842 | struct repository *repo) | |
| 1012 | 843 | { | |
| 844 | + | struct odb_fsck_options odb_fsck_opts = { | |
| 845 | + | .flags = ODB_FSCK_FULL, | |
| 846 | + | .object_cb = fsck_obj_buffer, | |
| 847 | + | .object_payload = repo, | |
| 848 | + | }; | |
| 849 | + | int keep_cache_objects = 0; | |
| 850 | + | int name_objects = 0; | |
| 851 | + | int check_references = 1; | |
| 852 | + | struct option fsck_opts[] = { | |
| 853 | + | OPT__VERBOSE(&verbose, N_("be verbose")), | |
| 854 | + | OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")), | |
| 855 | + | OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")), | |
| 856 | + | OPT_BOOL(0, "tags", &show_tags, N_("report tags")), | |
| 857 | + | OPT_BOOL(0, "root", &show_root, N_("report root nodes")), | |
| 858 | + | OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")), | |
| 859 | + | OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")), | |
| 860 | + | OPT_BIT(0, "full", &odb_fsck_opts.flags, | |
| 861 | + | N_("also consider packs and alternate objects"), ODB_FSCK_FULL), | |
| 862 | + | OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")), | |
| 863 | + | OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")), | |
| 864 | + | OPT_BOOL(0, "lost-found", &write_lost_and_found, | |
| 865 | + | N_("write dangling objects in .git/lost-found")), | |
| 866 | + | OPT_BOOL(0, "progress", &show_progress, N_("show progress")), | |
| 867 | + | OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")), | |
| 868 | + | OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")), | |
| 869 | + | OPT_END(), | |
| 870 | + | }; | |
| 1013 | 871 | struct odb_source *source; | |
| 1014 | 872 | struct snapshot snap = { | |
| 1015 | 873 | .nr = 0, | |
| @@ -1037,11 +895,15 @@ int cmd_fsck(int argc, | |||
| 1037 | 895 | ||
| 1038 | 896 | if (show_progress == -1) | |
| 1039 | 897 | show_progress = isatty(2); | |
| 1040 | - | if (verbose) | |
| 898 | + | if (verbose) { | |
| 1041 | 899 | show_progress = 0; | |
| 900 | + | odb_fsck_opts.flags |= ODB_FSCK_VERBOSE; | |
| 901 | + | } | |
| 902 | + | if (show_progress) | |
| 903 | + | odb_fsck_opts.flags |= ODB_FSCK_PROGRESS; | |
| 1042 | 904 | ||
| 1043 | 905 | if (write_lost_and_found) { | |
| 1044 | - | check_full = 1; | |
| 906 | + | odb_fsck_opts.flags |= ODB_FSCK_FULL; | |
| 1045 | 907 | include_reflogs = 0; | |
| 1046 | 908 | } | |
| 1047 | 909 | ||
| @@ -1069,35 +931,8 @@ int cmd_fsck(int argc, | |||
| 1069 | 931 | odb_for_each_object(repo->objects, NULL, | |
| 1070 | 932 | mark_object_for_connectivity, repo, 0); | |
| 1071 | 933 | } else { | |
| 1072 | - | for (source = repo->objects->sources; source; source = source->next) | |
| 1073 | - | fsck_source(repo, source); | |
| 1074 | - | ||
| 1075 | - | if (check_full) { | |
| 1076 | - | struct packed_git *p; | |
| 1077 | - | uint32_t total = 0, count = 0; | |
| 1078 | - | struct progress *progress = NULL; | |
| 1079 | - | ||
| 1080 | - | if (show_progress) { | |
| 1081 | - | repo_for_each_pack(repo, p) { | |
| 1082 | - | if (open_pack_index(p)) | |
| 1083 | - | continue; | |
| 1084 | - | total += p->num_objects; | |
| 1085 | - | } | |
| 1086 | - | ||
| 1087 | - | progress = start_progress(repo, | |
| 1088 | - | _("Checking objects"), total); | |
| 1089 | - | } | |
| 1090 | - | ||
| 1091 | - | repo_for_each_pack(repo, p) { | |
| 1092 | - | /* verify gives error messages itself */ | |
| 1093 | - | if (verify_pack(repo, | |
| 1094 | - | p, fsck_obj_buffer, repo, | |
| 1095 | - | progress, count)) | |
| 1096 | - | errors_found |= ERROR_PACK; | |
| 1097 | - | count += p->num_objects; | |
| 1098 | - | } | |
| 1099 | - | stop_progress(&progress); | |
| 1100 | - | } | |
| 934 | + | if (odb_fsck(repo->objects, &odb_fsck_opts) < 0) | |
| 935 | + | errors_found |= ERROR_OBJECT; | |
| 1101 | 936 | ||
| 1102 | 937 | if (fsck_finish(&fsck_obj_options)) | |
| 1103 | 938 | errors_found |= ERROR_OBJECT; | |
| @@ -1145,10 +980,6 @@ int cmd_fsck(int argc, | |||
| 1145 | 980 | free_worktrees(worktrees); | |
| 1146 | 981 | } | |
| 1147 | 982 | ||
| 1148 | - | errors_found |= check_pack_rev_indexes(repo, show_progress); | |
| 1149 | - | if (verify_bitmap_files(repo)) | |
| 1150 | - | errors_found |= ERROR_BITMAP; | |
| 1151 | - | ||
| 1152 | 983 | check_connectivity(repo); | |
| 1153 | 984 | ||
| 1154 | 985 | if (repo->settings.core_commit_graph) { | |
| @@ -1168,23 +999,6 @@ int cmd_fsck(int argc, | |||
| 1168 | 999 | } | |
| 1169 | 1000 | } | |
| 1170 | 1001 | ||
| 1171 | - | if (repo->settings.core_multi_pack_index) { | |
| 1172 | - | struct child_process midx_verify = CHILD_PROCESS_INIT; | |
| 1173 | - | ||
| 1174 | - | for (source = repo->objects->sources; source; source = source->next) { | |
| 1175 | - | child_process_init(&midx_verify); | |
| 1176 | - | midx_verify.git_cmd = 1; | |
| 1177 | - | strvec_pushl(&midx_verify.args, "multi-pack-index", | |
| 1178 | - | "verify", "--object-dir", source->path, NULL); | |
| 1179 | - | if (show_progress) | |
| 1180 | - | strvec_push(&midx_verify.args, "--progress"); | |
| 1181 | - | else | |
| 1182 | - | strvec_push(&midx_verify.args, "--no-progress"); | |
| 1183 | - | if (run_command(&midx_verify)) | |
| 1184 | - | errors_found |= ERROR_MULTI_PACK_INDEX; | |
| 1185 | - | } | |
| 1186 | - | } | |
| 1187 | - | ||
| 1188 | 1002 | free_snapshot_refs(&snap); | |
| 1189 | 1003 | return errors_found; | |
| 1190 | 1004 | } | |
modified builtin/history.c
| @@ -161,6 +161,7 @@ out: | |||
| 161 | 161 | free_commit_extra_headers(original_extra_headers); | |
| 162 | 162 | strbuf_release(&commit_message); | |
| 163 | 163 | free(original_author); | |
| 164 | + | repo_unuse_commit_buffer(repo, commit_with_message, original_message); | |
| 164 | 165 | return ret; | |
| 165 | 166 | } | |
| 166 | 167 | ||
modified ci/lib.sh
| @@ -391,9 +391,6 @@ linux-asan-ubsan) | |||
| 391 | 391 | osx-meson) | |
| 392 | 392 | MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain" | |
| 393 | 393 | ;; | |
| 394 | - | windows-*) | |
| 395 | - | export NO_RUST=UnfortunatelyYes | |
| 396 | - | ;; | |
| 397 | 394 | esac | |
| 398 | 395 | ||
| 399 | 396 | MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}" | |
modified config.mak.uname
| @@ -760,7 +760,30 @@ ifeq ($(uname_S),MINGW) | |||
| 760 | 760 | MINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z) | |
| 761 | 761 | endif | |
| 762 | 762 | prefix = $(MINGW_PREFIX) | |
| 763 | - | HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST)) | |
| 763 | + | ||
| 764 | + | # A rustup-managed Rust on Windows defaults to the MSVC ABI and | |
| 765 | + | # produces a `gitcore.lib` that the MinGW `ld.exe` cannot link. | |
| 766 | + | # Pick a GCC-compatible Rust target triple matching the MSYS2 | |
| 767 | + | # subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM | |
| 768 | + | # subsystems (which on Windows is also the only choice for | |
| 769 | + | # ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu` | |
| 770 | + | # for the MSVCRT-based MinGW subsystems. For a `staticlib` | |
| 771 | + | # crate-type Cargo does not invoke an external linker, so | |
| 772 | + | # `rustup target add <triple>` is sufficient. | |
| 773 | + | ifneq (,$(filter %ARM64, $(MSYSTEM))) | |
| 774 | + | HOST_CPU = aarch64 | |
| 775 | + | else ifneq (,$(filter %32, $(MSYSTEM))) | |
| 776 | + | HOST_CPU = i686 | |
| 777 | + | else | |
| 778 | + | HOST_CPU = x86_64 | |
| 779 | + | endif | |
| 780 | + | ifneq (,$(filter CLANG%, $(MSYSTEM))) | |
| 781 | + | CARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnullvm | |
| 782 | + | else | |
| 783 | + | CARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnu | |
| 784 | + | endif | |
| 785 | + | export CARGO_BUILD_TARGET | |
| 786 | + | ||
| 764 | 787 | BASIC_LDFLAGS += -Wl,--pic-executable | |
| 765 | 788 | COMPAT_CFLAGS += -DDETECT_MSYS_TTY \ | |
| 766 | 789 | -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" \ | |
modified dir.c
| @@ -212,9 +212,10 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen, | |||
| 212 | 212 | return match_status; | |
| 213 | 213 | } | |
| 214 | 214 | ||
| 215 | - | static size_t common_prefix_len(const struct pathspec *pathspec) | |
| 215 | + | static size_t common_prefix_len(const struct pathspec *pathspec, | |
| 216 | + | const char **matched_prefix) | |
| 216 | 217 | { | |
| 217 | - | int n; | |
| 218 | + | int n, first = -1; | |
| 218 | 219 | size_t max = 0; | |
| 219 | 220 | ||
| 220 | 221 | /* | |
| @@ -237,43 +238,47 @@ static size_t common_prefix_len(const struct pathspec *pathspec) | |||
| 237 | 238 | size_t i = 0, len = 0, item_len; | |
| 238 | 239 | if (pathspec->items[n].magic & PATHSPEC_EXCLUDE) | |
| 239 | 240 | continue; | |
| 241 | + | if (first < 0) | |
| 242 | + | first = n; | |
| 240 | 243 | if (pathspec->items[n].magic & PATHSPEC_ICASE) | |
| 241 | 244 | item_len = pathspec->items[n].prefix; | |
| 242 | 245 | else | |
| 243 | 246 | item_len = pathspec->items[n].nowildcard_len; | |
| 244 | - | while (i < item_len && (n == 0 || i < max)) { | |
| 247 | + | while (i < item_len && (n == first || i < max)) { | |
| 245 | 248 | char c = pathspec->items[n].match[i]; | |
| 246 | - | if (c != pathspec->items[0].match[i]) | |
| 249 | + | if (c != pathspec->items[first].match[i]) | |
| 247 | 250 | break; | |
| 248 | 251 | if (c == '/') | |
| 249 | 252 | len = i + 1; | |
| 250 | 253 | i++; | |
| 251 | 254 | } | |
| 252 | - | if (n == 0 || len < max) { | |
| 255 | + | if (n == first || len < max) { | |
| 253 | 256 | max = len; | |
| 254 | 257 | if (!max) | |
| 255 | 258 | break; | |
| 256 | 259 | } | |
| 257 | 260 | } | |
| 261 | + | *matched_prefix = first < 0 ? NULL : pathspec->items[first].match; | |
| 258 | 262 | return max; | |
| 259 | 263 | } | |
| 260 | 264 | ||
| 261 | 265 | /* | |
| 262 | - | * Returns a copy of the longest leading path common among all | |
| 263 | - | * pathspecs. | |
| 266 | + | * Returns a copy of the longest leading path common among all pathspec | |
| 267 | + | * items that are not excluded. | |
| 264 | 268 | */ | |
| 265 | 269 | char *common_prefix(const struct pathspec *pathspec) | |
| 266 | 270 | { | |
| 267 | - | unsigned long len = common_prefix_len(pathspec); | |
| 271 | + | const char *matched_prefix; | |
| 272 | + | size_t len = common_prefix_len(pathspec, &matched_prefix); | |
| 268 | 273 | ||
| 269 | - | return len ? xmemdupz(pathspec->items[0].match, len) : NULL; | |
| 274 | + | return len ? xmemdupz(matched_prefix, len) : NULL; | |
| 270 | 275 | } | |
| 271 | 276 | ||
| 272 | 277 | int fill_directory(struct dir_struct *dir, | |
| 273 | 278 | struct index_state *istate, | |
| 274 | 279 | const struct pathspec *pathspec) | |
| 275 | 280 | { | |
| 276 | - | const char *prefix; | |
| 281 | + | const char *matched_prefix; | |
| 277 | 282 | size_t prefix_len; | |
| 278 | 283 | ||
| 279 | 284 | unsigned exclusive_flags = DIR_SHOW_IGNORED | DIR_SHOW_IGNORED_TOO; | |
| @@ -284,11 +289,11 @@ int fill_directory(struct dir_struct *dir, | |||
| 284 | 289 | * Calculate common prefix for the pathspec, and | |
| 285 | 290 | * use that to optimize the directory walk | |
| 286 | 291 | */ | |
| 287 | - | prefix_len = common_prefix_len(pathspec); | |
| 288 | - | prefix = prefix_len ? pathspec->items[0].match : ""; | |
| 292 | + | prefix_len = common_prefix_len(pathspec, &matched_prefix); | |
| 289 | 293 | ||
| 290 | 294 | /* Read the directory and prune it */ | |
| 291 | - | read_directory(dir, istate, prefix, prefix_len, pathspec); | |
| 295 | + | read_directory(dir, istate, prefix_len ? matched_prefix : "", | |
| 296 | + | prefix_len, pathspec); | |
| 292 | 297 | ||
| 293 | 298 | return prefix_len; | |
| 294 | 299 | } | |
| @@ -394,7 +399,7 @@ static int match_pathspec_item(struct index_state *istate, | |||
| 394 | 399 | ||
| 395 | 400 | /* | |
| 396 | 401 | * The normal call pattern is: | |
| 397 | - | * 1. prefix = common_prefix_len(ps); | |
| 402 | + | * 1. prefix = common_prefix_len(ps, &matched_prefix); | |
| 398 | 403 | * 2. prune something, or fill_directory | |
| 399 | 404 | * 3. match_pathspec() | |
| 400 | 405 | * | |
| @@ -414,8 +419,8 @@ static int match_pathspec_item(struct index_state *istate, | |||
| 414 | 419 | * Normally the caller (common_prefix_len() in fact) does | |
| 415 | 420 | * _exact_ matching on name[-prefix+1..-1] and we do not need | |
| 416 | 421 | * to check that part. Be defensive and check it anyway, in | |
| 417 | - | * case common_prefix_len is changed, or a new caller is | |
| 418 | - | * introduced that does not use common_prefix_len. | |
| 422 | + | * case common_prefix_len() is changed, or a new caller is | |
| 423 | + | * introduced that does not use common_prefix_len(). | |
| 419 | 424 | * | |
| 420 | 425 | * If the penalty turns out too high when prefix is really | |
| 421 | 426 | * long, maybe change it to | |
| @@ -593,7 +598,7 @@ static int match_pathspec_with_flags(struct index_state *istate, | |||
| 593 | 598 | if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive) | |
| 594 | 599 | return positive; | |
| 595 | 600 | negative = do_match_pathspec(istate, ps, name, namelen, | |
| 596 | - | prefix, seen, | |
| 601 | + | 0, seen, | |
| 597 | 602 | flags | DO_MATCH_EXCLUDE); | |
| 598 | 603 | return negative ? 0 : positive; | |
| 599 | 604 | } | |
modified odb.c
| @@ -1157,3 +1157,11 @@ void odb_reprepare(struct object_database *o) | |||
| 1157 | 1157 | { | |
| 1158 | 1158 | odb_prepare(o, ODB_PREPARE_FLUSH_CACHES); | |
| 1159 | 1159 | } | |
| 1160 | + | ||
| 1161 | + | int odb_fsck(struct object_database *odb, struct odb_fsck_options *options) | |
| 1162 | + | { | |
| 1163 | + | int ret = 0; | |
| 1164 | + | for (struct odb_source *source = odb->sources; source; source = source->next) | |
| 1165 | + | ret |= odb_source_fsck(source, options); | |
| 1166 | + | return ret; | |
| 1167 | + | } | |
modified odb.h
| @@ -192,6 +192,39 @@ void odb_prepare(struct object_database *o, enum odb_prepare_flags flags); | |||
| 192 | 192 | /* Equivalent to `odb_prepare(o, ODB_PREPARE_FLUSH_CACHES)`. */ | |
| 193 | 193 | void odb_reprepare(struct object_database *o); | |
| 194 | 194 | ||
| 195 | + | enum odb_fsck_flags { | |
| 196 | + | /* | |
| 197 | + | * If set, perform a full consistency check for the full object | |
| 198 | + | * database, including all of its sources and the contents of their | |
| 199 | + | * optimized formats. Otherwise, only check the local source, and | |
| 200 | + | * restrict checks of its optimized formats to cheap structural | |
| 201 | + | * verification of their metadata. | |
| 202 | + | */ | |
| 203 | + | ODB_FSCK_FULL = (1 << 0), | |
| 204 | + | ||
| 205 | + | /* Display a progress meter, if sensible. */ | |
| 206 | + | ODB_FSCK_PROGRESS = (1 << 1), | |
| 207 | + | ||
| 208 | + | /* Be extra verbose when checking the database. */ | |
| 209 | + | ODB_FSCK_VERBOSE = (1 << 2), | |
| 210 | + | }; | |
| 211 | + | ||
| 212 | + | /* Options that shall be passed to `odb_fsck()`. */ | |
| 213 | + | struct odb_fsck_options { | |
| 214 | + | enum odb_fsck_flags flags; | |
| 215 | + | ||
| 216 | + | int (*object_cb)(const struct object_id *oid, enum object_type type, | |
| 217 | + | unsigned long size, void *buffer, int *eaten, void *cb_data); | |
| 218 | + | void *object_payload; | |
| 219 | + | }; | |
| 220 | + | ||
| 221 | + | /* | |
| 222 | + | * Run backend-specific integrity checks on all object sources. Each source | |
| 223 | + | * performs the checks appropriate to its type. Returns 0 on success, a | |
| 224 | + | * negative error code otherwise. | |
| 225 | + | */ | |
| 226 | + | int odb_fsck(struct object_database *odb, struct odb_fsck_options *opts); | |
| 227 | + | ||
| 195 | 228 | /* | |
| 196 | 229 | * Find source by its object directory path. Returns a `NULL` pointer in case | |
| 197 | 230 | * the source could not be found. | |
modified odb/source-files.c
| @@ -909,6 +909,21 @@ static int odb_source_files_generate_pack(struct odb_source *source UNUSED, | |||
| 909 | 909 | return 0; | |
| 910 | 910 | } | |
| 911 | 911 | ||
| 912 | + | static int odb_source_files_fsck(struct odb_source *source, | |
| 913 | + | struct odb_fsck_options *opts) | |
| 914 | + | { | |
| 915 | + | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 916 | + | int ret = 0; | |
| 917 | + | ||
| 918 | + | if (!(opts->flags & ODB_FSCK_FULL) && !source->local) | |
| 919 | + | return 0; | |
| 920 | + | ||
| 921 | + | ret |= odb_source_fsck(&files->loose->base, opts); | |
| 922 | + | ret |= odb_source_fsck(&files->packed->base, opts); | |
| 923 | + | ||
| 924 | + | return ret; | |
| 925 | + | } | |
| 926 | + | ||
| 912 | 927 | struct odb_source_files *odb_source_files_new(struct object_database *odb, | |
| 913 | 928 | const char *path, | |
| 914 | 929 | bool local) | |
| @@ -924,6 +939,7 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb, | |||
| 924 | 939 | files->base.close = odb_source_files_close; | |
| 925 | 940 | files->base.create_on_disk = odb_source_files_create_on_disk; | |
| 926 | 941 | files->base.prepare = odb_source_files_prepare; | |
| 942 | + | files->base.fsck = odb_source_files_fsck; | |
| 927 | 943 | files->base.read_object_info = odb_source_files_read_object_info; | |
| 928 | 944 | files->base.read_object_stream = odb_source_files_read_object_stream; | |
| 929 | 945 | files->base.for_each_object = odb_source_files_for_each_object; | |
modified odb/source-inmemory.c
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | #include "git-compat-util.h" | |
| 2 | 2 | #include "object-file.h" | |
| 3 | 3 | #include "odb.h" | |
| 4 | + | #include "fsck.h" | |
| 4 | 5 | #include "odb/source-inmemory.h" | |
| 5 | 6 | #include "odb/streaming.h" | |
| 6 | 7 | #include "oidtree.h" | |
| @@ -369,6 +370,12 @@ static void odb_source_inmemory_free(struct odb_source *source) | |||
| 369 | 370 | free(inmemory); | |
| 370 | 371 | } | |
| 371 | 372 | ||
| 373 | + | static int odb_source_inmemory_fsck(struct odb_source *source UNUSED, | |
| 374 | + | struct odb_fsck_options *opts UNUSED) | |
| 375 | + | { | |
| 376 | + | return 0; | |
| 377 | + | } | |
| 378 | + | ||
| 372 | 379 | struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb) | |
| 373 | 380 | { | |
| 374 | 381 | struct odb_source_inmemory *source; | |
| @@ -379,6 +386,7 @@ struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb) | |||
| 379 | 386 | source->base.free = odb_source_inmemory_free; | |
| 380 | 387 | source->base.close = odb_source_inmemory_close; | |
| 381 | 388 | source->base.prepare = odb_source_inmemory_prepare; | |
| 389 | + | source->base.fsck = odb_source_inmemory_fsck; | |
| 382 | 390 | source->base.read_object_info = odb_source_inmemory_read_object_info; | |
| 383 | 391 | source->base.read_object_stream = odb_source_inmemory_read_object_stream; | |
| 384 | 392 | source->base.for_each_object = odb_source_inmemory_for_each_object; | |
modified odb/source-loose.c
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | #include "odb/streaming.h" | |
| 13 | 13 | #include "oidtree.h" | |
| 14 | 14 | #include "path.h" | |
| 15 | + | #include "progress.h" | |
| 15 | 16 | #include "repository.h" | |
| 16 | 17 | #include "strbuf.h" | |
| 17 | 18 | #include "tempfile.h" | |
| @@ -1038,6 +1039,96 @@ static void odb_source_loose_free(struct odb_source *source) | |||
| 1038 | 1039 | free(loose); | |
| 1039 | 1040 | } | |
| 1040 | 1041 | ||
| 1042 | + | struct fsck_loose_data { | |
| 1043 | + | struct odb_source_loose *source; | |
| 1044 | + | struct odb_fsck_options *opts; | |
| 1045 | + | struct progress *progress; | |
| 1046 | + | bool error_found; | |
| 1047 | + | }; | |
| 1048 | + | ||
| 1049 | + | static int fsck_loose(const struct object_id *oid, const char *path, | |
| 1050 | + | void *cb_data) | |
| 1051 | + | { | |
| 1052 | + | struct fsck_loose_data *data = cb_data; | |
| 1053 | + | enum object_type type = OBJ_NONE; | |
| 1054 | + | size_t size; | |
| 1055 | + | void *contents = NULL; | |
| 1056 | + | int eaten = 0; | |
| 1057 | + | struct object_info oi = OBJECT_INFO_INIT; | |
| 1058 | + | struct object_id real_oid = *null_oid(data->source->base.odb->repo->hash_algo); | |
| 1059 | + | int err = 0; | |
| 1060 | + | ||
| 1061 | + | oi.sizep = &size; | |
| 1062 | + | oi.typep = &type; | |
| 1063 | + | ||
| 1064 | + | if (read_loose_object(data->source->base.odb->repo, | |
| 1065 | + | path, oid, &real_oid, &contents, &oi) < 0) { | |
| 1066 | + | if (contents && !oideq(&real_oid, oid)) | |
| 1067 | + | err = error(_("%s: hash-path mismatch, found at: %s"), | |
| 1068 | + | oid_to_hex(&real_oid), path); | |
| 1069 | + | else | |
| 1070 | + | err = error(_("%s: object corrupt or missing: %s"), | |
| 1071 | + | oid_to_hex(oid), path); | |
| 1072 | + | } | |
| 1073 | + | if (err < 0) | |
| 1074 | + | goto out; | |
| 1075 | + | ||
| 1076 | + | if (!contents && type != OBJ_BLOB) | |
| 1077 | + | BUG("read_loose_object streamed a non-blob"); | |
| 1078 | + | ||
| 1079 | + | if (data->opts->object_cb(oid, type, size, contents, &eaten, | |
| 1080 | + | data->opts->object_payload)) { | |
| 1081 | + | err = -1; | |
| 1082 | + | goto out; | |
| 1083 | + | } | |
| 1084 | + | ||
| 1085 | + | out: | |
| 1086 | + | if (err) | |
| 1087 | + | data->error_found = true; | |
| 1088 | + | if (!eaten) | |
| 1089 | + | free(contents); | |
| 1090 | + | return 0; /* keep checking other objects, even if we saw an error */ | |
| 1091 | + | } | |
| 1092 | + | ||
| 1093 | + | static int fsck_cruft(const char *basename, const char *path, | |
| 1094 | + | void *data UNUSED) | |
| 1095 | + | { | |
| 1096 | + | if (!starts_with(basename, "tmp_obj_")) | |
| 1097 | + | fprintf_ln(stderr, _("bad sha1 file: %s"), path); | |
| 1098 | + | return 0; | |
| 1099 | + | } | |
| 1100 | + | ||
| 1101 | + | static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *cb_data) | |
| 1102 | + | { | |
| 1103 | + | struct fsck_loose_data *data = cb_data; | |
| 1104 | + | display_progress(data->progress, nr + 1); | |
| 1105 | + | return 0; | |
| 1106 | + | } | |
| 1107 | + | ||
| 1108 | + | static int odb_source_loose_fsck(struct odb_source *source, | |
| 1109 | + | struct odb_fsck_options *opts) | |
| 1110 | + | { | |
| 1111 | + | struct odb_source_loose *loose = odb_source_loose_downcast(source); | |
| 1112 | + | struct fsck_loose_data data = { | |
| 1113 | + | .source = loose, | |
| 1114 | + | .opts = opts, | |
| 1115 | + | }; | |
| 1116 | + | ||
| 1117 | + | if (opts->flags & ODB_FSCK_VERBOSE) | |
| 1118 | + | fprintf_ln(stderr, _("Checking object directory")); | |
| 1119 | + | ||
| 1120 | + | if (opts->flags & ODB_FSCK_PROGRESS) | |
| 1121 | + | data.progress = start_progress(source->odb->repo, | |
| 1122 | + | _("Checking object directories"), 256); | |
| 1123 | + | ||
| 1124 | + | for_each_loose_file_in_source(source, fsck_loose, | |
| 1125 | + | fsck_cruft, fsck_subdir, &data); | |
| 1126 | + | display_progress(data.progress, 256); | |
| 1127 | + | stop_progress(&data.progress); | |
| 1128 | + | ||
| 1129 | + | return data.error_found ? -1 : 0; | |
| 1130 | + | } | |
| 1131 | + | ||
| 1041 | 1132 | struct odb_source_loose *odb_source_loose_new(struct object_database *odb, | |
| 1042 | 1133 | const char *path, | |
| 1043 | 1134 | bool local) | |
| @@ -1050,6 +1141,7 @@ struct odb_source_loose *odb_source_loose_new(struct object_database *odb, | |||
| 1050 | 1141 | loose->base.free = odb_source_loose_free; | |
| 1051 | 1142 | loose->base.close = odb_source_loose_close; | |
| 1052 | 1143 | loose->base.prepare = odb_source_loose_prepare; | |
| 1144 | + | loose->base.fsck = odb_source_loose_fsck; | |
| 1053 | 1145 | loose->base.read_object_info = odb_source_loose_read_object_info; | |
| 1054 | 1146 | loose->base.read_object_stream = odb_source_loose_read_object_stream; | |
| 1055 | 1147 | loose->base.for_each_object = odb_source_loose_for_each_object; | |
modified odb/source-packed.c
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | #include "chdir-notify.h" | |
| 4 | 4 | #include "dir.h" | |
| 5 | 5 | #include "gettext.h" | |
| 6 | + | #include "fsck.h" | |
| 6 | 7 | #include "git-zlib.h" | |
| 7 | 8 | #include "hex.h" | |
| 8 | 9 | #include "list-objects-filter-options.h" | |
| @@ -10,9 +11,13 @@ | |||
| 10 | 11 | #include "midx.h" | |
| 11 | 12 | #include "odb/source-packed.h" | |
| 12 | 13 | #include "odb/streaming.h" | |
| 14 | + | #include "pack.h" | |
| 15 | + | #include "pack-revindex.h" | |
| 13 | 16 | #include "packfile.h" | |
| 14 | 17 | #include "pack-bitmap.h" | |
| 15 | 18 | #include "strbuf.h" | |
| 19 | + | #include "progress.h" | |
| 20 | + | #include "run-command.h" | |
| 16 | 21 | ||
| 17 | 22 | static int find_pack_entry(struct odb_source_packed *store, | |
| 18 | 23 | const struct object_id *oid, | |
| @@ -886,6 +891,117 @@ static void odb_source_packed_free(struct odb_source *source) | |||
| 886 | 891 | free(packed); | |
| 887 | 892 | } | |
| 888 | 893 | ||
| 894 | + | static int verify_packs(struct odb_source_packed *source, | |
| 895 | + | struct odb_fsck_options *opts) | |
| 896 | + | { | |
| 897 | + | struct progress *progress = NULL; | |
| 898 | + | struct packfile_list_entry *e; | |
| 899 | + | uint32_t total = 0, count = 0; | |
| 900 | + | int ret = 0; | |
| 901 | + | ||
| 902 | + | if (opts->flags & ODB_FSCK_PROGRESS) { | |
| 903 | + | for (e = packfile_store_get_packs(source); e; e = e->next) { | |
| 904 | + | if (open_pack_index(e->pack)) | |
| 905 | + | continue; | |
| 906 | + | total += e->pack->num_objects; | |
| 907 | + | } | |
| 908 | + | ||
| 909 | + | progress = start_progress(source->base.odb->repo, | |
| 910 | + | _("Checking objects"), total); | |
| 911 | + | } | |
| 912 | + | ||
| 913 | + | for (e = packfile_store_get_packs(source); e; e = e->next) { | |
| 914 | + | /* verify gives error messages itself */ | |
| 915 | + | if (verify_pack(source->base.odb->repo, e->pack, | |
| 916 | + | opts->object_cb, opts->object_payload, | |
| 917 | + | progress, count)) | |
| 918 | + | ret = -1; | |
| 919 | + | count += e->pack->num_objects; | |
| 920 | + | } | |
| 921 | + | stop_progress(&progress); | |
| 922 | + | ||
| 923 | + | return ret; | |
| 924 | + | } | |
| 925 | + | ||
| 926 | + | static int verify_reverse_indices(struct odb_source_packed *source, | |
| 927 | + | struct odb_fsck_options *opts) | |
| 928 | + | { | |
| 929 | + | struct progress *progress = NULL; | |
| 930 | + | struct packfile_list_entry *e; | |
| 931 | + | uint32_t pack_count = 0; | |
| 932 | + | int res = 0; | |
| 933 | + | ||
| 934 | + | if (opts->flags & ODB_FSCK_PROGRESS) { | |
| 935 | + | for (e = packfile_store_get_packs(source); e; e = e->next) | |
| 936 | + | pack_count++; | |
| 937 | + | progress = start_delayed_progress(source->base.odb->repo, | |
| 938 | + | "Verifying reverse pack-indexes", pack_count); | |
| 939 | + | pack_count = 0; | |
| 940 | + | } | |
| 941 | + | ||
| 942 | + | for (e = packfile_store_get_packs(source); e; e = e->next) { | |
| 943 | + | int load_error = load_pack_revindex_from_disk(e->pack); | |
| 944 | + | ||
| 945 | + | if (load_error < 0) { | |
| 946 | + | error(_("unable to load rev-index for pack '%s'"), e->pack->pack_name); | |
| 947 | + | res = -1; | |
| 948 | + | } else if (!load_error && | |
| 949 | + | !load_pack_revindex(source->base.odb->repo, e->pack) && | |
| 950 | + | verify_pack_revindex(e->pack)) { | |
| 951 | + | error(_("invalid rev-index for pack '%s'"), e->pack->pack_name); | |
| 952 | + | res = -1; | |
| 953 | + | } | |
| 954 | + | display_progress(progress, ++pack_count); | |
| 955 | + | } | |
| 956 | + | stop_progress(&progress); | |
| 957 | + | ||
| 958 | + | return res; | |
| 959 | + | } | |
| 960 | + | ||
| 961 | + | static int verify_midx(struct odb_source_packed *source, | |
| 962 | + | struct odb_fsck_options *opts) | |
| 963 | + | { | |
| 964 | + | struct child_process midx_verify = CHILD_PROCESS_INIT; | |
| 965 | + | ||
| 966 | + | prepare_repo_settings(source->base.odb->repo); | |
| 967 | + | if (!source->base.odb->repo->settings.core_multi_pack_index) | |
| 968 | + | return 0; | |
| 969 | + | ||
| 970 | + | child_process_init(&midx_verify); | |
| 971 | + | midx_verify.git_cmd = 1; | |
| 972 | + | strvec_pushl(&midx_verify.args, "multi-pack-index", | |
| 973 | + | "verify", "--object-dir", source->base.path, NULL); | |
| 974 | + | if (opts->flags & ODB_FSCK_PROGRESS) | |
| 975 | + | strvec_push(&midx_verify.args, "--progress"); | |
| 976 | + | else | |
| 977 | + | strvec_push(&midx_verify.args, "--no-progress"); | |
| 978 | + | if (run_command(&midx_verify)) | |
| 979 | + | return -1; | |
| 980 | + | ||
| 981 | + | return 0; | |
| 982 | + | } | |
| 983 | + | ||
| 984 | + | static int odb_source_packed_fsck(struct odb_source *source, | |
| 985 | + | struct odb_fsck_options *opts) | |
| 986 | + | { | |
| 987 | + | struct odb_source_packed *packed = odb_source_packed_downcast(source); | |
| 988 | + | int ret = 0; | |
| 989 | + | ||
| 990 | + | if ((opts->flags & ODB_FSCK_FULL) && verify_packs(packed, opts) < 0) | |
| 991 | + | ret = -1; | |
| 992 | + | ||
| 993 | + | if (verify_reverse_indices(packed, opts) < 0) | |
| 994 | + | ret = -1; | |
| 995 | + | ||
| 996 | + | if (verify_bitmap_files(packed)) | |
| 997 | + | ret = -1; | |
| 998 | + | ||
| 999 | + | if (verify_midx(packed, opts) < 0) | |
| 1000 | + | ret = -1; | |
| 1001 | + | ||
| 1002 | + | return ret; | |
| 1003 | + | } | |
| 1004 | + | ||
| 889 | 1005 | struct odb_source_packed *odb_source_packed_new(struct object_database *odb, | |
| 890 | 1006 | const char *path, | |
| 891 | 1007 | bool local) | |
| @@ -899,6 +1015,7 @@ struct odb_source_packed *odb_source_packed_new(struct object_database *odb, | |||
| 899 | 1015 | packed->base.free = odb_source_packed_free; | |
| 900 | 1016 | packed->base.close = odb_source_packed_close; | |
| 901 | 1017 | packed->base.prepare = odb_source_packed_prepare; | |
| 1018 | + | packed->base.fsck = odb_source_packed_fsck; | |
| 902 | 1019 | packed->base.read_object_info = odb_source_packed_read_object_info; | |
| 903 | 1020 | packed->base.read_object_stream = odb_source_packed_read_object_stream; | |
| 904 | 1021 | packed->base.for_each_object = odb_source_packed_for_each_object; | |
modified odb/source.h
| @@ -325,6 +325,17 @@ struct odb_source { | |||
| 325 | 325 | int (*generate_pack)(struct odb_source *source, | |
| 326 | 326 | struct odb_pack_generator **out, | |
| 327 | 327 | const struct odb_generate_pack_options *opts); | |
| 328 | + | ||
| 329 | + | /* | |
| 330 | + | * This callback is expected to check the integrity of the object source | |
| 331 | + | * and report any errors found via the fsck options. The checks performed | |
| 332 | + | * are backend-specific. | |
| 333 | + | * | |
| 334 | + | * The callback is expected to return 0 on success, a negative error | |
| 335 | + | * code otherwise. | |
| 336 | + | */ | |
| 337 | + | int (*fsck)(struct odb_source *source, | |
| 338 | + | struct odb_fsck_options *options); | |
| 328 | 339 | }; | |
| 329 | 340 | ||
| 330 | 341 | /* | |
| @@ -598,4 +609,14 @@ static inline int odb_source_generate_pack(struct odb_source *source, | |||
| 598 | 609 | return source->generate_pack(source, out, opts); | |
| 599 | 610 | } | |
| 600 | 611 | ||
| 612 | + | /* | |
| 613 | + | * Check the integrity of the object database source. The checks performed | |
| 614 | + | * are backend-specific. Returns 0 on success, a negative error code otherwise. | |
| 615 | + | */ | |
| 616 | + | static inline int odb_source_fsck(struct odb_source *source, | |
| 617 | + | struct odb_fsck_options *opts) | |
| 618 | + | { | |
| 619 | + | return source->fsck(source, opts); | |
| 620 | + | } | |
| 621 | + | ||
| 601 | 622 | #endif | |
modified pack-bitmap.c
| @@ -3410,28 +3410,22 @@ static int verify_bitmap_file(const struct git_hash_algo *algop, | |||
| 3410 | 3410 | return res; | |
| 3411 | 3411 | } | |
| 3412 | 3412 | ||
| 3413 | - | int verify_bitmap_files(struct repository *r) | |
| 3413 | + | int verify_bitmap_files(struct odb_source_packed *source) | |
| 3414 | 3414 | { | |
| 3415 | - | struct odb_source *source; | |
| 3416 | - | struct packed_git *p; | |
| 3415 | + | struct packfile_list_entry *e; | |
| 3416 | + | struct multi_pack_index *m; | |
| 3417 | 3417 | int res = 0; | |
| 3418 | 3418 | ||
| 3419 | - | for (source = r->objects->sources; source; source = source->next) { | |
| 3420 | - | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 3421 | - | struct multi_pack_index *m = get_multi_pack_index(files->packed); | |
| 3422 | - | char *midx_bitmap_name; | |
| 3423 | - | ||
| 3424 | - | if (!m) | |
| 3425 | - | continue; | |
| 3426 | - | ||
| 3427 | - | midx_bitmap_name = midx_bitmap_filename(m); | |
| 3428 | - | res |= verify_bitmap_file(r->hash_algo, midx_bitmap_name); | |
| 3419 | + | m = get_multi_pack_index(source); | |
| 3420 | + | if (m) { | |
| 3421 | + | char *midx_bitmap_name = midx_bitmap_filename(m); | |
| 3422 | + | res |= verify_bitmap_file(source->base.odb->repo->hash_algo, midx_bitmap_name); | |
| 3429 | 3423 | free(midx_bitmap_name); | |
| 3430 | 3424 | } | |
| 3431 | 3425 | ||
| 3432 | - | repo_for_each_pack(r, p) { | |
| 3433 | - | char *pack_bitmap_name = pack_bitmap_filename(p); | |
| 3434 | - | res |= verify_bitmap_file(r->hash_algo, pack_bitmap_name); | |
| 3426 | + | for (e = packfile_store_get_packs(source); e; e = e->next) { | |
| 3427 | + | char *pack_bitmap_name = pack_bitmap_filename(e->pack); | |
| 3428 | + | res |= verify_bitmap_file(source->base.odb->repo->hash_algo, pack_bitmap_name); | |
| 3435 | 3429 | free(pack_bitmap_name); | |
| 3436 | 3430 | } | |
| 3437 | 3431 | ||
modified pack-bitmap.h
| @@ -205,7 +205,7 @@ int bitmap_is_midx(struct bitmap_index *bitmap_git); | |||
| 205 | 205 | ||
| 206 | 206 | int bitmap_is_preferred_refname(struct repository *r, const char *refname); | |
| 207 | 207 | ||
| 208 | - | int verify_bitmap_files(struct repository *r); | |
| 208 | + | int verify_bitmap_files(struct odb_source_packed *source); | |
| 209 | 209 | ||
| 210 | 210 | struct ewah_bitmap *read_bitmap(const unsigned char *map, | |
| 211 | 211 | size_t map_size, size_t *map_pos); | |
modified po/AGENTS.md
| @@ -93,17 +93,9 @@ msgstr "" | |||
| 93 | 93 | ||
| 94 | 94 | **CRITICAL**: Do **not** use `grep '^msgstr ""'` to find untranslated entries; | |
| 95 | 95 | multi-line `msgstr` blocks use the same opening line, so grep gives false | |
| 96 | - | positives. Use `msgattrib` (next section). | |
| 97 | - | ||
| 98 | - | ||
| 99 | - | ### Locating untranslated, fuzzy, and obsolete entries | |
| 100 | - | ||
| 101 | - | Use `msgattrib` to list untranslated, fuzzy, and obsolete entries. Task 3 | |
| 102 | - | (translating `po/XX.po`) uses these commands. | |
| 103 | - | ||
| 104 | - | - **Untranslated**: `msgattrib --untranslated --no-obsolete po/XX.po` | |
| 105 | - | - **Fuzzy**: `msgattrib --only-fuzzy --no-obsolete po/XX.po` | |
| 106 | - | - **Obsolete** (`#~`): `msgattrib --obsolete --no-wrap po/XX.po` | |
| 96 | + | positives. Use `git-po-helper msg-select` with `--untranslated` / `--fuzzy` | |
| 97 | + | (see Task 3), or `msgattrib` (e.g. `--untranslated`, `--only-fuzzy`, | |
| 98 | + | `--obsolete`). | |
| 107 | 99 | ||
| 108 | 100 | ||
| 109 | 101 | ### Translating fuzzy entries | |
| @@ -238,8 +230,19 @@ On failure, `msgfmt` prints the line number; fix the PO at that line. | |||
| 238 | 230 | ||
| 239 | 231 | [git-po-helper](https://github.com/git-l10n/git-po-helper) supports Git l10n with | |
| 240 | 232 | **quality checking** (git-l10n PR conventions) and **AI-assisted translation** | |
| 241 | - | (subcommands for automated workflows). Housekeeping tasks in this document use | |
| 242 | - | it when available; otherwise rely on gettext tools. | |
| 233 | + | (subcommands for automated workflows). Task 3 (translating) and Task 4 | |
| 234 | + | (reviewing) **require** `git-po-helper` **>= 0.9.1**. Task 1 and Task 2 use | |
| 235 | + | `make` / gettext tooling instead. | |
| 236 | + | ||
| 237 | + | **Version check**: Before Task 3 or Task 4, run: | |
| 238 | + | ||
| 239 | + | ```shell | |
| 240 | + | git-po-helper version --ge 0.9.1 | |
| 241 | + | ``` | |
| 242 | + | ||
| 243 | + | If the command is missing or the exit status is non-zero, print the error (use | |
| 244 | + | the command's own output when available) and **refuse** the task; do not | |
| 245 | + | continue. | |
| 243 | 246 | ||
| 244 | 247 | ||
| 245 | 248 | #### Splitting large PO files | |
| @@ -288,10 +291,10 @@ changed entries; otherwise it contains a valid PO header. | |||
| 288 | 291 | git-po-helper compare po/XX.po -o po/out.po | |
| 289 | 292 | ||
| 290 | 293 | # Get full context of changes in a specific commit (parent vs commit) | |
| 291 | - | git-po-helper compare --commit <commit> po/XX.po -o po/out.po | |
| 294 | + | git-po-helper compare --json --commit <commit> po/XX.po -o po/out.json | |
| 292 | 295 | ||
| 293 | 296 | # Get full context of changes since a commit (commit vs working tree) | |
| 294 | - | git-po-helper compare --since <commit> po/XX.po -o po/out.po | |
| 297 | + | git-po-helper compare --json --since <commit> po/XX.po -o po/out.json | |
| 295 | 298 | ||
| 296 | 299 | # Get full context between two commits | |
| 297 | 300 | git-po-helper compare -r <commit1>..<commit2> po/XX.po -o po/out.po | |
| @@ -476,42 +479,32 @@ When asked to update `po/XX.po` (or the like): | |||
| 476 | 479 | ||
| 477 | 480 | ### Task 3: Translating po/XX.po | |
| 478 | 481 | ||
| 479 | - | To translate `po/XX.po`, use the steps below. The script uses gettext or | |
| 480 | - | `git-po-helper` depending on what is installed; JSON export (when available) | |
| 481 | - | supports batch translation rather than per-entry work. | |
| 482 | + | To translate `po/XX.po`, use the steps below. **Require** `git-po-helper` (see | |
| 483 | + | "Using git-po-helper" for the version check); without a passing check, refuse | |
| 484 | + | the task. Batches are GETTEXT JSON for translation. | |
| 482 | 485 | ||
| 483 | 486 | **Workflow loop**: Steps 1→2→3→4→5→6→7 form a loop. After step 6 succeeds, | |
| 484 | 487 | **always** go to step 7, which returns to step 1. The **only** exit to step 8 | |
| 485 | - | is when step 2 finds `po/l10n-pending.po` empty. Do not skip step 7 or jump to | |
| 488 | + | is when step 2 finds `po/l10n-pending.json` empty. Do not skip step 7 or jump to | |
| 486 | 489 | step 8 after step 6. | |
| 487 | 490 | ||
| 488 | 491 | 1. **Extract entries to translate**: **Directly execute** the script below—it is | |
| 489 | - | authoritative; do not reimplement. It generates `po/l10n-pending.po` with | |
| 492 | + | authoritative; do not reimplement. It generates `po/l10n-pending.json` with | |
| 490 | 493 | messages that need translation. | |
| 491 | 494 | ||
| 492 | 495 | ```shell | |
| 493 | 496 | l10n_extract_pending () { | |
| 494 | 497 | test $# -ge 1 || { echo "Usage: l10n_extract_pending <po-file>" >&2; return 1; } | |
| 495 | 498 | PO_FILE="$1" | |
| 496 | - | PENDING="po/l10n-pending.po" | |
| 497 | - | PENDING_FUZZY="${PENDING}.fuzzy" | |
| 498 | - | PENDING_REFER="${PENDING}.fuzzy.reference" | |
| 499 | - | PENDING_UNTRANS="${PENDING}.untranslated" | |
| 499 | + | PENDING="po/l10n-pending.json" | |
| 500 | 500 | rm -f "$PENDING" | |
| 501 | 501 | ||
| 502 | - | if command -v git-po-helper >/dev/null 2>&1 | |
| 502 | + | git-po-helper msg-select --json --untranslated --fuzzy --no-obsolete -o "$PENDING" "$PO_FILE" | |
| 503 | + | ENTRY_COUNT=$(git-po-helper stat -c "$PENDING" 2>/dev/null || true) | |
| 504 | + | ENTRY_COUNT=${ENTRY_COUNT:-0} | |
| 505 | + | if test "$ENTRY_COUNT" -gt 0 | |
| 503 | 506 | then | |
| 504 | - | git-po-helper msg-select --untranslated --fuzzy --no-obsolete -o "$PENDING" "$PO_FILE" | |
| 505 | - | else | |
| 506 | - | msgattrib --untranslated --no-obsolete "$PO_FILE" >"${PENDING_UNTRANS}" | |
| 507 | - | msgattrib --only-fuzzy --no-obsolete --clear-fuzzy --empty "$PO_FILE" >"${PENDING_FUZZY}" | |
| 508 | - | msgattrib --only-fuzzy --no-obsolete "$PO_FILE" >"${PENDING_REFER}" | |
| 509 | - | msgcat --use-first "${PENDING_UNTRANS}" "${PENDING_FUZZY}" >"$PENDING" | |
| 510 | - | rm -f "${PENDING_UNTRANS}" "${PENDING_FUZZY}" | |
| 511 | - | fi | |
| 512 | - | if test -s "$PENDING" | |
| 513 | - | then | |
| 514 | - | msgfmt --stat -o /dev/null "$PENDING" || true | |
| 507 | + | git-po-helper stat "$PENDING" || true | |
| 515 | 508 | echo "Pending file is not empty; there are still entries to translate." | |
| 516 | 509 | else | |
| 517 | 510 | echo "No entries need translation." | |
| @@ -522,30 +515,28 @@ step 8 after step 6. | |||
| 522 | 515 | l10n_extract_pending po/XX.po | |
| 523 | 516 | ``` | |
| 524 | 517 | ||
| 525 | - | 2. **Check generated file**: If `po/l10n-pending.po` is empty or does not exist, | |
| 526 | - | translation is complete; go to step 8. Otherwise proceed to step 3. | |
| 518 | + | 2. **Check generated file**: If `po/l10n-pending.json` has no content entries | |
| 519 | + | (or does not exist), translation is complete; go to step 8. Otherwise proceed | |
| 520 | + | to step 3. | |
| 527 | 521 | ||
| 528 | 522 | 3. **Prepare one batch for translation**: Batching keeps each run small so the | |
| 529 | 523 | model can complete translation within limited context. **BEFORE translating**, | |
| 530 | 524 | **directly execute** the script below—it is authoritative; do not reimplement. | |
| 531 | - | Based on which file the script produces: if `po/l10n-todo.json` exists, go to | |
| 532 | - | step 4a; if `po/l10n-todo.po` exists, go to step 4b. | |
| 525 | + | It writes `po/l10n-todo.json`; then go to step 4. | |
| 533 | 526 | ||
| 534 | 527 | ```shell | |
| 535 | 528 | l10n_one_batch () { | |
| 536 | 529 | test $# -ge 1 || { echo "Usage: l10n_one_batch <po-file> [min_batch_size]" >&2; return 1; } | |
| 537 | 530 | PO_FILE="$1" | |
| 538 | 531 | min_batch_size=${2:-100} | |
| 539 | - | PENDING="po/l10n-pending.po" | |
| 532 | + | PENDING="po/l10n-pending.json" | |
| 540 | 533 | TODO_JSON="po/l10n-todo.json" | |
| 541 | - | TODO_PO="po/l10n-todo.po" | |
| 542 | 534 | DONE_JSON="po/l10n-done.json" | |
| 543 | - | DONE_PO="po/l10n-done.po" | |
| 544 | - | rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO" | |
| 545 | - | ||
| 546 | - | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0) | |
| 547 | - | ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0)) | |
| 535 | + | DONE_PO_TMP="po/l10n-done.po.tmp" | |
| 536 | + | rm -f "$TODO_JSON" "$DONE_JSON" "$DONE_PO_TMP" | |
| 548 | 537 | ||
| 538 | + | ENTRY_COUNT=$(git-po-helper stat -c "$PENDING" 2>/dev/null || true) | |
| 539 | + | ENTRY_COUNT=${ENTRY_COUNT:-0} | |
| 549 | 540 | if test "$ENTRY_COUNT" -gt $min_batch_size | |
| 550 | 541 | then | |
| 551 | 542 | if test "$ENTRY_COUNT" -gt $((min_batch_size * 8)) | |
| @@ -557,39 +548,18 @@ step 8 after step 6. | |||
| 557 | 548 | else | |
| 558 | 549 | NUM=$min_batch_size | |
| 559 | 550 | fi | |
| 560 | - | BATCHING=1 | |
| 551 | + | git-po-helper msg-select --json --head "$NUM" -o "$TODO_JSON" "$PENDING" | |
| 552 | + | echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)" | |
| 561 | 553 | else | |
| 562 | - | NUM=$ENTRY_COUNT | |
| 563 | - | BATCHING= | |
| 564 | - | fi | |
| 565 | - | ||
| 566 | - | if command -v git-po-helper >/dev/null 2>&1 | |
| 567 | - | then | |
| 568 | - | if test -n "$BATCHING" | |
| 569 | - | then | |
| 570 | - | git-po-helper msg-select --json --head "$NUM" -o "$TODO_JSON" "$PENDING" | |
| 571 | - | echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)" | |
| 572 | - | else | |
| 573 | - | git-po-helper msg-select --json -o "$TODO_JSON" "$PENDING" | |
| 574 | - | echo "Processing all $ENTRY_COUNT entries at once" | |
| 575 | - | fi | |
| 576 | - | else | |
| 577 | - | if test -n "$BATCHING" | |
| 578 | - | then | |
| 579 | - | awk -v num="$NUM" '/^msgid / && count++ > num {exit} 1' "$PENDING" | | |
| 580 | - | tac | awk '/^$/ {found=1} found' | tac >"$TODO_PO" | |
| 581 | - | echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)" | |
| 582 | - | else | |
| 583 | - | cp "$PENDING" "$TODO_PO" | |
| 584 | - | echo "Processing all $ENTRY_COUNT entries at once" | |
| 585 | - | fi | |
| 554 | + | git-po-helper msg-select --json -o "$TODO_JSON" "$PENDING" | |
| 555 | + | echo "Processing all $ENTRY_COUNT entries at once" | |
| 586 | 556 | fi | |
| 587 | 557 | } | |
| 588 | 558 | # Prepare one batch; shrink 2nd arg when batches exceed agent capacity. | |
| 589 | 559 | l10n_one_batch po/XX.po 100 | |
| 590 | 560 | ``` | |
| 591 | 561 | ||
| 592 | - | 4a. **Translate JSON batch** (`po/l10n-todo.json` → `po/l10n-done.json`): | |
| 562 | + | 4. **Translate JSON batch** (`po/l10n-todo.json` → `po/l10n-done.json`): | |
| 593 | 563 | ||
| 594 | 564 | - **Task**: Translate `po/l10n-todo.json` (input, GETTEXT JSON) into | |
| 595 | 565 | `po/l10n-done.json` (output, GETTEXT JSON). See the "GETTEXT JSON format" | |
| @@ -604,32 +574,20 @@ step 8 after step 6. | |||
| 604 | 574 | (for plural entries); clear the fuzzy flag (omit or set `fuzzy` to `false`). | |
| 605 | 575 | Do **not** modify `msgid` or `msgid_plural`. | |
| 606 | 576 | ||
| 607 | - | 4b. **Translate PO batch** (`po/l10n-todo.po` → `po/l10n-done.po`): | |
| 608 | - | ||
| 609 | - | - **Task**: Translate `po/l10n-todo.po` (input, GETTEXT PO) into | |
| 610 | - | `po/l10n-done.po` (output, GETTEXT PO). | |
| 611 | - | - **Reference glossary**: Read the glossary from the pending file header | |
| 612 | - | (see "Glossary Section" above) and use it for consistent terminology. | |
| 613 | - | - **When translating**: Follow the "Quality checklist" above for correctness | |
| 614 | - | and quality. Preserve escape sequences (`\n`, `\"`, `\\`, `\t`), placeholders, | |
| 615 | - | and quotes as in `msgid`. Modify `msgstr` and `msgstr[n]` (for plural | |
| 616 | - | entries); remove the `#, fuzzy` tag from comments when done. Do **not** | |
| 617 | - | modify `msgid` or `msgid_plural`. | |
| 618 | - | ||
| 619 | - | 5. **Validate `po/l10n-done.po`**: | |
| 577 | + | 5. **Validate `po/l10n-done.po.tmp`**: | |
| 620 | 578 | ||
| 621 | 579 | Run the validation script below. If it fails, fix per the errors and notes, | |
| 622 | 580 | re-run until it succeeds. | |
| 623 | 581 | ||
| 624 | 582 | ```shell | |
| 625 | 583 | l10n_validate_done () { | |
| 626 | - | DONE_PO="po/l10n-done.po" | |
| 584 | + | DONE_PO_TMP="po/l10n-done.po.tmp" | |
| 627 | 585 | DONE_JSON="po/l10n-done.json" | |
| 628 | - | PENDING="po/l10n-pending.po" | |
| 586 | + | PENDING="po/l10n-pending.json" | |
| 629 | 587 | ||
| 630 | - | if test -f "$DONE_JSON" && { ! test -f "$DONE_PO" || test "$DONE_JSON" -nt "$DONE_PO"; } | |
| 588 | + | if test -f "$DONE_JSON" && { ! test -f "$DONE_PO_TMP" || test "$DONE_JSON" -nt "$DONE_PO_TMP"; } | |
| 631 | 589 | then | |
| 632 | - | git-po-helper msg-cat --unset-fuzzy -o "$DONE_PO" "$DONE_JSON" || { | |
| 590 | + | git-po-helper msg-cat --unset-fuzzy -o "$DONE_PO_TMP" "$DONE_JSON" || { | |
| 633 | 591 | echo "ERROR [JSON to PO conversion]: Fix $DONE_JSON and re-run." >&2 | |
| 634 | 592 | return 1 | |
| 635 | 593 | } | |
| @@ -637,22 +595,22 @@ step 8 after step 6. | |||
| 637 | 595 | ||
| 638 | 596 | # Check 1: msgid should not be modified | |
| 639 | 597 | MSGID_OUT=$(git-po-helper compare -q --msgid --assert-no-changes \ | |
| 640 | - | "$PENDING" "$DONE_PO" 2>&1) | |
| 598 | + | "$PENDING" "$DONE_PO_TMP" 2>&1) | |
| 641 | 599 | MSGID_RC=$? | |
| 642 | 600 | if test $MSGID_RC -ne 0 || test -n "$MSGID_OUT" | |
| 643 | 601 | then | |
| 644 | 602 | echo "ERROR [msgid modified]: The following entries appeared after" >&2 | |
| 645 | - | echo "translation because msgid was altered. Fix in $DONE_PO." >&2 | |
| 603 | + | echo "translation because msgid was altered. Fix in $DONE_PO_TMP." >&2 | |
| 646 | 604 | echo "$MSGID_OUT" >&2 | |
| 647 | 605 | return 1 | |
| 648 | 606 | fi | |
| 649 | 607 | ||
| 650 | 608 | # Check 2: PO format (see "Validating PO File Format" for error handling) | |
| 651 | - | MSGFMT_OUT=$(msgfmt --check -o /dev/null "$DONE_PO" 2>&1) | |
| 609 | + | MSGFMT_OUT=$(msgfmt --check -o /dev/null "$DONE_PO_TMP" 2>&1) | |
| 652 | 610 | MSGFMT_RC=$? | |
| 653 | 611 | if test $MSGFMT_RC -ne 0 | |
| 654 | 612 | then | |
| 655 | - | echo "ERROR [PO format]: Fix errors in $DONE_PO." >&2 | |
| 613 | + | echo "ERROR [PO format]: Fix errors in $DONE_PO_TMP." >&2 | |
| 656 | 614 | echo "$MSGFMT_OUT" >&2 | |
| 657 | 615 | return 1 | |
| 658 | 616 | fi | |
| @@ -662,46 +620,43 @@ step 8 after step 6. | |||
| 662 | 620 | l10n_validate_done | |
| 663 | 621 | ``` | |
| 664 | 622 | ||
| 665 | - | If the script fails, fix **directly in `po/l10n-done.po`**. Re-run | |
| 623 | + | If the script fails, fix **directly in `po/l10n-done.po.tmp`**. Re-run | |
| 666 | 624 | `l10n_validate_done` until it succeeds. Editing `po/l10n-done.json` is not | |
| 667 | 625 | recommended because it adds an extra JSON-to-PO conversion step. Use the | |
| 668 | 626 | error message to decide: | |
| 669 | 627 | ||
| 670 | 628 | - **`[msgid modified]`**: The listed entries have altered `msgid`; restore | |
| 671 | - | them to match `po/l10n-pending.po`. | |
| 629 | + | them to match `po/l10n-pending.json`. | |
| 672 | 630 | - **`[PO format]`**: `msgfmt` reports line numbers; fix the errors in place. | |
| 673 | 631 | See "Validating PO File Format" for common issues. | |
| 674 | 632 | ||
| 675 | 633 | ||
| 676 | 634 | 6. **Merge translation results into `po/XX.po`**: Run the script below. If it | |
| 677 | 635 | fails, fix the file the error names: **`[JSON to PO conversion]`** → | |
| 678 | - | `po/l10n-done.json`; **`[msgcat merge]`** → `po/l10n-done.po`. Re-run until | |
| 636 | + | `po/l10n-done.json`; **`[msgcat merge]`** → `po/l10n-done.po.tmp`. Re-run until | |
| 679 | 637 | it succeeds. | |
| 680 | 638 | ||
| 681 | 639 | ```shell | |
| 682 | 640 | l10n_merge_batch () { | |
| 683 | 641 | test $# -ge 1 || { echo "Usage: l10n_merge_batch <po-file>" >&2; return 1; } | |
| 684 | 642 | PO_FILE="$1" | |
| 685 | - | DONE_PO="po/l10n-done.po" | |
| 643 | + | DONE_PO_TMP="po/l10n-done.po.tmp" | |
| 686 | 644 | DONE_JSON="po/l10n-done.json" | |
| 687 | 645 | MERGED="po/l10n-done.merged" | |
| 688 | - | PENDING="po/l10n-pending.po" | |
| 689 | - | PENDING_REFER="${PENDING}.fuzzy.reference" | |
| 690 | 646 | TODO_JSON="po/l10n-todo.json" | |
| 691 | - | TODO_PO="po/l10n-todo.po" | |
| 692 | - | if test -f "$DONE_JSON" && { ! test -f "$DONE_PO" || test "$DONE_JSON" -nt "$DONE_PO"; } | |
| 647 | + | if test -f "$DONE_JSON" && { ! test -f "$DONE_PO_TMP" || test "$DONE_JSON" -nt "$DONE_PO_TMP"; } | |
| 693 | 648 | then | |
| 694 | - | git-po-helper msg-cat --unset-fuzzy -o "$DONE_PO" "$DONE_JSON" || { | |
| 649 | + | git-po-helper msg-cat --unset-fuzzy -o "$DONE_PO_TMP" "$DONE_JSON" || { | |
| 695 | 650 | echo "ERROR [JSON to PO conversion]: Fix $DONE_JSON and re-run." >&2 | |
| 696 | 651 | return 1 | |
| 697 | 652 | } | |
| 698 | 653 | fi | |
| 699 | - | msgcat --use-first "$DONE_PO" "$PO_FILE" >"$MERGED" || { | |
| 700 | - | echo "ERROR [msgcat merge]: Fix errors in $DONE_PO and re-run." >&2 | |
| 654 | + | msgcat --use-first "$DONE_PO_TMP" "$PO_FILE" >"$MERGED" || { | |
| 655 | + | echo "ERROR [msgcat merge]: Fix errors in $DONE_PO_TMP and re-run." >&2 | |
| 701 | 656 | return 1 | |
| 702 | 657 | } | |
| 703 | 658 | mv "$MERGED" "$PO_FILE" | |
| 704 | - | rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO" "$PENDING_REFER" | |
| 659 | + | rm -f "$TODO_JSON" "$DONE_JSON" "$DONE_PO_TMP" | |
| 705 | 660 | } | |
| 706 | 661 | # Run the merge. Example: l10n_merge_batch po/zh_CN.po | |
| 707 | 662 | l10n_merge_batch po/XX.po | |
| @@ -726,15 +681,16 @@ commit. When asked to review, follow the steps below. | |||
| 726 | 681 | ||
| 727 | 682 | **Workflow**: Follow steps in order. Do **NOT** use `git show`, `git diff`, | |
| 728 | 683 | `git format-patch`, or similar to get changes—they break PO context; use **only** | |
| 729 | - | `git-po-helper compare` for extraction. Without `git-po-helper`, refuse the task. | |
| 730 | - | Steps 3→4→5→6→7 loop: after step 6, **always** go to step 7 (back to step 3). | |
| 731 | - | The **only** ways to step 8 are when step 4 finds `po/review-todo.json` missing | |
| 732 | - | or empty (no batch left to review), or when step 1 finds `po/review-result.json` | |
| 733 | - | already present. | |
| 684 | + | `git-po-helper compare` for extraction. **Require** `git-po-helper` (see | |
| 685 | + | "Using git-po-helper" for the version check); without a passing check, refuse | |
| 686 | + | the task. Steps 3→4→5→6→7 loop: after step 6, **always** go to step 7 (back to | |
| 687 | + | step 3). The **only** ways to step 8 are when step 4 finds `po/review-todo.json` | |
| 688 | + | missing or empty (no batch left to review), or when step 1 finds | |
| 689 | + | `po/review-result.json` already present. | |
| 734 | 690 | ||
| 735 | 691 | 1. **Check for existing review (resume support)**: Evaluate the following in order: | |
| 736 | 692 | ||
| 737 | - | - If `po/review-input.po` does **not** exist, proceed to step 2 (Extract | |
| 693 | + | - If `po/review-input.json` does **not** exist, proceed to step 2 (Extract | |
| 738 | 694 | entries) for a fresh start. | |
| 739 | 695 | - Else If `po/review-result.json` exists, go to step 8 (only after loop exits). | |
| 740 | 696 | - Else If `po/review-done.json` exists, go to step 6 (Rename result). | |
| @@ -742,9 +698,9 @@ already present. | |||
| 742 | 698 | batch). | |
| 743 | 699 | - Else go to step 3 (Prepare one batch). | |
| 744 | 700 | ||
| 745 | - | 2. **Extract entries**: Run `git-po-helper compare` with the desired range and | |
| 746 | - | redirect the output to `po/review-input.po`. See "Comparing PO files for | |
| 747 | - | translation and review" under git-po-helper for options. | |
| 701 | + | 2. **Extract entries**: Run `git-po-helper compare --json` with the desired range | |
| 702 | + | and write the output to `po/review-input.json` (use `-o`). See "Comparing PO | |
| 703 | + | files for translation and review" under git-po-helper for options. | |
| 748 | 704 | ||
| 749 | 705 | 3. **Prepare one batch**: Batching keeps each run small so the model can | |
| 750 | 706 | complete review within limited context. **Directly execute** the script | |
| @@ -753,27 +709,27 @@ already present. | |||
| 753 | 709 | ```shell | |
| 754 | 710 | review_one_batch () { | |
| 755 | 711 | min_batch_size=${1:-100} | |
| 756 | - | INPUT_PO="po/review-input.po" | |
| 757 | - | PENDING="po/review-pending.po" | |
| 712 | + | INPUT_JSON="po/review-input.json" | |
| 713 | + | PENDING="po/review-pending.json" | |
| 758 | 714 | TODO="po/review-todo.json" | |
| 759 | 715 | DONE="po/review-done.json" | |
| 760 | 716 | BATCH_FILE="po/review-batch.txt" | |
| 761 | 717 | ||
| 762 | - | if test ! -f "$INPUT_PO" | |
| 718 | + | if test ! -f "$INPUT_JSON" | |
| 763 | 719 | then | |
| 764 | 720 | rm -f "$TODO" | |
| 765 | - | echo >&2 "cannot find $INPUT_PO, nothing for review" | |
| 721 | + | echo >&2 "cannot find $INPUT_JSON, nothing for review" | |
| 766 | 722 | return 1 | |
| 767 | 723 | fi | |
| 768 | - | if test ! -f "$PENDING" || test "$INPUT_PO" -nt "$PENDING" | |
| 724 | + | if test ! -f "$PENDING" || test "$INPUT_JSON" -nt "$PENDING" | |
| 769 | 725 | then | |
| 770 | 726 | rm -f "$BATCH_FILE" "$TODO" "$DONE" | |
| 771 | 727 | rm -f po/review-result*.json | |
| 772 | - | cp "$INPUT_PO" "$PENDING" | |
| 728 | + | cp "$INPUT_JSON" "$PENDING" | |
| 773 | 729 | fi | |
| 774 | 730 | ||
| 775 | - | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0) | |
| 776 | - | ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0)) | |
| 731 | + | ENTRY_COUNT=$(git-po-helper stat -c "$PENDING" 2>/dev/null || true) | |
| 732 | + | ENTRY_COUNT=${ENTRY_COUNT:-0} | |
| 777 | 733 | if test "$ENTRY_COUNT" -eq 0 | |
| 778 | 734 | then | |
| 779 | 735 | rm -f "$TODO" | |
| @@ -796,12 +752,13 @@ already present. | |||
| 796 | 752 | NUM=$ENTRY_COUNT | |
| 797 | 753 | fi | |
| 798 | 754 | ||
| 799 | - | BATCH=$(cat "$BATCH_FILE" 2>/dev/null || echo 0) | |
| 755 | + | BATCH=$(cat "$BATCH_FILE" 2>/dev/null || true) | |
| 756 | + | BATCH=${BATCH:-0} | |
| 800 | 757 | BATCH=$((BATCH + 1)) | |
| 801 | 758 | echo "$BATCH" >"$BATCH_FILE" | |
| 802 | 759 | ||
| 803 | 760 | git-po-helper msg-select --json --head "$NUM" -o "$TODO" "$PENDING" | |
| 804 | - | git-po-helper msg-select --since "$((NUM + 1))" -o "${PENDING}.tmp" "$PENDING" | |
| 761 | + | git-po-helper msg-select --json --since "$((NUM + 1))" -o "${PENDING}.tmp" "$PENDING" | |
| 805 | 762 | mv "${PENDING}.tmp" "$PENDING" | |
| 806 | 763 | echo "Processing batch $BATCH ($NUM entries out of $ENTRY_COUNT)" | |
| 807 | 764 | } | |
modified sequencer.c
| @@ -143,13 +143,6 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script") | |||
| 143 | 143 | * command is processed, this file is deleted. | |
| 144 | 144 | */ | |
| 145 | 145 | static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend") | |
| 146 | - | /* | |
| 147 | - | * The apply ("am") backend keeps its state in the rebase-apply directory; | |
| 148 | - | * the "applying" file within it marks a plain `git am` (as opposed to an | |
| 149 | - | * apply-based rebase). | |
| 150 | - | */ | |
| 151 | - | static GIT_PATH_FUNC(apply_dir, "rebase-apply") | |
| 152 | - | static GIT_PATH_FUNC(apply_path_applying, "rebase-apply/applying") | |
| 153 | 146 | /* | |
| 154 | 147 | * When we stop at a given patch via the "edit" command, this file contains | |
| 155 | 148 | * the commit object name of the corresponding patch. | |
| @@ -6994,7 +6987,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 6994 | 6987 | !repo_get_oid(r, "REBASE_HEAD", &rebase_head) && | |
| 6995 | 6988 | !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) && | |
| 6996 | 6989 | oideq(&rebase_head, &cherry_pick_head)) | |
| 6997 | - | *whence = FROM_REBASE_NOW_EMPTY; | |
| 6990 | + | *whence = FROM_REBASE_PICK; | |
| 6998 | 6991 | else | |
| 6999 | 6992 | *whence = FROM_CHERRY_PICK_SINGLE; | |
| 7000 | 6993 | ||
| @@ -7004,56 +6997,6 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 7004 | 6997 | return 0; | |
| 7005 | 6998 | } | |
| 7006 | 6999 | ||
| 7007 | - | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 7008 | - | enum commit_whence whence) | |
| 7009 | - | { | |
| 7010 | - | /* | |
| 7011 | - | * The merge, cherry-pick, and (empty) rebase-pick stops are already | |
| 7012 | - | * distinguished by 'whence'. | |
| 7013 | - | */ | |
| 7014 | - | switch (whence) { | |
| 7015 | - | case FROM_MERGE: | |
| 7016 | - | return ONGOING_MERGE; | |
| 7017 | - | case FROM_CHERRY_PICK_SINGLE: | |
| 7018 | - | case FROM_CHERRY_PICK_MULTI: | |
| 7019 | - | return ONGOING_CHERRY_PICK; | |
| 7020 | - | case FROM_REBASE_NOW_EMPTY: | |
| 7021 | - | return ONGOING_REBASE_NOW_EMPTY; | |
| 7022 | - | case FROM_COMMIT: | |
| 7023 | - | break; | |
| 7024 | - | } | |
| 7025 | - | ||
| 7026 | - | /* | |
| 7027 | - | * 'whence' is FROM_COMMIT, but we may still be in the middle of an | |
| 7028 | - | * operation that records its result on top of HEAD; detect those | |
| 7029 | - | * from their on-disk state. | |
| 7030 | - | */ | |
| 7031 | - | ||
| 7032 | - | /* In the middle of a revert? */ | |
| 7033 | - | if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) | |
| 7034 | - | return ONGOING_REVERT; | |
| 7035 | - | ||
| 7036 | - | /* In the middle of an `am`? */ | |
| 7037 | - | if (file_exists(apply_path_applying())) | |
| 7038 | - | return ONGOING_AM; | |
| 7039 | - | ||
| 7040 | - | /* | |
| 7041 | - | * In the middle of a rebase that stopped for conflict resolution? | |
| 7042 | - | * The apply backend only ever stops for conflicts, so the presence | |
| 7043 | - | * of its state directory is enough. The merge backend writes | |
| 7044 | - | * stopped-sha whenever it hands control back to the user, but omits | |
| 7045 | - | * `amend` unless it stopped with HEAD already pointing at the commit | |
| 7046 | - | * to be amended (a clean edit/reword stop); its absence therefore | |
| 7047 | - | * marks a conflicted stop. | |
| 7048 | - | */ | |
| 7049 | - | if (file_exists(apply_dir()) || | |
| 7050 | - | (file_exists(rebase_path_stopped_sha()) && | |
| 7051 | - | !file_exists(rebase_path_amend()))) | |
| 7052 | - | return ONGOING_REBASE_CONFLICT; | |
| 7053 | - | ||
| 7054 | - | return ONGOING_NONE; | |
| 7055 | - | } | |
| 7056 | - | ||
| 7057 | 7000 | int sequencer_get_update_refs_state(const char *wt_dir, | |
| 7058 | 7001 | struct string_list *refs) | |
| 7059 | 7002 | { | |
modified sequencer.h
| @@ -282,30 +282,6 @@ int sequencer_get_last_command(struct repository* r, | |||
| 282 | 282 | enum replay_action *action); | |
| 283 | 283 | int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); | |
| 284 | 284 | ||
| 285 | - | /* | |
| 286 | - | * An in-progress operation that records its result (often a conflict | |
| 287 | - | * resolution) as a new commit on top of HEAD. Some ways of invoking | |
| 288 | - | * "git commit" -- amending HEAD, or a partial commit -- are almost | |
| 289 | - | * always a mistake during such an operation. | |
| 290 | - | */ | |
| 291 | - | enum ongoing_operation { | |
| 292 | - | ONGOING_NONE = 0, | |
| 293 | - | ONGOING_MERGE, | |
| 294 | - | ONGOING_CHERRY_PICK, | |
| 295 | - | ONGOING_REBASE_NOW_EMPTY, | |
| 296 | - | ONGOING_REVERT, | |
| 297 | - | ONGOING_AM, | |
| 298 | - | ONGOING_REBASE_CONFLICT | |
| 299 | - | }; | |
| 300 | - | ||
| 301 | - | /* | |
| 302 | - | * Return which in-progress operation, if any, is underway; see enum | |
| 303 | - | * ongoing_operation. 'whence' is the origin already computed for the | |
| 304 | - | * pending commit. | |
| 305 | - | */ | |
| 306 | - | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 307 | - | enum commit_whence whence); | |
| 308 | - | ||
| 309 | 285 | /** | |
| 310 | 286 | * Append the set of ref-OID pairs that are currently stored for the 'git | |
| 311 | 287 | * rebase --update-refs' feature if such a rebase is currently happening. | |
modified src/cargo-meson.sh
| @@ -38,7 +38,7 @@ then | |||
| 38 | 38 | exit $RET | |
| 39 | 39 | fi | |
| 40 | 40 | ||
| 41 | - | if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 | |
| 41 | + | if ! cmp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 | |
| 42 | 42 | then | |
| 43 | - | cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" | |
| 43 | + | cp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" | |
| 44 | 44 | fi | |
modified t/t1450-fsck.sh
| @@ -844,6 +844,11 @@ test_expect_success 'alternate objects are correctly blamed' ' | |||
| 844 | 844 | echo "../../alt.git/objects" >.git/objects/info/alternates && | |
| 845 | 845 | mkdir alt.git/objects/$(dirname $path) && | |
| 846 | 846 | >alt.git/objects/$(dirname $path)/$(basename $path) && | |
| 847 | + | ||
| 848 | + | # Without "--full", only the local object source is checked. | |
| 849 | + | git fsck --no-full >out 2>&1 && | |
| 850 | + | test_must_be_empty out && | |
| 851 | + | ||
| 847 | 852 | test_must_fail git fsck >out 2>&1 && | |
| 848 | 853 | test_grep alt.git out | |
| 849 | 854 | ' | |
modified t/t3404-rebase-interactive.sh
| @@ -1858,7 +1858,7 @@ test_expect_success 'post-commit hook is called' ' | |||
| 1858 | 1858 | test_cmp expect actual | |
| 1859 | 1859 | ' | |
| 1860 | 1860 | ||
| 1861 | - | test_expect_success 'partial commit is allowed when a rebase pick becomes empty' ' | |
| 1861 | + | test_expect_success 'correct error message for partial commit after empty pick' ' | |
| 1862 | 1862 | test_when_finished "git rebase --abort" && | |
| 1863 | 1863 | ( | |
| 1864 | 1864 | set_fake_editor && | |
| @@ -1867,7 +1867,8 @@ test_expect_success 'partial commit is allowed when a rebase pick becomes empty' | |||
| 1867 | 1867 | test_must_fail git rebase -i A D | |
| 1868 | 1868 | ) && | |
| 1869 | 1869 | echo x >file1 && | |
| 1870 | - | git commit file1 | |
| 1870 | + | test_must_fail git commit file1 2>err && | |
| 1871 | + | test_grep "cannot do a partial commit during a rebase." err | |
| 1871 | 1872 | ' | |
| 1872 | 1873 | ||
| 1873 | 1874 | test_expect_success 'correct error message for commit --amend after empty pick' ' | |
| @@ -1880,128 +1881,7 @@ test_expect_success 'correct error message for commit --amend after empty pick' | |||
| 1880 | 1881 | ) && | |
| 1881 | 1882 | echo x>file1 && | |
| 1882 | 1883 | test_must_fail git commit -a --amend 2>err && | |
| 1883 | - | test_grep "now-empty commit has been dropped -- cannot amend." err | |
| 1884 | - | ' | |
| 1885 | - | ||
| 1886 | - | test_expect_success 'commit --amend is refused at a rebase conflict stop' ' | |
| 1887 | - | test_when_finished "git rebase --abort" && | |
| 1888 | - | git checkout --detach conflict-branch && | |
| 1889 | - | ( | |
| 1890 | - | set_fake_editor && | |
| 1891 | - | FAKE_LINES="1 3" && | |
| 1892 | - | export FAKE_LINES && | |
| 1893 | - | test_must_fail git rebase -i A | |
| 1894 | - | ) && | |
| 1895 | - | test_path_is_file .git/rebase-merge/patch && | |
| 1896 | - | test_path_is_missing .git/rebase-merge/amend && | |
| 1897 | - | echo resolved >conflict && | |
| 1898 | - | git add conflict && | |
| 1899 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1900 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1901 | - | ' | |
| 1902 | - | ||
| 1903 | - | test_expect_success 'commit --amend is refused when an "edit" pick conflicts' ' | |
| 1904 | - | test_when_finished "git rebase --abort" && | |
| 1905 | - | git checkout --detach conflict-branch && | |
| 1906 | - | ( | |
| 1907 | - | set_fake_editor && | |
| 1908 | - | FAKE_LINES="1 edit 3" && | |
| 1909 | - | export FAKE_LINES && | |
| 1910 | - | test_must_fail git rebase -i A | |
| 1911 | - | ) && | |
| 1912 | - | test_path_is_file .git/rebase-merge/patch && | |
| 1913 | - | test_path_is_missing .git/rebase-merge/amend && | |
| 1914 | - | echo resolved >conflict && | |
| 1915 | - | git add conflict && | |
| 1916 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1917 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1918 | - | ' | |
| 1919 | - | ||
| 1920 | - | test_expect_success 'commit --amend is allowed at a rebase edit stop' ' | |
| 1921 | - | test_when_finished "git rebase --abort" && | |
| 1922 | - | git checkout --detach no-conflict-branch && | |
| 1923 | - | ( | |
| 1924 | - | set_fake_editor && | |
| 1925 | - | FAKE_LINES="edit 1 2 3 4" && | |
| 1926 | - | export FAKE_LINES && | |
| 1927 | - | git rebase -i A | |
| 1928 | - | ) && | |
| 1929 | - | test_path_is_file .git/rebase-merge/amend && | |
| 1930 | - | echo tweak >fileJ && | |
| 1931 | - | git add fileJ && | |
| 1932 | - | git commit --amend --no-edit | |
| 1933 | - | ' | |
| 1934 | - | ||
| 1935 | - | test_expect_success 'commit --amend is allowed at a rebase break stop' ' | |
| 1936 | - | test_when_finished "git rebase --abort" && | |
| 1937 | - | git checkout --detach no-conflict-branch && | |
| 1938 | - | ( | |
| 1939 | - | set_fake_editor && | |
| 1940 | - | FAKE_LINES="break 1 2 3 4" && | |
| 1941 | - | export FAKE_LINES && | |
| 1942 | - | git rebase -i A | |
| 1943 | - | ) && | |
| 1944 | - | test_must_fail git rev-parse --verify REBASE_HEAD && | |
| 1945 | - | echo tweak >fileJ && | |
| 1946 | - | git add fileJ && | |
| 1947 | - | git commit --amend --no-edit | |
| 1948 | - | ' | |
| 1949 | - | ||
| 1950 | - | test_expect_success 'commit --amend is refused at an apply-backend conflict stop' ' | |
| 1951 | - | test_when_finished "rm -rf apply-backend" && | |
| 1952 | - | test_create_repo apply-backend && | |
| 1953 | - | ( | |
| 1954 | - | cd apply-backend && | |
| 1955 | - | test_commit base file && | |
| 1956 | - | git branch -M mainline && | |
| 1957 | - | test_commit upstream file upstream && | |
| 1958 | - | git checkout -b side mainline~1 && | |
| 1959 | - | test_commit conflicting file side && | |
| 1960 | - | test_commit unrelated other && | |
| 1961 | - | test_must_fail git rebase --apply mainline && | |
| 1962 | - | # the apply backend only ever stops for conflicts, and | |
| 1963 | - | # leaves HEAD on the previously-applied commit | |
| 1964 | - | test_path_is_dir .git/rebase-apply && | |
| 1965 | - | test_path_is_missing .git/rebase-apply/applying && | |
| 1966 | - | echo resolved >file && | |
| 1967 | - | git add file && | |
| 1968 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1969 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1970 | - | ) | |
| 1971 | - | ' | |
| 1972 | - | ||
| 1973 | - | test_expect_success 'partial commit is refused at a rebase conflict stop' ' | |
| 1974 | - | test_when_finished "git rebase --abort" && | |
| 1975 | - | git checkout --detach conflict-branch && | |
| 1976 | - | ( | |
| 1977 | - | set_fake_editor && | |
| 1978 | - | FAKE_LINES="1 3" && | |
| 1979 | - | export FAKE_LINES && | |
| 1980 | - | test_must_fail git rebase -i A | |
| 1981 | - | ) && | |
| 1982 | - | echo resolved >conflict && | |
| 1983 | - | git add conflict && | |
| 1984 | - | test_must_fail git commit conflict 2>err && | |
| 1985 | - | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 1986 | - | ' | |
| 1987 | - | ||
| 1988 | - | test_expect_success 'partial commit is refused at an apply-backend conflict stop' ' | |
| 1989 | - | test_when_finished "rm -rf apply-backend" && | |
| 1990 | - | test_create_repo apply-backend && | |
| 1991 | - | ( | |
| 1992 | - | cd apply-backend && | |
| 1993 | - | test_commit base file && | |
| 1994 | - | git branch -M mainline && | |
| 1995 | - | test_commit upstream file upstream && | |
| 1996 | - | git checkout -b side mainline~1 && | |
| 1997 | - | test_commit conflicting file side && | |
| 1998 | - | test_commit unrelated other && | |
| 1999 | - | test_must_fail git rebase --apply mainline && | |
| 2000 | - | echo resolved >file && | |
| 2001 | - | git add file && | |
| 2002 | - | test_must_fail git commit file 2>err && | |
| 2003 | - | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 2004 | - | ) | |
| 1884 | + | test_grep "middle of a rebase -- cannot amend." err | |
| 2005 | 1885 | ' | |
| 2006 | 1886 | ||
| 2007 | 1887 | test_expect_success 'todo has correct onto hash' ' | |
modified t/t3507-cherry-pick-conflict.sh
| @@ -365,28 +365,6 @@ test_expect_success 'failed revert sets REVERT_HEAD' ' | |||
| 365 | 365 | test_cmp_rev picked REVERT_HEAD | |
| 366 | 366 | ' | |
| 367 | 367 | ||
| 368 | - | test_expect_success 'commit --amend of revert fails' ' | |
| 369 | - | pristine_detach initial && | |
| 370 | - | ||
| 371 | - | test_must_fail git revert picked && | |
| 372 | - | echo resolved >foo && | |
| 373 | - | git add foo && | |
| 374 | - | test_must_fail git commit --amend 2>err && | |
| 375 | - | ||
| 376 | - | test_grep "in the middle of a revert -- cannot amend." err | |
| 377 | - | ' | |
| 378 | - | ||
| 379 | - | test_expect_success 'partial commit during a revert fails' ' | |
| 380 | - | pristine_detach initial && | |
| 381 | - | ||
| 382 | - | test_must_fail git revert picked && | |
| 383 | - | echo resolved >foo && | |
| 384 | - | git add foo && | |
| 385 | - | test_must_fail git commit foo 2>err && | |
| 386 | - | ||
| 387 | - | test_grep "cannot do a partial commit during a revert." err | |
| 388 | - | ' | |
| 389 | - | ||
| 390 | 368 | test_expect_success 'successful revert does not set REVERT_HEAD' ' | |
| 391 | 369 | pristine_detach base && | |
| 392 | 370 | git revert base && | |
modified t/t4151-am-abort.sh
| @@ -63,28 +63,6 @@ do | |||
| 63 | 63 | ||
| 64 | 64 | done | |
| 65 | 65 | ||
| 66 | - | test_expect_success 'commit --amend during a failed am fails' ' | |
| 67 | - | git reset --hard initial && | |
| 68 | - | cp file-2-expect file-2 && | |
| 69 | - | test_must_fail git am 000[1245]-*.patch && | |
| 70 | - | echo resolved >file-1 && | |
| 71 | - | git add file-1 && | |
| 72 | - | test_must_fail git commit --amend 2>err && | |
| 73 | - | test_grep "in the middle of an am session -- cannot amend." err && | |
| 74 | - | git am --abort | |
| 75 | - | ' | |
| 76 | - | ||
| 77 | - | test_expect_success 'partial commit during a failed am fails' ' | |
| 78 | - | git reset --hard initial && | |
| 79 | - | cp file-2-expect file-2 && | |
| 80 | - | test_must_fail git am 000[1245]-*.patch && | |
| 81 | - | echo resolved >file-1 && | |
| 82 | - | git add file-1 && | |
| 83 | - | test_must_fail git commit file-1 2>err && | |
| 84 | - | test_grep "cannot do a partial commit during an am session." err && | |
| 85 | - | git am --abort | |
| 86 | - | ' | |
| 87 | - | ||
| 88 | 66 | test_expect_success 'am -3 --skip removes otherfile-4' ' | |
| 89 | 67 | git reset --hard initial && | |
| 90 | 68 | test_must_fail git am -3 0003-*.patch && | |
modified t/t5319-multi-pack-index.sh
| @@ -573,6 +573,19 @@ test_expect_success 'verify incorrect checksum' ' | |||
| 573 | 573 | $objdir "incorrect checksum" | |
| 574 | 574 | ' | |
| 575 | 575 | ||
| 576 | + | test_expect_success 'git fsck --no-full checks multi-pack-index, --connectivity-only does not' ' | |
| 577 | + | pos=$(($(wc -c <$objdir/pack/multi-pack-index) - 10)) && | |
| 578 | + | corrupt_midx_and_verify $pos \ | |
| 579 | + | "\377\377\377\377\377\377\377\377\377\377" \ | |
| 580 | + | $objdir "incorrect checksum" && | |
| 581 | + | ||
| 582 | + | test_must_fail git fsck --no-full 2>err && | |
| 583 | + | test_grep "incorrect checksum" err && | |
| 584 | + | ||
| 585 | + | git fsck --connectivity-only 2>err && | |
| 586 | + | test_grep ! "incorrect checksum" err | |
| 587 | + | ' | |
| 588 | + | ||
| 576 | 589 | test_expect_success 'setup for v1-specific fsck tests' ' | |
| 577 | 590 | git -c midx.version=1 multi-pack-index write | |
| 578 | 591 | ' | |
modified t/t5325-reverse-index.sh
| @@ -204,4 +204,12 @@ test_expect_success 'fsck catches invalid header: hash function' ' | |||
| 204 | 204 | "reverse-index file .* has unsupported hash id" | |
| 205 | 205 | ' | |
| 206 | 206 | ||
| 207 | + | test_expect_success 'fsck --no-full checks rev-index, --connectivity-only does not' ' | |
| 208 | + | test_must_fail git -C corrupt fsck --no-full 2>err && | |
| 209 | + | test_grep "has unsupported hash id" err && | |
| 210 | + | ||
| 211 | + | git -C corrupt fsck --connectivity-only 2>err && | |
| 212 | + | test_grep ! "has unsupported hash id" err | |
| 213 | + | ' | |
| 214 | + | ||
| 207 | 215 | test_done | |
modified t/t5326-multi-pack-bitmaps.sh
| @@ -498,7 +498,15 @@ test_expect_success 'git fsck correctly identifies good and bad bitmaps' ' | |||
| 498 | 498 | corrupt_file "$packbitmap" && | |
| 499 | 499 | test_must_fail git fsck 2>err && | |
| 500 | 500 | test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && | |
| 501 | - | test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err | |
| 501 | + | test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err && | |
| 502 | + | ||
| 503 | + | # The bitmap checks are performed with "--no-full", but not with | |
| 504 | + | # "--connectivity-only". | |
| 505 | + | test_must_fail git fsck --no-full 2>err && | |
| 506 | + | test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && | |
| 507 | + | test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err && | |
| 508 | + | git fsck --connectivity-only 2>err && | |
| 509 | + | test_grep ! "invalid checksum" err | |
| 502 | 510 | ' | |
| 503 | 511 | ||
| 504 | 512 | test_expect_success 'corrupt MIDX with bitmap causes fallback' ' | |
modified t/t6132-pathspec-exclude.sh
| @@ -183,6 +183,24 @@ EOF | |||
| 183 | 183 | test_cmp expect actual | |
| 184 | 184 | ' | |
| 185 | 185 | ||
| 186 | + | test_expect_success 'negative pathspec shorter than positive pathspec prefix' ' | |
| 187 | + | git ls-files -- sub/sub/ ":(exclude)sub2" >actual && | |
| 188 | + | cat <<-\EOF >expect && | |
| 189 | + | sub/sub/file | |
| 190 | + | sub/sub/sub/file | |
| 191 | + | EOF | |
| 192 | + | test_cmp expect actual | |
| 193 | + | ' | |
| 194 | + | ||
| 195 | + | test_expect_success 'exclude is matched against the full path' ' | |
| 196 | + | git ls-files -- sub/sub/ ":(exclude)zzzzzzz" >actual && | |
| 197 | + | cat <<-\EOF >expect && | |
| 198 | + | sub/sub/file | |
| 199 | + | sub/sub/sub/file | |
| 200 | + | EOF | |
| 201 | + | test_cmp expect actual | |
| 202 | + | ' | |
| 203 | + | ||
| 186 | 204 | test_expect_success 'multiple exclusions' ' | |
| 187 | 205 | git ls-files -- ":^*/file2" ":^sub2" >actual && | |
| 188 | 206 | cat <<-\EOF >expect && | |
modified t/unit-tests/u-dir.c
| @@ -45,3 +45,31 @@ void test_dir__within_depth(void) | |||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | 47 | } | |
| 48 | + | ||
| 49 | + | void test_dir__common_prefix_skips_excluded_pathspec_items(void) | |
| 50 | + | { | |
| 51 | + | struct pathspec_item items[] = { | |
| 52 | + | { | |
| 53 | + | .match = "unrelated/path", | |
| 54 | + | .magic = PATHSPEC_EXCLUDE, | |
| 55 | + | .nowildcard_len = 14, | |
| 56 | + | }, | |
| 57 | + | { | |
| 58 | + | .match = "foo/bar", | |
| 59 | + | .nowildcard_len = 7, | |
| 60 | + | }, | |
| 61 | + | { | |
| 62 | + | .match = "foo/baz", | |
| 63 | + | .nowildcard_len = 7, | |
| 64 | + | }, | |
| 65 | + | }; | |
| 66 | + | struct pathspec pathspec = { | |
| 67 | + | .nr = ARRAY_SIZE(items), | |
| 68 | + | .magic = PATHSPEC_EXCLUDE, | |
| 69 | + | .items = items, | |
| 70 | + | }; | |
| 71 | + | char *prefix = common_prefix(&pathspec); | |
| 72 | + | ||
| 73 | + | cl_assert_equal_s(prefix, "foo/"); | |
| 74 | + | free(prefix); | |
| 75 | + | } | |
modified wt-status.h
| @@ -41,7 +41,7 @@ enum commit_whence { | |||
| 41 | 41 | FROM_MERGE, /* commit came from merge */ | |
| 42 | 42 | FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ | |
| 43 | 43 | FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ | |
| 44 | - | FROM_REBASE_NOW_EMPTY /* rebase applied a pick that became empty */ | |
| 44 | + | FROM_REBASE_PICK /* commit came from a pick/reword/edit */ | |
| 45 | 45 | }; | |
| 46 | 46 | ||
| 47 | 47 | static inline int is_from_cherry_pick(enum commit_whence whence) | |
| @@ -50,9 +50,9 @@ static inline int is_from_cherry_pick(enum commit_whence whence) | |||
| 50 | 50 | whence == FROM_CHERRY_PICK_MULTI; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | - | static inline int is_from_rebase_now_empty(enum commit_whence whence) | |
| 53 | + | static inline int is_from_rebase(enum commit_whence whence) | |
| 54 | 54 | { | |
| 55 | - | return whence == FROM_REBASE_NOW_EMPTY; | |
| 55 | + | return whence == FROM_REBASE_PICK; | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | 58 | struct wt_status_change_data { | |