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>
Jiang Xin committed
Jul 25, 2012 at 22:53 UTC
c7108bf9ed72403bdf6274bf46263731590bffcf
5 files changed
+53
-42
git-am.sh
+3
-3
@@ -102,9 +102,9 @@ stop_here_user_resolve () {
102
printf '%s\n' "$resolvemsg"
103
stop_here $1
104
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\"."
108
109
stop_here $1
110
}
git-rebase.sh
+34
-30
@@ -65,6 +65,7 @@ abort! abort and check out the original branch
65
skip! skip current patch and continue
66
"
67
. git-sh-setup
68
+. git-sh-i18n
69
set_reflog_action rebase
70
require_work_tree_exists
71
cd_to_toplevel
@@ -73,9 +74,9 @@ LF='
74
'
75
ok_to_skip_pre_rebase=
76
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".')
80
"
81
unset onto
82
cmd=
@@ -161,7 +162,7 @@ move_to_original_branch () {
162
git symbolic-ref \
163
-m "rebase finished: returning to $head_name" \
164
HEAD $head_name ||
164
- die "Could not move back to $head_name"
165
+ die "$(gettext "Could not move back to $head_name")"
166
;;
167
esac
168
}
@@ -180,12 +181,12 @@ run_pre_rebase_hook () {
181
test -x "$GIT_DIR/hooks/pre-rebase"
182
then
183
"$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.")"
185
fi
186
}
187
188
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.")"
190
191
if test -d "$apply_dir"
192
then
@@ -316,12 +317,12 @@ test $# -gt 2 && usage
317
if test -n "$cmd" &&
318
test "$interactive_rebase" != explicit
319
then
319
- die "--exec option must be used with --interactive option"
320
+ die "$(gettext -- "--exec option must be used with --interactive option")"
321
fi
322
323
if test -n "$action"
324
then
324
- test -z "$in_progress" && die "No rebase in progress?"
325
+ test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
326
# Only interactive rebase uses detailed reflog messages
327
if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
328
then
@@ -334,11 +335,11 @@ case "$action" in
335
continue)
336
# Sanity check
337
git rev-parse --verify HEAD >/dev/null ||
337
- die "Cannot read HEAD"
338
+ die "$(gettext "Cannot read HEAD")"
339
git update-index --ignore-submodules --refresh &&
340
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")"
343
exit 1
344
}
345
read_basic_state
@@ -355,7 +356,7 @@ abort)
356
case "$head_name" in
357
refs/*)
358
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")"
360
;;
361
esac
362
output git reset --hard $orig_head
@@ -367,15 +368,18 @@ esac
368
# Make sure no rebase is in progress
369
if test -n "$in_progress"
370
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
377
case, please try
374
- git rebase (--continue | --abort | --skip)
378
+ $cmd_live_rebase
379
If that is not the case, please
376
- rm -fr '"$state_dir"'
380
+ $cmd_clear_stale_rebase
381
and run me again. I am stopping in case you still have something
378
-valuable there.'
382
+valuable there.')"
383
fi
384
385
if test -n "$rebase_root" && test -z "$onto"
@@ -413,7 +417,7 @@ then
417
;;
418
esac
419
upstream=`git rev-parse --verify "${upstream_name}^0"` ||
416
- die "invalid upstream $upstream_name"
420
+ die "$(eval_gettext "invalid upstream \$upstream_name")"
421
upstream_arg="$upstream_name"
422
else
423
if test -z "$onto"
@@ -437,19 +441,19 @@ case "$onto_name" in
441
then
442
case "$onto" in
443
?*"$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")"
445
;;
446
'')
443
- die "$onto_name: there is no merge base"
447
+ die "$(eval_gettext "\$onto_name: there is no merge base")"
448
;;
449
esac
450
else
447
- die "$onto_name: there is no merge base"
451
+ die "$(eval_gettext "\$onto_name: there is no merge base")"
452
fi
453
;;
454
*)
455
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")"
457
;;
458
esac
459
@@ -472,7 +476,7 @@ case "$#" in
476
then
477
head_name="detached HEAD"
478
else
475
- die "fatal: no such branch: $1"
479
+ die "$(eval_gettext "fatal: no such branch: \$branch_name")"
480
fi
481
;;
482
0)
@@ -492,7 +496,7 @@ case "$#" in
496
;;
497
esac
498
495
-require_clean_work_tree "rebase" "Please commit or stash them."
499
+require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")"
500
501
# Now we are rebasing commits $upstream..$orig_head (or with --root,
502
# everything leading up to $orig_head) on top of $onto
@@ -510,10 +514,10 @@ then
514
then
515
# Lazily switch to the target branch if needed...
516
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.")"
518
exit 0
519
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.")"
521
fi
522
fi
523
@@ -524,7 +528,7 @@ if test -n "$diffstat"
528
then
529
if test -n "$verbose"
530
then
527
- echo "Changes from $mb to $onto:"
531
+ echo "$(eval_gettext "Changes from \$mb to \$onto:")"
532
fi
533
# We want color (if set), but no pager
534
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
@@ -533,7 +537,7 @@ fi
537
test "$type" = interactive && run_specific_rebase
538
539
# 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...")"
541
git checkout -q "$onto^0" || die "could not detach HEAD"
542
git update-ref ORIG_HEAD $orig_head
543
@@ -541,7 +545,7 @@ git update-ref ORIG_HEAD $orig_head
545
# we just fast-forwarded.
546
if test "$mb" = "$orig_head"
547
then
544
- say "Fast-forwarded $branch_name to $onto_name."
548
+ say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")"
549
move_to_original_branch
550
exit 0
551
fi
t/t0201-gettext-fallbacks.sh
+4
-4
@@ -51,16 +51,16 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v
51
test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces' '
52
cmdline="git am" &&
53
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
56
test_i18ncmp expect actual
57
'
58
59
test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces and quotes' '
60
cmdline="git am" &&
61
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
64
test_i18ncmp expect actual
65
'
66
t/t3400-rebase.sh
+4
-4
@@ -68,24 +68,24 @@ test_expect_success 'rebase against master' '
68
69
test_expect_success 'rebase against master twice' '
70
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
72
'
73
74
test_expect_success 'rebase against master twice with --force' '
75
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
77
'
78
79
test_expect_success 'rebase against master twice from another branch' '
80
git checkout my-topic-branch^ &&
81
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
83
'
84
85
test_expect_success 'rebase fast-forward to master' '
86
git checkout my-topic-branch^ &&
87
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
89
'
90
91
test_expect_success 'the rebase operation should not have destroyed author information' '
t/t3406-rebase-message.sh
+8
-1
@@ -62,9 +62,16 @@ test_expect_success 'rebase -n overrides config rebase.stat config' '
62
! grep "^ fileX | *1 +$" diffstat.txt
63
'
64
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.
72
test_expect_success 'rebase --onto outputs the invalid ref' '
73
test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
67
- grep "invalid-ref" err
74
+ test_i18ngrep "invalid-ref" err
75
'
76
77
test_done