Skip to content

Commit c7108bf

Browse files
jiangxingitster
authored andcommitted
i18n: rebase: mark messages for translation
Mark messages in git-rebase.sh for translation. While doing this Jonathan noticed that the comma usage and sentence structure of the resolvemsg was not quite right, so correct that and its cousins in git-am.sh and t/t0201-gettext-fallbacks.sh at the same time. Some tests would start to fail with GETTEXT_POISON turned on after this update. Use test_i18ncmp and test_i18ngrep where appropriate to mark strings that should only be checked in the C locale output to avoid such issues. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Reviewed-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c2d140d commit c7108bf

File tree

5 files changed

+53
-42
lines changed

5 files changed

+53
-42
lines changed

git-am.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ stop_here_user_resolve () {
102102
printf '%s\n' "$resolvemsg"
103103
stop_here $1
104104
fi
105-
eval_gettextln "When you have resolved this problem run \"\$cmdline --resolved\".
106-
If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
107-
To restore the original branch and stop patching run \"\$cmdline --abort\"."
105+
eval_gettextln "When you have resolved this problem, run \"\$cmdline --resolved\".
106+
If you prefer to skip this patch, run \"\$cmdline --skip\" instead.
107+
To restore the original branch and stop patching, run \"\$cmdline --abort\"."
108108

109109
stop_here $1
110110
}

