Skip to content

Commit 9574500

Browse files
committed
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
2 parents 1952e10 + 6ff875c commit 9574500

File tree

5 files changed

+44
-40
lines changed

5 files changed

+44
-40
lines changed

git-am.sh

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,8 @@ safe_to_abort () {
9090
then
9191
return 0
9292
fi
93-
(
94-
gettext "You seem to have moved HEAD since the last 'am' failure.
95-
Not rewinding to ORIG_HEAD" &&
96-
echo
97-
) >&2
93+
gettextln "You seem to have moved HEAD since the last 'am' failure.
94+
Not rewinding to ORIG_HEAD" >&2
9895
return 1
9996
}
10097

@@ -103,9 +100,9 @@ stop_here_user_resolve () {
103100
printf '%s\n' "$resolvemsg"
104101
stop_here $1
105102
fi
106-
eval_gettext "When you have resolved this problem run \"\$cmdline --resolved\".
103+
eval_gettextln "When you have resolved this problem run \"\$cmdline --resolved\".
107104
If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
108-
To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo
105+
To restore the original branch and stop patching run \"\$cmdline --abort\"."
109106

110107
stop_here $1
111108
}
@@ -119,7 +116,7 @@ go_next () {
119116

120117
cannot_fallback () {
121118
echo "$1"
122-
gettext "Cannot fall back to three-way merge."; echo
119+
gettextln "Cannot fall back to three-way merge."
123120
exit 1
124121
}
125122

@@ -619,9 +616,9 @@ do
619616
go_next && continue
620617

621618
test -s "$dotest/patch" || {
622-
eval_gettext "Patch is empty. Was it split wrong?
619+
eval_gettextln "Patch is empty. Was it split wrong?
623620
If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
624-
To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo
621+
To restore the original branch and stop patching run \"\$cmdline --abort\"."
625622
stop_here $this
626623
}
627624
rm -f "$dotest/original-commit" "$dotest/author-script"
@@ -656,7 +653,7 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
656653

657654
if test -z "$GIT_AUTHOR_EMAIL"
658655
then
659-
gettext "Patch does not have a valid e-mail address."; echo
656+
gettextln "Patch does not have a valid e-mail address."
660657
stop_here $this
661658
fi
662659

@@ -707,7 +704,7 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
707704
action=again
708705
while test "$action" = again
709706
do
710-
gettext "Commit Body is:"; echo
707+
gettextln "Commit Body is:"
711708
echo "--------------------------"
712709
cat "$dotest/final-commit"
713710
echo "--------------------------"
@@ -771,16 +768,16 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec
771768
# working tree.
772769
resolved=
773770
git diff-index --quiet --cached HEAD -- && {
774-
gettext "No changes - did you forget to use 'git add'?
771+
gettextln "No changes - did you forget to use 'git add'?
775772
If there is nothing left to stage, chances are that something else
776-
already introduced the same changes; you might want to skip this patch."; echo
773+
already introduced the same changes; you might want to skip this patch."
777774
stop_here_user_resolve $this
778775
}
779776
unmerged=$(git ls-files -u)
780777
if test -n "$unmerged"
781778
then
782-
gettext "You still have unmerged paths in your index
783-
did you forget to use 'git add'?"; echo
779+
gettextln "You still have unmerged paths in your index
780+
did you forget to use 'git add'?"
784781
stop_here_user_resolve $this
785782
fi
786783
apply_status=0
@@ -805,7 +802,7 @@ did you forget to use 'git add'?"; echo
805802
fi
806803
if test $apply_status != 0
807804
then
808-
eval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo
805+
eval_gettextln 'Patch failed at $msgnum $FIRSTLINE'
809806
stop_here_user_resolve $this
810807
fi
811808

git-pull.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,9 @@ then
217217
# $orig_head commit, but we are merging into $curr_head.
218218
# First update the working tree to match $curr_head.
219219

220-
(
221-
eval_gettext "Warning: fetch updated the current branch head.
220+
eval_gettextln "Warning: fetch updated the current branch head.
222221
Warning: fast-forwarding your working tree from
223-
Warning: commit \$orig_head." &&
224-
echo
225-
) >&2
222+
Warning: commit \$orig_head." >&2
226223
git update-index -q --refresh
227224
git read-tree -u -m "$orig_head" "$curr_head" ||
228225
die "$(eval_gettext "Cannot fast-forward your working tree.

git-sh-i18n.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ then
1111
printf "%s" "$1"
1212
}
1313

