Compare

d306f3f0d5bac2f59a47ccf2cff2f07da95c2ba9..b758bc5bc4b35db0bc807d3ab33cd492e86d6b4d

l10n: AGENTS.md: fix counter fallbacks

Reading a counter with "cmd || echo 0" breaks whenever the command
writes output but still exits non-zero. On zero matches, "grep -c"
prints 0 and exits with status 1, so the command substitution
captured two zeros and the arithmetic that follows failed with a
syntax error instead of evaluating to 0.

Fix by ignoring the exit status with "|| true" and defaulting the
empty value with "${VAR:-0}". Apply this to ENTRY_COUNT in both
l10n_one_batch() and review_one_batch(), and to the BATCH counter
read from po/review-batch.txt, which used the same fragile fallback.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>

Jiang Xin <worldhello.net@gmail.com> · 2026-09-17 07:21 UTC

Browse files
17 files changed, +134 −344
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 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 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
@@ -543,9 +543,9 @@ step 8 after step 6.
543 543 DONE_PO="po/l10n-done.po"
544 544 rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO"
545 545
546 - ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0)
546 + ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true)
547 + ENTRY_COUNT=${ENTRY_COUNT:-0}
547 548 ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0))
548 -
549 549 if test "$ENTRY_COUNT" -gt $min_batch_size
550 550 then
551 551 if test "$ENTRY_COUNT" -gt $((min_batch_size * 8))
@@ -772,7 +772,8 @@ already present.
772 772 cp "$INPUT_PO" "$PENDING"
773 773 fi
774 774
775 - ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0)
775 + ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true)
776 + ENTRY_COUNT=${ENTRY_COUNT:-0}
776 777 ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0))
777 778 if test "$ENTRY_COUNT" -eq 0
778 779 then
@@ -796,7 +797,8 @@ already present.
796 797 NUM=$ENTRY_COUNT
797 798 fi
798 799
799 - BATCH=$(cat "$BATCH_FILE" 2>/dev/null || echo 0)
800 + BATCH=$(cat "$BATCH_FILE" 2>/dev/null || true)
801 + BATCH=${BATCH:-0}
800 802 BATCH=$((BATCH + 1))
801 803 echo "$BATCH" >"$BATCH_FILE"
802 804
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 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 {