git-rebase.sh

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ abort! abort and check out the original branch
6565
skip! skip current patch and continue
6666
"
6767
. git-sh-setup
68+
. git-sh-i18n
6869
set_reflog_action rebase
6970
require_work_tree_exists
7071
cd_to_toplevel
@@ -73,9 +74,9 @@ LF='
7374
'
7475
ok_to_skip_pre_rebase=
7576
resolvemsg="
76-
When you have resolved this problem run \"git rebase --continue\".
77-
If you would prefer to skip this patch, instead run \"git rebase --skip\".
78-
To check out the original branch and stop rebasing run \"git rebase --abort\".
77+
$(gettext 'When you have resolved this problem, run "git rebase --continue".
78+
If you prefer to skip this patch, run "git rebase --skip" instead.
79+
To check out the original branch and stop rebasing, run "git rebase --abort".')
7980
"
8081
unset onto
8182
cmd=
@@ -161,7 +162,7 @@ move_to_original_branch () {
161162
git symbolic-ref \
162163
-m "rebase finished: returning to $head_name" \
163164
HEAD $head_name ||
164-
die "Could not move back to $head_name"
165+
die "$(gettext "Could not move back to $head_name")"
165166
;;
166167
esac
167168
}
@@ -180,12 +181,12 @@ run_pre_rebase_hook () {
180181
test -x "$GIT_DIR/hooks/pre-rebase"
181182
then
182183
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
183-
die "The pre-rebase hook refused to rebase."
184+
die "$(gettext "The pre-rebase hook refused to rebase.")"
184185
fi
185186
}
186187

187188
test -f "$apply_dir"/applying &&
188-
die 'It looks like git-am is in progress. Cannot rebase.'
189+
die "$(gettext "It looks like git-am is in progress. Cannot rebase.")"
189190

190191
if test -d "$apply_dir"
191192
then
@@ -316,12 +317,12 @@ test $# -gt 2 && usage
316317
if test -n "$cmd" &&
317318
test "$interactive_rebase" != explicit
318319
then
319-
die "--exec option must be used with --interactive option"
320+
die "$(gettext -- "--exec option must be used with --interactive option")"
320321
fi
321322

322323
if test -n "$action"
323324
then
324-
test -z "$in_progress" && die "No rebase in progress?"
325+
test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
325326
# Only interactive rebase uses detailed reflog messages
326327
if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
327328
then
@@ -334,11 +335,11 @@ case "$action" in
334335
continue)
335336
# Sanity check
336337
git rev-parse --verify HEAD >/dev/null ||
337-
die "Cannot read HEAD"
338+
die "$(gettext "Cannot read HEAD")"
338339
git update-index --ignore-submodules --refresh &&
339340
git diff-files --quiet --ignore-submodules || {
340-
echo "You must edit all merge conflicts and then"
341-
echo "mark them as resolved using git add"
341+
echo "$(gettext "You must edit all merge conflicts and then
342+
mark them as resolved using git add")"
342343
exit 1
343344
}
344345
read_basic_state
@@ -355,7 +356,7 @@ abort)
355356
case "$head_name" in
356357
refs/*)
357358
git symbolic-ref -m "rebase: aborting" HEAD $head_name ||
358-
die "Could not move back to $head_name"
359+
die "$(eval_gettext "Could not move back to \$head_name")"
359360
;;
360361
esac
361362
output git reset --hard $orig_head
@@ -367,15 +368,18 @@ esac
367368
# Make sure no rebase is in progress
368369
if test -n "$in_progress"
369370
then
370-
die '
371-
It seems that there is already a '"${state_dir##*/}"' directory, and
372-
I wonder if you are in the middle of another rebase. If that is the
371+
state_dir_base=${state_dir##*/}
372+
cmd_live_rebase="git rebase (--continue | --abort | --skip)"
373+
cmd_clear_stale_rebase="rm -fr \"$state_dir\""
374+
die "
375+
$(eval_gettext 'It seems that there is already a $state_dir_base directory, and
376+
I wonder if you ware in the middle of another rebase. If that is the
373377
case, please try
374-
git rebase (--continue | --abort | --skip)
378+
$cmd_live_rebase
375379
If that is not the case, please
376-
rm -fr '"$state_dir"'
380+
$cmd_clear_stale_rebase
377381
and run me again. I am stopping in case you still have something
378-
valuable there.'
382+
valuable there.')"
379383
fi
380384

381385
if test -n "$rebase_root" && test -z "$onto"
@@ -413,7 +417,7 @@ then
413417
;;
414418
esac
415419
upstream=`git rev-parse --verify "${upstream_name}^0"` ||
416-
die "invalid upstream $upstream_name"
420+
die "$(eval_gettext "invalid upstream \$upstream_name")"
417421
upstream_arg="$upstream_name"
418422
else
419423
if test -z "$onto"
@@ -437,19 +441,19 @@ case "$onto_name" in
437441
then
438442
case "$onto" in
439443
?*"$LF"?*)
440-
die "$onto_name: there are more than one merge bases"
444+
die "$(eval_gettext "\$onto_name: there are more than one merge bases")"
441445
;;
442446
'')
443-
die "$onto_name: there is no merge base"
447+
die "$(eval_gettext "\$onto_name: there is no merge base")"
444448
;;
445449
esac
446450
else
447-
die "$onto_name: there is no merge base"
451+
die "$(eval_gettext "\$onto_name: there is no merge base")"
448452
fi
449453
;;
450454
*)
451455
onto=$(git rev-parse --verify "${onto_name}^0") ||
452-
die "Does not point to a valid commit: $onto_name"
456+
die "$(eval_gettext "Does not point to a valid commit: \$onto_name")"
453457
;;
454458
esac
455459

@@ -472,7 +476,7 @@ case "$#" in
472476
then
473477
head_name="detached HEAD"
474478
else
475-
die "fatal: no such branch: $1"
479+
die "$(eval_gettext "fatal: no such branch: \$branch_name")"
476480
fi
477481
;;
478482
0)
@@ -492,7 +496,7 @@ case "$#" in
492496
;;
493497
esac
494498

495-
require_clean_work_tree "rebase" "Please commit or stash them."
499+
require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")"
496500

497501
# Now we are rebasing commits $upstream..$orig_head (or with --root,
498502
# everything leading up to $orig_head) on top of $onto
@@ -510,10 +514,10 @@ then
510514
then
511515
# Lazily switch to the target branch if needed...
512516
test -z "$switch_to" || git checkout "$switch_to" --
513-
say "Current branch $branch_name is up to date."
517+
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
514518
exit 0
515519
else
516-
say "Current branch $branch_name is up to date, rebase forced."
520+
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
517521
fi
518522
fi
519523