14+
gettextln() {
15+
printf "%s\n" "$1"
16+
}
17+
1418
eval_gettext () {
1519
printf "%s" "$1" | (
1620
export PATH $(git sh-i18n--envsubst --variables "$1");
1721
git sh-i18n--envsubst "$1"
1822
)
1923
}
24+
25+
eval_gettextln () {
26+
printf "%s\n" "$1" | (
27+
export PATH $(git sh-i18n--envsubst --variables "$1");
28+
git sh-i18n--envsubst "$1"
29+
)
30+
}
2031
else
2132
gettext () {
2233
printf "%s" "# GETTEXT POISON #"
2334
}
2435

36+
gettextln () {
37+
printf "%s\n" "# GETTEXT POISON #"
38+
}
39+
2540
eval_gettext () {
2641
printf "%s" "# GETTEXT POISON #"
2742
}
43+
44+
eval_gettextln () {
45+
printf "%s\n" "# GETTEXT POISON #"
46+
}
2847
fi
2948

git-stash.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ save_stash () {
198198
# $ git stash save --blah-blah 2>&1 | head -n 2
199199
# error: unknown option for 'stash save': --blah-blah
200200
# To provide a message, use git stash save -- '--blah-blah'
201-
eval_gettext "$("error: unknown option for 'stash save': \$option
202-
To provide a message, use git stash save -- '\$option'")"; echo
201+
eval_gettextln "$("error: unknown option for 'stash save': \$option
202+
To provide a message, use git stash save -- '\$option'")"
203203
usage
204204
;;
205205
*)
@@ -470,10 +470,7 @@ apply_stash () {
470470
status=$?
471471
if test -n "$INDEX_OPTION"
472472
then
473-
(
474-
gettext "Index was not unstashed." &&
475-
echo
476-
) >&2
473+
gettextln "Index was not unstashed." >&2
477474
fi
478475
exit $status
479476
fi

git-submodule.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,9 @@ cmd_add()
228228

229229
if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1
230230
then
231-
(
232-
eval_gettext "The following path is ignored by one of your .gitignore files:
231+
eval_gettextln "The following path is ignored by one of your .gitignore files:
233232
\$path
234-
Use -f if you really want to add it." &&
235-
echo
236-
) >&2
233+
Use -f if you really want to add it." >&2
237234
exit 1
238235
fi
239236

@@ -242,7 +239,7 @@ Use -f if you really want to add it." &&
242239
then
243240
if test -d "$path"/.git -o -f "$path"/.git
244241
then
245-
eval_gettext "Adding existing repo at '\$path' to the index"; echo
242+
eval_gettextln "Adding existing repo at '\$path' to the index"
246243
else
247244
die "$(eval_gettext "'\$path' already exists and is not a valid git repo")"
248245
fi
@@ -701,10 +698,7 @@ cmd_summary() {
701698
;; # removed
702699
*)
703700
# unexpected type
704-
(
705-
eval_gettext "unexpected mode \$mod_dst" &&
706-
echo
707-
) >&2
701+
eval_gettextln "unexpected mode \$mod_dst" >&2
708702
continue ;;
709703
esac
710704
fi
@@ -791,9 +785,9 @@ cmd_summary() {
791785
done |
792786
if test -n "$for_status"; then
793787
if [ -n "$files" ]; then
794-
gettext "# Submodules changed but not updated:"; echo
788+
gettextln "# Submodules changed but not updated:"
795789
else
796-
gettext "# Submodule changes to be committed:"; echo
790+
gettextln "# Submodule changes to be committed:"
797791
fi
798792
echo "#"
799793
sed -e 's|^|# |' -e 's|^# $|#|'

0 commit comments

Comments
 (0)