Compare

f0ef1b96a076d08dc972a8d2cb0d1cfd60931eb6..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

Browse files
23 files changed, +262 −472
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
@@ -560,6 +560,11 @@ Performance, Internal Implementation, Development Support etc.
560 560 backend-specific object source layers, making them pluggable for
561 561 different object storage formats.
562 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 +
563 568
564 569 Fixes since v2.55
565 570 -----------------
@@ -862,12 +867,6 @@ Fixes since v2.55
862 867 Additionally, an obsolete variable used for retired Azure Pipelines
863 868 environments has been removed.
864 869
865 - * Teach 'am', 'revert', and 'rebase' that running 'commit --amend' or a
866 - partial 'commit <paths>' makes no sense during operations that stop
867 - and return control to the user to resolve conflicts left in the
868 - working tree, just like 'cherry-pick' and 'merge' do.
869 - (merge cc499d40e5 en/no-amend-during-conflicts later to maint).
870 -
871 870 * The error path in 'git submodule--helper' has been updated to plug a
872 871 memory leak when a repository handle could not be obtained,
873 872 leveraging an updated idempotent repo_clear().
@@ -883,7 +882,8 @@ Fixes since v2.55
883 882 (merge ec602484bd kh/doc-datamodel later to maint).
884 883
885 884 * Running "git history" in a corrupt repository can (unsurprisingly)
886 - 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.
887 887 (merge 76621488e8 jc/history-missing-tree-errorfix later to maint).
888 888
889 889 * The development helper script to lint gitlink references in the
@@ -897,6 +897,14 @@ Fixes since v2.55
897 897 branch-switch message.
898 898 (merge 2ba77ea828 hn/checkout-m-autostash-refine later to maint).
899 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 +
900 908 * Other code cleanup, docfix, build fix, etc.
901 909 (merge 026636128f ss/submittingpatches-typofix later to maint).
902 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/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 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/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/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 {