Merge branch 'js/i18n-scripts'

* js/i18n-scripts:
  submodule: take advantage of gettextln and eval_gettextln.
  stash: take advantage of eval_gettextln
  pull: take advantage of eval_gettextln
  git-am: take advantage of gettextln and eval_gettextln.
  gettext: add gettextln, eval_gettextln to encode common idiom
This commit is contained in:
Junio C Hamano 2011-08-25 16:00:16 -07:00
commit 957450054c
5 changed files with 44 additions and 40 deletions

View File

@ -90,11 +90,8 @@ safe_to_abort () {
then then
return 0 return 0
fi fi
( gettextln "You seem to have moved HEAD since the last 'am' failure.
gettext "You seem to have moved HEAD since the last 'am' failure. Not rewinding to ORIG_HEAD" >&2
Not rewinding to ORIG_HEAD" &&
echo
) >&2
return 1 return 1
} }
@ -103,9 +100,9 @@ stop_here_user_resolve () {
printf '%s\n' "$resolvemsg" printf '%s\n' "$resolvemsg"
stop_here $1 stop_here $1
fi fi
eval_gettext "When you have resolved this problem run \"\$cmdline --resolved\". eval_gettextln "When you have resolved this problem run \"\$cmdline --resolved\".
If you would prefer to skip this patch, instead run \"\$cmdline --skip\". If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo To restore the original branch and stop patching run \"\$cmdline --abort\"."
stop_here $1 stop_here $1
} }
@ -119,7 +116,7 @@ go_next () {
cannot_fallback () { cannot_fallback () {
echo "$1" echo "$1"
gettext "Cannot fall back to three-way merge."; echo gettextln "Cannot fall back to three-way merge."
exit 1 exit 1
} }
@ -619,9 +616,9 @@ do
go_next && continue go_next && continue
test -s "$dotest/patch" || { test -s "$dotest/patch" || {
eval_gettext "Patch is empty. Was it split wrong? eval_gettextln "Patch is empty. Was it split wrong?
If you would prefer to skip this patch, instead run \"\$cmdline --skip\". If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo To restore the original branch and stop patching run \"\$cmdline --abort\"."
stop_here $this stop_here $this
} }
rm -f "$dotest/original-commit" "$dotest/author-script" rm -f "$dotest/original-commit" "$dotest/author-script"
@ -656,7 +653,7 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
if test -z "$GIT_AUTHOR_EMAIL" if test -z "$GIT_AUTHOR_EMAIL"
then then
gettext "Patch does not have a valid e-mail address."; echo gettextln "Patch does not have a valid e-mail address."
stop_here $this stop_here $this
fi fi
@ -707,7 +704,7 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
action=again action=again
while test "$action" = again while test "$action" = again
do do
gettext "Commit Body is:"; echo gettextln "Commit Body is:"
echo "--------------------------" echo "--------------------------"
cat "$dotest/final-commit" cat "$dotest/final-commit"
echo "--------------------------" echo "--------------------------"
@ -771,16 +768,16 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
# working tree. # working tree.
resolved= resolved=
git diff-index --quiet --cached HEAD -- && { git diff-index --quiet --cached HEAD -- && {
gettext "No changes - did you forget to use 'git add'? gettextln "No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch."; echo already introduced the same changes; you might want to skip this patch."
stop_here_user_resolve $this stop_here_user_resolve $this
} }
unmerged=$(git ls-files -u) unmerged=$(git ls-files -u)
if test -n "$unmerged" if test -n "$unmerged"
then then
gettext "You still have unmerged paths in your index gettextln "You still have unmerged paths in your index
did you forget to use 'git add'?"; echo did you forget to use 'git add'?"
stop_here_user_resolve $this stop_here_user_resolve $this
fi fi
apply_status=0 apply_status=0
@ -805,7 +802,7 @@ did you forget to use 'git add'?"; echo
fi fi
if test $apply_status != 0 if test $apply_status != 0
then then
eval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo eval_gettextln 'Patch failed at $msgnum $FIRSTLINE'
stop_here_user_resolve $this stop_here_user_resolve $this
fi fi

View File

@ -217,12 +217,9 @@ then
# $orig_head commit, but we are merging into $curr_head. # $orig_head commit, but we are merging into $curr_head.
# First update the working tree to match $curr_head. # First update the working tree to match $curr_head.
( eval_gettextln "Warning: fetch updated the current branch head.
eval_gettext "Warning: fetch updated the current branch head.
Warning: fast-forwarding your working tree from Warning: fast-forwarding your working tree from
Warning: commit \$orig_head." && Warning: commit \$orig_head." >&2
echo
) >&2
git update-index -q --refresh git update-index -q --refresh
git read-tree -u -m "$orig_head" "$curr_head" || git read-tree -u -m "$orig_head" "$curr_head" ||
die "$(eval_gettext "Cannot fast-forward your working tree. die "$(eval_gettext "Cannot fast-forward your working tree.

View File

@ -11,19 +11,38 @@ then
printf "%s" "$1" printf "%s" "$1"
} }
gettextln() {
printf "%s\n" "$1"
}
eval_gettext () { eval_gettext () {
printf "%s" "$1" | ( printf "%s" "$1" | (
export PATH $(git sh-i18n--envsubst --variables "$1"); export PATH $(git sh-i18n--envsubst --variables "$1");
git sh-i18n--envsubst "$1" git sh-i18n--envsubst "$1"
) )
} }
eval_gettextln () {
printf "%s\n" "$1" | (
export PATH $(git sh-i18n--envsubst --variables "$1");
git sh-i18n--envsubst "$1"
)
}
else else
gettext () { gettext () {
printf "%s" "# GETTEXT POISON #" printf "%s" "# GETTEXT POISON #"
} }
gettextln () {
printf "%s\n" "# GETTEXT POISON #"
}
eval_gettext () { eval_gettext () {
printf "%s" "# GETTEXT POISON #" printf "%s" "# GETTEXT POISON #"
} }
eval_gettextln () {
printf "%s\n" "# GETTEXT POISON #"
}
fi fi