@@ -524,7 +528,7 @@ if test -n "$diffstat"
524528
then
525529
if test -n "$verbose"
526530
then
527-
echo "Changes from $mb to $onto:"
531+
echo "$(eval_gettext "Changes from \$mb to \$onto:")"
528532
fi
529533
# We want color (if set), but no pager
530534
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
@@ -533,15 +537,15 @@ fi
533537
test "$type" = interactive && run_specific_rebase
534538

535539
# Detach HEAD and reset the tree
536-
say "First, rewinding head to replay your work on top of it..."
540+
say "$(gettext "First, rewinding head to replay your work on top of it...")"
537541
git checkout -q "$onto^0" || die "could not detach HEAD"
538542
git update-ref ORIG_HEAD $orig_head
539543

540544
# If the $onto is a proper descendant of the tip of the branch, then
541545
# we just fast-forwarded.
542546
if test "$mb" = "$orig_head"
543547
then
544-
say "Fast-forwarded $branch_name to $onto_name."
548+
say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")"
545549
move_to_original_branch
546550
exit 0
547551
fi

t/t0201-gettext-fallbacks.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v
5151
test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces' '
5252
cmdline="git am" &&
5353
export cmdline;
54-
printf "When you have resolved this problem run git am --resolved." >expect &&
55-
eval_gettext "When you have resolved this problem run \$cmdline --resolved." >actual
54+
printf "When you have resolved this problem, run git am --resolved." >expect &&
55+
eval_gettext "When you have resolved this problem, run \$cmdline --resolved." >actual
5656
test_i18ncmp expect actual
5757
'
5858

5959
test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces and quotes' '
6060
cmdline="git am" &&
6161
export cmdline;
62-
printf "When you have resolved this problem run \"git am --resolved\"." >expect &&
63-
eval_gettext "When you have resolved this problem run \"\$cmdline --resolved\"." >actual
62+
printf "When you have resolved this problem, run \"git am --resolved\"." >expect &&
63+
eval_gettext "When you have resolved this problem, run \"\$cmdline --resolved\"." >actual
6464
test_i18ncmp expect actual
6565
'
6666

t/t3400-rebase.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,24 @@ test_expect_success 'rebase against master' '
6868

6969
test_expect_success 'rebase against master twice' '
7070
git rebase master >out &&
71-
grep "Current branch my-topic-branch is up to date" out
71+
test_i18ngrep "Current branch my-topic-branch is up to date" out
7272
'
7373

7474
test_expect_success 'rebase against master twice with --force' '
7575
git rebase --force-rebase master >out &&
76-
grep "Current branch my-topic-branch is up to date, rebase forced" out
76+
test_i18ngrep "Current branch my-topic-branch is up to date, rebase forced" out
7777
'
7878

7979
test_expect_success 'rebase against master twice from another branch' '
8080
git checkout my-topic-branch^ &&
8181
git rebase master my-topic-branch >out &&
82-
grep "Current branch my-topic-branch is up to date" out
82+
test_i18ngrep "Current branch my-topic-branch is up to date" out
8383
'
8484

8585
test_expect_success 'rebase fast-forward to master' '
8686
git checkout my-topic-branch^ &&
8787
git rebase my-topic-branch >out &&
88-
grep "Fast-forwarded HEAD to my-topic-branch" out
88+
test_i18ngrep "Fast-forwarded HEAD to my-topic-branch" out
8989
'
9090

9191
test_expect_success 'the rebase operation should not have destroyed author information' '

t/t3406-rebase-message.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ test_expect_success 'rebase -n overrides config rebase.stat config' '
6262
! grep "^ fileX | *1 +$" diffstat.txt
6363
'
6464

65+
# Output to stderr:
66+
#
67+
# "Does not point to a valid commit: invalid-ref"
68+
#
69+
# NEEDSWORK: This "grep" is fine in real non-C locales, but
70+
# GETTEXT_POISON poisons the refname along with the enclosing
71+
# error message.
6572
test_expect_success 'rebase --onto outputs the invalid ref' '
6673
test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
67-
grep "invalid-ref" err
74+
test_i18ngrep "invalid-ref" err
6875
'
6976

7077
test_done

0 commit comments

Comments
 (0)