i18n: rebase-interactive: mark strings for translation

Mark strings in git-rebase--interactive.sh for translation. There is no
need to source git-sh-i18n since git-rebase.sh already does so.

Add git-rebase--interactive.sh to LOCALIZED_SH in Makefile in order to
enable extracting strings marked for translation by xgettext.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Vasco Almeida 2016-06-17 20:21:03 +00:00 committed by Junio C Hamano
parent d323c6b641
commit 9588c52b75
2 changed files with 102 additions and 90 deletions

View File

@ -2064,6 +2064,7 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H) LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
LOCALIZED_SH = $(SCRIPT_SH) LOCALIZED_SH = $(SCRIPT_SH)
LOCALIZED_SH += git-parse-remote.sh LOCALIZED_SH += git-parse-remote.sh
LOCALIZED_SH += git-rebase--interactive.sh
LOCALIZED_SH += git-sh-setup.sh LOCALIZED_SH += git-sh-setup.sh
LOCALIZED_PERL = $(SCRIPT_PERL) LOCALIZED_PERL = $(SCRIPT_PERL)

View File

@ -128,7 +128,7 @@ mark_action_done () {
if test "$last_count" != "$new_count" if test "$last_count" != "$new_count"
then then
last_count=$new_count last_count=$new_count
printf "Rebasing (%d/%d)\r" $new_count $total eval_gettext "Rebasing (\$new_count/\$total)"; printf "\r"
test -z "$verbose" || echo test -z "$verbose" || echo
fi fi
} }
@ -201,13 +201,14 @@ exit_with_patch () {
make_patch $1 make_patch $1
git rev-parse --verify HEAD > "$amend" git rev-parse --verify HEAD > "$amend"
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
warn "You can amend the commit now, with" warn "$(eval_gettext "\
warn You can amend the commit now, with
warn " git commit --amend $gpg_sign_opt_quoted"
warn git commit --amend \$gpg_sign_opt_quoted
warn "Once you are satisfied with your changes, run"
warn Once you are satisfied with your changes, run
warn " git rebase --continue"
git rebase --continue")"
warn warn
exit $2 exit $2
} }
@ -222,10 +223,12 @@ has_action () {
} }
is_empty_commit() { is_empty_commit() {
tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null || tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null) || {
die "$1: not a commit that can be picked") sha1=$1
ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null || die "$(eval_gettext "\$sha1: not a commit that can be picked")"
ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904) }
ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null) ||
ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
test "$tree" = "$ptree" test "$tree" = "$ptree"
} }
@ -261,7 +264,7 @@ pick_one () {
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
case "$force_rebase" in '') ;; ?*) ff= ;; esac case "$force_rebase" in '') ;; ?*) ff= ;; esac
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1" output git rev-parse --verify $sha1 || die "$(eval_gettext "Invalid commit name: \$sha1")"
if is_empty_commit "$sha1" if is_empty_commit "$sha1"
then then
@ -303,7 +306,7 @@ pick_one_preserving_merges () {
git rev-parse HEAD > "$rewritten"/$current_commit git rev-parse HEAD > "$rewritten"/$current_commit
done <"$state_dir"/current-commit done <"$state_dir"/current-commit
rm "$state_dir"/current-commit || rm "$state_dir"/current-commit ||
die "Cannot write current commit's replacement sha1" die "$(gettext "Cannot write current commit's replacement sha1")"
fi fi
fi fi
@ -355,9 +358,9 @@ pick_one_preserving_merges () {
done done
case $fast_forward in case $fast_forward in
t) t)
output warn "Fast-forward to $sha1" output warn "$(eval_gettext "Fast-forward to \$sha1")"
output git reset --hard $sha1 || output git reset --hard $sha1 ||
die "Cannot fast-forward to $sha1" die "$(eval_gettext "Cannot fast-forward to \$sha1")"
;; ;;
f) f)
first_parent=$(expr "$new_parents" : ' \([^ ]*\)') first_parent=$(expr "$new_parents" : ' \([^ ]*\)')
@ -366,12 +369,12 @@ pick_one_preserving_merges () {
then then
# detach HEAD to current parent # detach HEAD to current parent
output git checkout $first_parent 2> /dev/null || output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent" die "$(eval_gettext "Cannot move HEAD to \$first_parent")"
fi fi
case "$new_parents" in case "$new_parents" in
' '*' '*) ' '*' '*)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1" test "a$1" = a-n && die "$(eval_gettext "Refusing to squash a merge: \$sha1")"
# redo merge # redo merge
author_script_content=$(get_author_ident_from_commit $sha1) author_script_content=$(get_author_ident_from_commit $sha1)
@ -385,7 +388,7 @@ pick_one_preserving_merges () {
$merge_args $strategy_args -m "$msg_content" $new_parents' $merge_args $strategy_args -m "$msg_content" $new_parents'
then then
printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
die_with_patch $sha1 "Error redoing merge $sha1" die_with_patch $sha1 "$(eval_gettext "Error redoing merge \$sha1")"
fi fi
echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list" echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
;; ;;
@ -393,7 +396,7 @@ pick_one_preserving_merges () {
output eval git cherry-pick \ output eval git cherry-pick \
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \ ${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
"$strategy_args" "$@" || "$strategy_args" "$@" ||
die_with_patch $sha1 "Could not pick $sha1" die_with_patch $sha1 "$(eval_gettext "Could not pick \$sha1")"
;; ;;
esac esac
;; ;;
@ -460,12 +463,14 @@ peek_next_command () {
# messages, effectively causing the combined commit to be used as the # messages, effectively causing the combined commit to be used as the
# new basis for any further squash/fixups. Args: sha1 rest # new basis for any further squash/fixups. Args: sha1 rest
die_failed_squash() { die_failed_squash() {
sha1=$1
rest=$2
mv "$squash_msg" "$msg" || exit mv "$squash_msg" "$msg" || exit
rm -f "$fixup_msg" rm -f "$fixup_msg"
cp "$msg" "$GIT_DIR"/MERGE_MSG || exit cp "$msg" "$GIT_DIR"/MERGE_MSG || exit
warn warn
warn "Could not apply $1... $2" warn "$(eval_gettext "Could not apply \$sha1... \$rest")"
die_with_patch $1 "" die_with_patch $sha1 ""
} }
flush_rewritten_pending() { flush_rewritten_pending() {
@ -489,6 +494,8 @@ record_in_rewritten() {
} }
do_pick () { do_pick () {
sha1=$1
rest=$2
if test "$(git rev-parse HEAD)" = "$squash_onto" if test "$(git rev-parse HEAD)" = "$squash_onto"
then then
# Set the correct commit message and author info on the # Set the correct commit message and author info on the
@ -500,15 +507,15 @@ do_pick () {
# resolve before manually running git commit --amend then git # resolve before manually running git commit --amend then git
# rebase --continue. # rebase --continue.
git commit --allow-empty --allow-empty-message --amend \ git commit --allow-empty --allow-empty-message --amend \
--no-post-rewrite -n -q -C $1 && --no-post-rewrite -n -q -C $sha1 &&
pick_one -n $1 && pick_one -n $sha1 &&
git commit --allow-empty --allow-empty-message \ git commit --allow-empty --allow-empty-message \
--amend --no-post-rewrite -n -q -C $1 \ --amend --no-post-rewrite -n -q -C $sha1 \
${gpg_sign_opt:+"$gpg_sign_opt"} || ${gpg_sign_opt:+"$gpg_sign_opt"} ||
die_with_patch $1 "Could not apply $1... $2" die_with_patch $sha1 "$(eval_gettext "Could not apply \$sha1... \$rest")"
else else
pick_one $1 || pick_one $sha1 ||
die_with_patch $1 "Could not apply $1... $2" die_with_patch $sha1 "$(eval_gettext "Could not apply \$sha1... \$rest")"
fi fi
} }
@ -536,10 +543,11 @@ do_next () {
mark_action_done mark_action_done
do_pick $sha1 "$rest" do_pick $sha1 "$rest"
git commit --amend --no-post-rewrite ${gpg_sign_opt:+"$gpg_sign_opt"} || { git commit --amend --no-post-rewrite ${gpg_sign_opt:+"$gpg_sign_opt"} || {
warn "Could not amend commit after successfully picking $sha1... $rest" warn "$(eval_gettext "\
warn "This is most likely due to an empty commit message, or the pre-commit hook" Could not amend commit after successfully picking \$sha1... \$rest
warn "failed. If the pre-commit hook failed, you may need to resolve the issue before" This is most likely due to an empty commit message, or the pre-commit hook
warn "you are able to reword the commit." failed. If the pre-commit hook failed, you may need to resolve the issue before
you are able to reword the commit.")"
exit_with_patch $sha1 1 exit_with_patch $sha1 1
} }
record_in_rewritten $sha1 record_in_rewritten $sha1
@ -550,7 +558,7 @@ do_next () {
mark_action_done mark_action_done
do_pick $sha1 "$rest" do_pick $sha1 "$rest"
sha1_abbrev=$(git rev-parse --short $sha1) sha1_abbrev=$(git rev-parse --short $sha1)
warn "Stopped at $sha1_abbrev... $rest" warn "$(eval_gettext "Stopped at \$sha1_abbrev... \$rest")"
exit_with_patch $sha1 0 exit_with_patch $sha1 0
;; ;;
squash|s|fixup|f) squash|s|fixup|f)
@ -565,7 +573,7 @@ do_next () {
comment_for_reflog $squash_style comment_for_reflog $squash_style
test -f "$done" && has_action "$done" || test -f "$done" && has_action "$done" ||
die "Cannot '$squash_style' without a previous commit" die "$(eval_gettext "Cannot '\$squash_style' without a previous commit")"
mark_action_done mark_action_done
update_squash_messages $squash_style $sha1 update_squash_messages $squash_style $sha1
@ -607,7 +615,7 @@ do_next () {
x|"exec") x|"exec")
read -r command rest < "$todo" read -r command rest < "$todo"
mark_action_done mark_action_done
printf 'Executing: %s\n' "$rest" eval_gettextln "Executing: \$rest"
"${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution "${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution
status=$? status=$?
# Run in subshell because require_clean_work_tree can die. # Run in subshell because require_clean_work_tree can die.
@ -615,13 +623,14 @@ do_next () {
(require_clean_work_tree "rebase" 2>/dev/null) || dirty=t (require_clean_work_tree "rebase" 2>/dev/null) || dirty=t
if test "$status" -ne 0 if test "$status" -ne 0
then then
warn "Execution failed: $rest" warn "$(eval_gettext "Execution failed: \$rest")"
test "$dirty" = f || test "$dirty" = f ||
warn "and made changes to the index and/or the working tree" warn "$(gettext "and made changes to the index and/or the working tree")"
warn "You can fix the problem, and then run" warn "$(gettext "\
warn You can fix the problem, and then run
warn " git rebase --continue"
git rebase --continue")"
warn warn
if test $status -eq 127 # command not found if test $status -eq 127 # command not found
then then
@ -630,18 +639,20 @@ do_next () {
exit "$status" exit "$status"
elif test "$dirty" = t elif test "$dirty" = t
then then
warn "Execution succeeded: $rest" # TRANSLATORS: after these lines is a command to be issued by the user
warn "but left changes to the index and/or the working tree" warn "$(eval_gettext "\
warn "Commit or stash your changes, and then run" Execution succeeded: \$rest
warn but left changes to the index and/or the working tree
warn " git rebase --continue" Commit or stash your changes, and then run
git rebase --continue")"
warn warn
exit 1 exit 1
fi fi
;; ;;
*) *)
warn "Unknown command: $command $sha1 $rest" warn "$(eval_gettext "Unknown command: \$command \$sha1 \$rest")"
fixtodo="Please fix this using 'git rebase --edit-todo'." fixtodo="$(gettext "Please fix this using 'git rebase --edit-todo'.")"
if git rev-parse --verify -q "$sha1" >/dev/null if git rev-parse --verify -q "$sha1" >/dev/null
then then
die_with_patch $sha1 "$fixtodo" die_with_patch $sha1 "$fixtodo"
@ -676,7 +687,7 @@ do_next () {
"$hook" rebase < "$rewritten_list" "$hook" rebase < "$rewritten_list"
true # we don't care if this hook failed true # we don't care if this hook failed
fi && fi &&
warn "Successfully rebased and updated $head_name." warn "$(eval_gettext "Successfully rebased and updated \$head_name.")"
return 1 # not failure; just to break the do_rest loop return 1 # not failure; just to break the do_rest loop
} }
@ -723,7 +734,7 @@ skip_unnecessary_picks () {
record_in_rewritten "$onto" record_in_rewritten "$onto"
;; ;;
esac || esac ||
die "Could not skip unnecessary pick commands" die "$(gettext "Could not skip unnecessary pick commands")"
} }
transform_todo_ids () { transform_todo_ids () {
@ -881,9 +892,9 @@ check_commit_sha () {
if test $badsha -ne 0 if test $badsha -ne 0
then then
line="$(sed -n -e "${2}p" "$3")" line="$(sed -n -e "${2}p" "$3")"
warn "Warning: the SHA-1 is missing or isn't" \ warn "$(eval_gettext "\
"a commit in the following line:" Warning: the SHA-1 is missing or isn't a commit in the following line:
warn " - $line" - \$line")"
warn warn
fi fi
@ -914,9 +925,9 @@ check_bad_cmd_and_sha () {
;; ;;
*) *)
line="$(sed -n -e "${lineno}p" "$1")" line="$(sed -n -e "${lineno}p" "$1")"
warn "Warning: the command isn't recognized" \ warn "$(eval_gettext "\
"in the following line:" Warning: the command isn't recognized in the following line:
warn " - $line" - \$line")"
warn warn
retval=1 retval=1
;; ;;
@ -953,7 +964,7 @@ warn_lines () {
# Switch to the branch in $into and notify it in the reflog # Switch to the branch in $into and notify it in the reflog
checkout_onto () { checkout_onto () {
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
output git checkout $onto || die_abort "could not detach HEAD" output git checkout $onto || die_abort "$(gettext "could not detach HEAD")"
git update-ref ORIG_HEAD $orig_head git update-ref ORIG_HEAD $orig_head
} }
@ -991,28 +1002,26 @@ check_todo_list () {
then then
test "$check_level" = error && raise_error=t test "$check_level" = error && raise_error=t
warn "Warning: some commits may have been dropped" \ warn "$(gettext "\
"accidentally." Warning: some commits may have been dropped accidentally.
warn "Dropped commits (newer to older):" Dropped commits (newer to older):")"
# Make the list user-friendly and display # Make the list user-friendly and display
opt="--no-walk=sorted --format=oneline --abbrev-commit --stdin" opt="--no-walk=sorted --format=oneline --abbrev-commit --stdin"
git rev-list $opt <"$todo".miss | warn_lines git rev-list $opt <"$todo".miss | warn_lines
warn "To avoid this message, use \"drop\" to" \ warn "$(gettext "\
"explicitly remove a commit." To avoid this message, use \"drop\" to explicitly remove a commit.
warn
warn "Use 'git config rebase.missingCommitsCheck' to change" \ Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
"the level of warnings." The possible behaviours are: ignore, warn, error.")"
warn "The possible behaviours are: ignore, warn, error."
warn warn
fi fi
;; ;;
ignore) ignore)
;; ;;
*) *)
warn "Unrecognized setting $check_level for option" \ warn "$(eval_gettext "Unrecognized setting \$check_level for option rebase.missingCommitsCheck. Ignoring.")"
"rebase.missingCommitsCheck. Ignoring."
;; ;;
esac esac
@ -1029,8 +1038,8 @@ check_todo_list () {
# placed before the commit of the next action # placed before the commit of the next action
checkout_onto checkout_onto
warn "You can fix this with 'git rebase --edit-todo'." warn "$(gettext "You can fix this with 'git rebase --edit-todo'.")"
die "Or you can abort the rebase with 'git rebase --abort'." die "$(gettext "Or you can abort the rebase with 'git rebase --abort'.")"
fi fi
} }
@ -1054,41 +1063,43 @@ continue)
test ! -f "$GIT_DIR"/CHERRY_PICK_HEAD || test ! -f "$GIT_DIR"/CHERRY_PICK_HEAD ||
rm "$GIT_DIR"/CHERRY_PICK_HEAD || rm "$GIT_DIR"/CHERRY_PICK_HEAD ||
die "Could not remove CHERRY_PICK_HEAD" die "$(gettext "Could not remove CHERRY_PICK_HEAD")"
else else
if ! test -f "$author_script" if ! test -f "$author_script"
then then
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
die "You have staged changes in your working tree. If these changes are meant to be die "$(eval_gettext "\
You have staged changes in your working tree.
If these changes are meant to be
squashed into the previous commit, run: squashed into the previous commit, run:
git commit --amend $gpg_sign_opt_quoted git commit --amend \$gpg_sign_opt_quoted
If they are meant to go into a new commit, run: If they are meant to go into a new commit, run:
git commit $gpg_sign_opt_quoted git commit \$gpg_sign_opt_quoted
In both case, once you're done, continue with: In both case, once you're done, continue with:
git rebase --continue git rebase --continue
" ")"
fi fi
. "$author_script" || . "$author_script" ||
die "Error trying to find the author identity to amend commit" die "$(gettext "Error trying to find the author identity to amend commit")"
if test -f "$amend" if test -f "$amend"
then then
current_head=$(git rev-parse --verify HEAD) current_head=$(git rev-parse --verify HEAD)
test "$current_head" = $(cat "$amend") || test "$current_head" = $(cat "$amend") ||
die "\ die "$(gettext "\
You have uncommitted changes in your working tree. Please, commit them You have uncommitted changes in your working tree. Please commit them
first and then run 'git rebase --continue' again." first and then run 'git rebase --continue' again.")"
do_with_author git commit --amend --no-verify -F "$msg" -e \ do_with_author git commit --amend --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} || ${gpg_sign_opt:+"$gpg_sign_opt"} ||
die "Could not commit staged changes." die "$(gettext "Could not commit staged changes.")"
else else
do_with_author git commit --no-verify -F "$msg" -e \ do_with_author git commit --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} || ${gpg_sign_opt:+"$gpg_sign_opt"} ||
die "Could not commit staged changes." die "$(gettext "Could not commit staged changes.")"
fi fi
fi fi
@ -1121,7 +1132,7 @@ To continue rebase after editing, run:
EOF EOF
git_sequence_editor "$todo" || git_sequence_editor "$todo" ||
die "Could not execute editor" die "$(gettext "Could not execute editor")"
expand_todo_ids expand_todo_ids
exit exit
@ -1129,7 +1140,7 @@ EOF
esac esac
git var GIT_COMMITTER_IDENT >/dev/null || git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first" die "$(gettext "You need to set your committer info first")"
comment_for_reflog start comment_for_reflog start
@ -1137,15 +1148,15 @@ if test ! -z "$switch_to"
then then
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
output git checkout "$switch_to" -- || output git checkout "$switch_to" -- ||
die "Could not checkout $switch_to" die "$(eval_gettext "Could not checkout \$switch_to")"
comment_for_reflog start comment_for_reflog start
fi fi
orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?" orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")"
mkdir -p "$state_dir" || die "Could not create temporary $state_dir" mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary \$state_dir")"
: > "$state_dir"/interactive || die "Could not mark as interactive" : > "$state_dir"/interactive || die "$(gettext "Could not mark as interactive")"
write_basic_state write_basic_state
if test t = "$preserve_merges" if test t = "$preserve_merges"
then then
@ -1155,12 +1166,12 @@ then
for c in $(git merge-base --all $orig_head $upstream) for c in $(git merge-base --all $orig_head $upstream)
do do
echo $onto > "$rewritten"/$c || echo $onto > "$rewritten"/$c ||
die "Could not init rewritten commits" die "$(gettext "Could not init rewritten commits")"
done done
else else
mkdir "$rewritten" && mkdir "$rewritten" &&
echo $onto > "$rewritten"/root || echo $onto > "$rewritten"/root ||
die "Could not init rewritten commits" die "$(gettext "Could not init rewritten commits")"
fi fi
# No cherry-pick because our first pass is to determine # No cherry-pick because our first pass is to determine
# parents to rewrite and skipping dropped commits would # parents to rewrite and skipping dropped commits would
@ -1270,7 +1281,7 @@ EOF
if test -z "$keep_empty" if test -z "$keep_empty"
then then
printf '%s\n' "$comment_char Note that empty commits are commented out" >>"$todo" printf '%s\n' "$comment_char $(gettext "Note that empty commits are commented out")" >>"$todo"
fi fi
@ -1280,7 +1291,7 @@ has_action "$todo" ||
cp "$todo" "$todo".backup cp "$todo" "$todo".backup
collapse_todo_ids collapse_todo_ids
git_sequence_editor "$todo" || git_sequence_editor "$todo" ||
die_abort "Could not execute editor" die_abort "$(gettext "Could not execute editor")"
has_action "$todo" || has_action "$todo" ||
return 2 return 2