View File

@ -198,8 +198,8 @@ save_stash () {
# $ git stash save --blah-blah 2>&1 | head -n 2 # $ git stash save --blah-blah 2>&1 | head -n 2
# error: unknown option for 'stash save': --blah-blah # error: unknown option for 'stash save': --blah-blah
# To provide a message, use git stash save -- '--blah-blah' # To provide a message, use git stash save -- '--blah-blah'
eval_gettext "$("error: unknown option for 'stash save': \$option eval_gettextln "$("error: unknown option for 'stash save': \$option
To provide a message, use git stash save -- '\$option'")"; echo To provide a message, use git stash save -- '\$option'")"
usage usage
;; ;;
*) *)
@ -470,10 +470,7 @@ apply_stash () {
status=$? status=$?
if test -n "$INDEX_OPTION" if test -n "$INDEX_OPTION"
then then
( gettextln "Index was not unstashed." >&2
gettext "Index was not unstashed." &&
echo
) >&2
fi fi
exit $status exit $status
fi fi

View File

@ -228,12 +228,9 @@ cmd_add()
if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1
then then
( eval_gettextln "The following path is ignored by one of your .gitignore files:
eval_gettext "The following path is ignored by one of your .gitignore files:
\$path \$path
Use -f if you really want to add it." && Use -f if you really want to add it." >&2
echo
) >&2
exit 1 exit 1
fi fi
@ -242,7 +239,7 @@ Use -f if you really want to add it." &&
then then
if test -d "$path"/.git -o -f "$path"/.git if test -d "$path"/.git -o -f "$path"/.git
then then
eval_gettext "Adding existing repo at '\$path' to the index"; echo eval_gettextln "Adding existing repo at '\$path' to the index"
else else
die "$(eval_gettext "'\$path' already exists and is not a valid git repo")" die "$(eval_gettext "'\$path' already exists and is not a valid git repo")"
fi fi
@ -701,10 +698,7 @@ cmd_summary() {
;; # removed ;; # removed
*) *)
# unexpected type # unexpected type
( eval_gettextln "unexpected mode \$mod_dst" >&2
eval_gettext "unexpected mode \$mod_dst" &&
echo
) >&2
continue ;; continue ;;
esac esac
fi fi
@ -791,9 +785,9 @@ cmd_summary() {
done | done |
if test -n "$for_status"; then if test -n "$for_status"; then
if [ -n "$files" ]; then if [ -n "$files" ]; then
gettext "# Submodules changed but not updated:"; echo gettextln "# Submodules changed but not updated:"
else else
gettext "# Submodule changes to be committed:"; echo gettextln "# Submodule changes to be committed:"
fi fi
echo "#" echo "#"
sed -e 's|^|# |' -e 's|^# $|#|' sed -e 's|^|# |' -e 's|^# $|#|'