i18n: Windows shellscript support
cover i18n: Windows shellscript support
This series goes on top of the other shell script serieses and fixes the issue with case insensitive environment variables on Windows by giving all the variables passed to eval_gettext a prefix that's unlikely to clash with existing variables in the environment.
With this series the ab/i18n-sh-scripts series should be ready for master, since this fixes the last known issue with it.
Ævar Arnfjörð Bjarmason (6):
i18n win32: add git-am eval_gettext variable prefix i18n win32: add git-bisect eval_gettext variable prefix i18n win32: add git-pull eval_gettext variable prefix i18n win32: add git-stash eval_gettext variable prefix i18n win32: add git-submodule eval_gettext variable prefix i18n win32: add test eval_gettext variable prefix
git-am.sh | 29 +++++--- git-bisect.sh | 39 +++++++---- git-pull.sh | 5 +- git-stash.sh | 26 ++++--- git-submodule.sh | 151 ++++++++++++++++++++++++++++-------------- t/t0201-gettext-fallbacks.sh | 4 +- 6 files changed, 167 insertions(+), 87 deletions(-)
Signature · 1 line
1.7.5.1
PATCH 1/6 i18n win32: add git-am eval_gettext variable prefix
Change the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- git-am.sh | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-)
git-am.sh +19 -10
@@ -102,9 +102,11 @@ stop_here_user_resolve () { printf '%s\n' "$resolvemsg" stop_here $1 fi - eval_gettext "When you have resolved this problem run \"\$cmdline --resolved\". -If you would prefer to skip this patch, instead run \"\$cmdline --skip\". -To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo + + GIT_I18N_VARIABLE_cmdline=$cmdline + eval_gettext "When you have resolved this problem run \"\$GIT_I18N_VARIABLE_cmdline --resolved\". +If you would prefer to skip this patch, instead run \"\$GIT_I18N_VARIABLE_cmdline --skip\". +To restore the original branch and stop patching run \"\$GIT_I18N_VARIABLE_cmdline --abort\"."; echo stop_here $1 }
@@ -310,7 +312,8 @@ split_patches () { ;; *) if test -n "$parse_patch" ; then - clean_abort "$(eval_gettext "Patch format \$patch_format is not supported.")" + GIT_I18N_VARIABLE_patch_format=$patch_format + clean_abort "$(eval_gettext "Patch format \$GIT_I18N_VARIABLE_patch_format is not supported.")" else clean_abort "$(gettext "Patch format detection failed.")" fi
@@ -407,6 +410,7 @@ fi if test -d "$dotest" then + GIT_I18N_VARIABLE_dotest=$dotest case "$#,$skip$resolved$abort" in 0,*t*) # Explicit resume command and we do not have file, so
@@ -425,7 +429,7 @@ then false ;; esac || - die "$(eval_gettext "previous rebase directory \$dotest still exists but mbox given.")" + die "$(eval_gettext "previous rebase directory \$GIT_I18N_VARIABLE_dotest still exists but mbox given.")" resume=yes case "$skip,$abort" in
@@ -522,7 +526,8 @@ case "$resolved" in if test "$files" then test -n "$HAS_HEAD" && : >"$dotest/dirtyindex" - die "$(eval_gettext "Dirty index: cannot apply patches (dirty: \$files)")" + GIT_I18N_VARIABLE_files=$files + die "$(eval_gettext "Dirty index: cannot apply patches (dirty: \$GIT_I18N_VARIABLE_files)")" fi esac
@@ -611,9 +616,10 @@ do go_next && continue test -s "$dotest/patch" || { + GIT_I18N_VARIABLE_cmdline=$cmdline eval_gettext "Patch is empty. Was it split wrong? -If you would prefer to skip this patch, instead run \"\$cmdline --skip\". -To restore the original branch and stop patching run \"\$cmdline --abort\"."; echo +If you would prefer to skip this patch, instead run \"\$GIT_I18N_VARIABLE_cmdline --skip\". +To restore the original branch and stop patching run \"\$GIT_I18N_VARIABLE_cmdline --abort\"."; echo stop_here $this } rm -f "$dotest/original-commit" "$dotest/author-script"
@@ -742,7 +748,8 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."; ec stop_here $this fi - say "$(eval_gettext "Applying: \$FIRSTLINE")" + GIT_I18N_VARIABLE_FIRSTLINE=$FIRSTLINE + say "$(eval_gettext "Applying: \$GIT_I18N_VARIABLE_FIRSTLINE")" case "$resolved" in '')
@@ -797,7 +804,9 @@ did you forget to use 'git add'?"; echo fi if test $apply_status != 0 then - eval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo + GIT_I18N_VARIABLE_msgnum=$msgnum + GIT_I18N_VARIABLE_FIRSTLINE=$FIRSTLINE + eval_gettext 'Patch failed at $GIT_I18N_VARIABLE_msgnum $GIT_I18N_VARIABLE_FIRSTLINE'; echo stop_here_user_resolve $this fi
Signature · 1 line
1.7.5.1
Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix
Am 5/26/2011 1:19, schrieb Ævar Arnfjörð Bjarmason:
Review
Quoted 4 lines
(quoted diff) +3
-1- eval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo + GIT_I18N_VARIABLE_msgnum=$msgnum + GIT_I18N_VARIABLE_FIRSTLINE=$FIRSTLINE + eval_gettext 'Patch failed at $GIT_I18N_VARIABLE_msgnum $GIT_I18N_VARIABLE_FIRSTLINE'; echo
That's not pretty.
I wonder whether it is possible to automate the variable prefix. Looking at the definition of eval_gettext()
eval_gettext () {
printf "%s" "$1" | (
export PATH $(git sh-i18n--envsubst --variables "$1");
git sh-i18n--envsubst "$1"
)
}I gather that the actual substitution of variable values is done by sh-i18n--envsubst, and not by the shell (right?). Let's look at an example:
git sh-i18n--envsubst --variables '$foo and $bar'
produces
foo
bar
What if it produced
GIT_I18N_VARIABLE_foo=$foo GIT_I18N_VARIABLE_bar=$bar export GIT_I18N_VARIABLE_foo GIT_I18N_VARIABLE_bar
then the definition of eval_gettext() would look like
eval_gettext () {
printf "%s" "$1" | (
export PATH
eval "$(git sh-i18n--envsubst --variables "$1")"
git sh-i18n--envsubst "$1"
)
}and the second call of sh-i18n--envsubst should replace $foo and $bar that it sees on stdin by the values of GIT_I18N_VARIABLE_foo and GIT_I18N_VARIABLE_bar from the environment.
What do you think?
BTW, if you re-roll the series, would you mind shortening the prefix to, say, _I18N__ because on Windows the variables names count towards the environment budget, which is restricted to 32k characters.
BTW2, the following patch is needed to avoid a crash of an invocation of 'git sh-i18n--envsubst' without arguments.
-- Hannes
(Warning: hand-edited patch text)
sh-i18n--envsubst.c +1 -0
@@ -76,2 +76,3 @@ main (int argc, char *argv[])error ("we won't substitute all variables on stdin for you" ); +break ;/*
Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix
Quoted 26 lines · Johannes Sixt
I gather that the actual substitution of variable values is done by sh-i18n--envsubst, and not by the shell (right?). Let's look at an example:
git sh-i18n--envsubst --variables '$foo and $bar'produces
foo
barWhat if it produced
GIT_I18N_VARIABLE_foo=$foo GIT_I18N_VARIABLE_bar=$bar export GIT_I18N_VARIABLE_foo GIT_I18N_VARIABLE_barthen the definition of
eval_gettext()would look likeeval_gettext () { printf "%s" "$1" | ( export PATH eval "$(git sh-i18n--envsubst --variables "$1")" git sh-i18n--envsubst "$1" ) }
Quoted 5 lines
and the second call of sh-i18n--envsubst should replace $foo and $bar that it sees on stdin by the values of
GIT_I18N_VARIABLE_fooandGIT_I18N_VARIABLE_barfrom the environment.What do you think?
This started on windows that confuses between $path and $PATH, we wouldn't be doing this, right? In git-submodule.sh uses $path variable for something other than the search-path, and the definition updated by you would become in the larger picture:
path=... ;# git-submodule uses the variable for not-a-search-path
_I18N__path=$path
export _I18N__path
git sh-i18n--envsubst "... $_I18N__path"Is the RHS of the second assignment safe on Windows? Are environment variables case insane but normal variables are safe?
If that is a non-issue, I think your change is a good thing to do.
Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix
Am 5/26/2011 16:13, schrieb Junio C Hamano:
Quoted 5 lines
This started on windows that confuses between $path and $PATH, we wouldn't be doing this, right? In
git-submodule.shuses $path variable for something other than the search-path, and the definition updated by you would become in the larger picture:
Quoted 7 lines
path=... ;# git-submodule uses the variable for not-a-search-path _I18N__path=$path export _I18N__path git sh-i18n--envsubst "... $_I18N__path"Is the RHS of the second assignment safe on Windows? Are environment variables case insane but normal variables are safe?
Yes, the second assignment is safe, because at this point everything is internal to bash; it does the right thing.
Problems start only when exported variables are transported from bash to another process.
But ... wait a minute - I've another idea!
bash -c "path=z env"
*does* list both 'path' and 'PATH'
... hack hack ...
and so does a home-grown equivalent of 'env', both for MinGW and Visual Studio. It looks like the environment was transfered just fine, only the *lookup* by getenv() was case-insensitive. This means we would just have to supply a POSIX conformant getenv() for sh-i18n--envsubst.
I can write one, no problem; and, Ævar, I'm awfully sorry for sending you in the wrong direction.
-- Hannes
Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix
Quoted 2 lines · Johannes Sixt
I can write one, no problem; and, Ævar, I'm awfully sorry for sending you in the wrong direction.
That's very nice. Having a compat/getenv.c to solve this would be great.
I look forward to seeing it. Thanks for writing it, since I can't test stuff on Windows.
PATCH 2/6 i18n win32: add git-bisect eval_gettext variable prefix
In reply to Ævar Arnfjörð BjarmasonChange the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- git-bisect.sh | 39 ++++++++++++++++++++++++++------------- 1 files changed, 26 insertions(+), 13 deletions(-)
git-bisect.sh +26 -13
@@ -116,8 +116,11 @@ bisect_start() { ;; *) rev=$(git rev-parse -q --verify "$arg^{commit}") || { - test $has_double_dash -eq 1 && - die "$(eval_gettext "'\$arg' does not appear to be a valid revision")" + if test $has_double_dash -eq 1 + then + $GIT_I18N_VARIABLE_arg=$arg + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_arg' does not appear to be a valid revision")" + fi break } case $bad_seen in
@@ -162,7 +165,8 @@ bisect_write() { case "$state" in bad) tag="$state" ;; good|skip) tag="$state"-"$rev" ;; - *) die "$(eval_gettext "Bad bisect_write argument: \$state")" ;; + *) GIT_I18N_VARIABLE_state=$state + die "$(eval_gettext "Bad bisect_write argument: \$GIT_I18N_VARIABLE_state")" ;; esac git update-ref "refs/bisect/$tag" "$rev" || exit echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
@@ -190,7 +194,8 @@ bisect_skip() { do case "$arg" in *..*) - revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$arg")" ;; + GIT_I18N_VARIABLE_arg=$arg + revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$GIT_I18N_VARIABLE_arg")" ;; *) revs=$(git rev-parse --sq-quote "$arg") ;; esac
@@ -215,8 +220,9 @@ bisect_state() { eval='' for rev in "$@" do + GIT_I18N_VARIABLE_rev=$rev sha=$(git rev-parse --verify "$rev^{commit}") || - die "$(eval_gettext "Bad rev input: \$rev")" + die "$(eval_gettext "Bad rev input: \$GIT_I18N_VARIABLE_rev")" eval="$eval bisect_write '$state' '$sha'; " done eval "$eval"
@@ -333,8 +339,8 @@ bisect_reset() { case "$#" in 0) branch=$(cat "$GIT_DIR/BISECT_START") ;; 1) git rev-parse --quiet --verify "$1^{commit}" > /dev/null || { - invalid="$1" - die "$(eval_gettext "'\$invalid' is not a valid commit")" + GIT_I18N_VARIABLE_invalid="$1" + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_invalid' is not a valid commit")" } branch="$1" ;; *)
@@ -343,7 +349,8 @@ bisect_reset() { if git checkout "$branch" -- ; then bisect_clean_state else - die "$(eval_gettext "Could not check out original HEAD '\$branch'. + GIT_I18N_VARIABLE_branch=$branch + die "$(eval_gettext "Could not check out original HEAD '\$GIT_I18N_VARIABLE_branch'. Try 'git bisect reset <commit>'.")" fi }
@@ -369,7 +376,10 @@ bisect_clean_state() { bisect_replay () { file="$1" test "$#" -eq 1 || die "$(gettext "No logfile given")" - test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")" + test -r "$file" || { + GIT_I18N_VARIABLE_file=$file + die "$(eval_gettext "cannot read \$GIT_I18N_VARIABLE_file for replaying")" + } bisect_reset while read git bisect command rev do
@@ -396,16 +406,17 @@ bisect_run () { while true do - command="$@" - eval_gettext "running \$command"; echo + GIT_I18N_VARIABLE_command="$@" + eval_gettext "running \$GIT_I18N_VARIABLE_command"; echo "$@" res=$? # Check for really bad run error. if [ $res -lt 0 -o $res -ge 128 ]; then ( + GIT_I18N_VARIABLE_res=$res eval_gettext "bisect run failed: -exit code \$res from '\$command' is < 0 or >= 128" && +exit code \$GIT_I18N_VARIABLE_res from '\$GIT_I18N_VARIABLE_command' is < 0 or >= 128" && echo ) >&2 exit $res
@@ -438,8 +449,10 @@ exit code \$res from '\$command' is < 0 or >= 128" && if [ $res -ne 0 ]; then ( + GIT_I18N_VARIABLE_state=$state + GIT_I18N_VARIABLE_res=$res eval_gettext "bisect run failed: -'bisect_state \$state' exited with error code \$res" && +'bisect_state \$GIT_I18N_VARIABLE_state' exited with error code \$GIT_I18N_VARIABLE_res" && echo ) >&2 exit $res
Signature · 1 line
1.7.5.1
PATCH 3/6 i18n win32: add git-pull eval_gettext variable prefix
In reply to Ævar Arnfjörð BjarmasonChange the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- git-pull.sh | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
git-pull.sh +3 -2
@@ -217,17 +217,18 @@ then # $orig_head commit, but we are merging into $curr_head. # First update the working tree to match $curr_head. + GIT_I18N_VARIABLE_orig_head=$orig_head ( eval_gettext "Warning: fetch updated the current branch head. Warning: fast-forwarding your working tree from -Warning: commit \$orig_head." && +Warning: commit \$GIT_I18N_VARIABLE_orig_head." && echo ) >&2 git update-index -q --refresh git read-tree -u -m "$orig_head" "$curr_head" || die "$(eval_gettext "Cannot fast-forward your working tree. After making sure that you saved anything precious from -$ git diff \$orig_head +$ git diff \$GIT_I18N_VARIABLE_orig_head output, run $ git reset --hard to recover.")"
Signature · 1 line
1.7.5.1
PATCH 4/6 i18n win32: add git-stash eval_gettext variable prefix
In reply to Ævar Arnfjörð BjarmasonChange the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- git-stash.sh | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)
git-stash.sh +15 -11
@@ -153,6 +153,7 @@ save_stash () { ;; -*) option="$1" + GIT_I18N_VARIABLE_option=$option # TRANSLATORS: $option is an invalid option, like # `--blah-blah'. The 7 spaces at the beginning of the # second line correspond to "error: ". So you should line
@@ -163,8 +164,8 @@ save_stash () { # $ git stash save --blah-blah 2>&1 | head -n 2 # error: unknown option for 'stash save': --blah-blah # To provide a message, use git stash save -- '--blah-blah' - eval_gettext "$("error: unknown option for 'stash save': \$option - To provide a message, use git stash save -- '\$option'")"; echo + eval_gettext "$("error: unknown option for 'stash save': \$GIT_I18N_VARIABLE_option + To provide a message, use git stash save -- '\$GIT_I18N_VARIABLE_option'")"; echo usage ;; *)
@@ -306,13 +307,14 @@ parse_flags_and_rev() : ;; *) - die "$(eval_gettext "Too many revisions specified: \$REV")" + GIT_I18N_VARIABLE_REV=$REV + die "$(eval_gettext "Too many revisions specified: \$GIT_I18N_VARIABLE_REV")" ;; esac REV=$(git rev-parse --quiet --symbolic --verify $1 2>/dev/null) || { - reference="$1" - die "$(eval_gettext "\$reference is not valid reference")" + GIT_I18N_VARIABLE_reference="$1" + die "$(eval_gettext "\$GIT_I18N_VARIABLE_reference is not valid reference")" } i_commit=$(git rev-parse --quiet --verify $REV^2 2>/dev/null) &&
@@ -336,8 +338,8 @@ is_stash_like() assert_stash_like() { is_stash_like "$@" || { - args="$*" - die "$(eval_gettext "'\$args' is not a stash-like commit")" + GIT_I18N_VARIABLE_args="$*" + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_args' is not a stash-like commit")" } }
@@ -347,8 +349,8 @@ is_stash_ref() { assert_stash_ref() { is_stash_ref "$@" || { - args="$*" - die "$(eval_gettext "'\$args' is not a stash reference")" + GIT_I18N_VARIABLE_args="$*" + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_args' is not a stash reference")" } }
@@ -429,9 +431,11 @@ pop_stash() { drop_stash () { assert_stash_ref "$@" + GIT_I18N_VARIABLE_REV=$REV + GIT_I18N_VARIABLE_s=$s git reflog delete --updateref --rewrite "${REV}" && - say "$(eval_gettext "Dropped \${REV} (\$s)")" || - die "$(eval_gettext "\${REV}: Could not drop stash entry")" + say "$(eval_gettext "Dropped \$GIT_I18N_VARIABLE_REV (\$GIT_I18N_VARIABLE_s)")" || + die "$(eval_gettext "\$GIT_I18N_VARIABLE_REV: Could not drop stash entry")" # clear_stash if we just dropped the last stash entry git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
Signature · 1 line
1.7.5.1
PATCH 5/6 i18n win32: add git-submodule eval_gettext variable prefix
In reply to Ævar Arnfjörð BjarmasonChange the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- git-submodule.sh | 151 ++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 102 insertions(+), 49 deletions(-)
git-submodule.sh +102 -49
@@ -34,8 +34,10 @@ prefix= resolve_relative_url () { remote=$(get_default_remote) - remoteurl=$(git config "remote.$remote.url") || - die "$(eval_gettext "remote (\$remote) does not have a url defined in .git/config")" + remoteurl=$(git config "remote.$remote.url") || { + GIT_I18N_VARIABLE_remote=$(get_default_remote) + die "$(eval_gettext "remote (\$GIT_I18N_VARIABLE_remote) does not have a url defined in .git/config")" + } url="$1" remoteurl=${remoteurl%/} sep=/
@@ -53,7 +55,8 @@ resolve_relative_url () sep=: ;; *) - die "$(eval_gettext "cannot strip one component off url '\$remoteurl'")" + GIT_I18N_VARIABLE_remoteurl=$remoteurl + die "$(eval_gettext "cannot strip one component off url '\$GIT_I18N_VARIABLE_remoteurl'")" ;; esac ;;
@@ -104,9 +107,12 @@ module_name() re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g') name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' ) - test -z "$name" && - die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$path'")" - echo "$name" + if test -z "$name" + then + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$GIT_I18N_VARIABLE_path'")" + fi + echo "$name" } #
@@ -128,8 +134,11 @@ module_clone() git-clone "$reference" -n "$url" "$path" else git-clone -n "$url" "$path" - fi || - die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" + fi || { + GIT_I18N_VARIABLE_url=$url + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Clone of '\$GIT_I18N_VARIABLE_url' into submodule path '\$GIT_I18N_VARIABLE_path' failed")" + } } #
@@ -202,7 +211,8 @@ cmd_add() realrepo=$repo ;; *) - die "$(eval_gettext "repo URL: '\$repo' must be absolute or begin with ./|../")" + GIT_I18N_VARIABLE_repo=$repo + die "$(eval_gettext "repo URL: '\$GIT_I18N_VARIABLE_repo' must be absolute or begin with ./|../")" ;; esac
@@ -218,14 +228,18 @@ cmd_add() tstart s|/*$|| ') - git ls-files --error-unmatch "$path" > /dev/null 2>&1 && - die "$(eval_gettext "'\$path' already exists in the index")" + if git ls-files --error-unmatch "$path" > /dev/null 2>&1 + then + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_path' already exists in the index")" + fi if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 then ( + GIT_I18N_VARIABLE_path=$path eval_gettext "The following path is ignored by one of your .gitignore files: -\$path +\$GIT_I18N_VARIABLE_path Use -f if you really want to add it." && echo ) >&2
@@ -237,9 +251,11 @@ Use -f if you really want to add it." && then if test -d "$path"/.git -o -f "$path"/.git then - eval_gettext "Adding existing repo at '\$path' to the index"; echo + GIT_I18N_VARIABLE_path=$path + eval_gettext "Adding existing repo at '\$GIT_I18N_VARIABLE_path' to the index"; echo else - die "$(eval_gettext "'\$path' already exists and is not a valid git repo")" + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "'\$GIT_I18N_VARIABLE_path' already exists and is not a valid git repo")" fi case "$repo" in
@@ -262,16 +278,22 @@ Use -f if you really want to add it." && '') git checkout -f -q ;; ?*) git checkout -f -q -B "$branch" "origin/$branch" ;; esac - ) || die "$(eval_gettext "Unable to checkout submodule '\$path'")" + ) || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Unable to checkout submodule '\$GIT_I18N_VARIABLE_path'")" + } fi - git add $force "$path" || - die "$(eval_gettext "Failed to add submodule '\$path'")" + git add $force "$path" || { + die "$(eval_gettext "Failed to add submodule '\$GIT_I18N_VARIABLE_path'")" + } git config -f .gitmodules submodule."$path".path "$path" && git config -f .gitmodules submodule."$path".url "$repo" && - git add --force .gitmodules || - die "$(eval_gettext "Failed to register submodule '\$path'")" + git add --force .gitmodules || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Failed to register submodule '\$GIT_I18N_VARIABLE_path'")" + } } #
@@ -309,7 +331,9 @@ cmd_foreach() do if test -e "$path"/.git then - say "$(eval_gettext "Entering '\$prefix\$path'")" + GIT_I18N_VARIABLE_prefix=$prefix + GIT_I18N_VARIABLE_path=$path + say "$(eval_gettext "Entering '\$GIT_I18N_VARIABLE_prefix\$GIT_I18N_VARIABLE_path'")" name=$(module_name "$path") ( prefix="$prefix$path/"
@@ -321,7 +345,7 @@ cmd_foreach() cmd_foreach "--recursive" "$@" fi ) || - die "$(eval_gettext "Stopping at '\$path'; script returned non-zero status.")" + die "$(eval_gettext "Stopping at '\$GIT_I18N_VARIABLE_path'; script returned non-zero status.")" fi done }
@@ -363,8 +387,11 @@ cmd_init() test -z "$url" || continue url=$(git config -f .gitmodules submodule."$name".url) - test -z "$url" && - die "$(eval_gettext "No url found for submodule path '\$path' in .gitmodules")" + if test -z "$url" + then + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "No url found for submodule path '\$GIT_I18N_VARIABLE_path' in .gitmodules")" + fi # Possibly a url relative to parent case "$url" in
@@ -373,15 +400,24 @@ cmd_init() ;; esac - git config submodule."$name".url "$url" || - die "$(eval_gettext "Failed to register url for submodule path '\$path'")" + if ! git config submodule."$name".url "$url" + then + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Failed to register url for submodule path '\$GIT_I18N_VARIABLE_path'")" + fi upd="$(git config -f .gitmodules submodule."$name".update)" test -z "$upd" || - git config submodule."$name".update "$upd" || - die "$(eval_gettext "Failed to register update mode for submodule path '\$path'")" + if ! git config submodule."$name".update "$upd" + then + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Failed to register update mode for submodule path '\$GIT_I18N_VARIABLE_path'")" + fi - say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$path'")" + GIT_I18N_VARIABLE_name=$name + GIT_I18N_VARIABLE_url=$url + GIT_I18N_VARIABLE_path=$path + say "$(eval_gettext "Submodule '\$GIT_I18N_VARIABLE_name' (\$GIT_I18N_VARIABLE_url) registered for path '\$GIT_I18N_VARIABLE_path'")" done }
@@ -463,9 +499,11 @@ cmd_update() then # Only mention uninitialized submodules when its # path have been specified - test "$#" != "0" && - say "$(eval_gettext "Submodule path '\$path' not initialized + if test "$#" != "0" + then + say "$(eval_gettext "Submodule path '\$GIT_I18N_VARIABLE_path' not initialized Maybe you want to use 'update --init'?")" + fi continue fi
@@ -476,8 +514,10 @@ Maybe you want to use 'update --init'?")" subsha1= else subsha1=$(clear_local_git_env; cd "$path" && - git rev-parse --verify HEAD) || - die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")" + git rev-parse --verify HEAD) || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Unable to find current revision in submodule path '\$GIT_I18N_VARIABLE_path'")" + } fi if ! test -z "$update"
@@ -500,8 +540,10 @@ Maybe you want to use 'update --init'?")" # is not reachable from a ref. (clear_local_git_env; cd "$path" && ((rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) && - test -z "$rev") || git-fetch)) || - die "$(eval_gettext "Unable to fetch in submodule path '\$path'")" + test -z "$rev") || git-fetch)) || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Unable to fetch in submodule path '\$GIT_I18N_VARIABLE_path'")" + } fi # Is this something we just cloned?
@@ -511,21 +553,23 @@ Maybe you want to use 'update --init'?")" update_module= ;; esac + GIT_I18N_VARIABLE_path=$path + GIT_I18N_VARIABLE_sha1=$sha1 case "$update_module" in rebase) command="git rebase" - die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': rebased into '\$sha1'")" + die_msg="$(eval_gettext "Unable to rebase '\$GIT_I18N_VARIABLE_sha1' in submodule path '\$GIT_I18N_VARIABLE_path'")" + say_msg="$(eval_gettext "Submodule path '\$GIT_I18N_VARIABLE_path': rebased into '\$GIT_I18N_VARIABLE_sha1'")" ;; merge) command="git merge" - die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': merged in '\$sha1'")" + die_msg="$(eval_gettext "Unable to merge '\$GIT_I18N_VARIABLE_sha1' in submodule path '\$GIT_I18N_VARIABLE_path'")" + say_msg="$(eval_gettext "Submodule path '\$GIT_I18N_VARIABLE_path': merged in '\$GIT_I18N_VARIABLE_sha1'")" ;; *) command="git checkout $subforce -q" - die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': checked out '\$sha1'")" + die_msg="$(eval_gettext "Unable to checkout '\$GIT_I18N_VARIABLE_sha1' in submodule path '\$GIT_I18N_VARIABLE_path'")" + say_msg="$(eval_gettext "Submodule path '\$GIT_I18N_VARIABLE_path': checked out '\$GIT_I18N_VARIABLE_sha1'")" ;; esac
@@ -535,8 +579,10 @@ Maybe you want to use 'update --init'?")" if test -n "$recursive" then - (clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags") || - die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" + (clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags") || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Failed to recurse into submodule path '\$GIT_I18N_VARIABLE_path'")" + } fi done }
@@ -661,7 +707,8 @@ cmd_summary() { *) # unexpected type ( - eval_gettext "unexpected mode \$mod_dst" && + GIT_I18N_VARIABLE_mod_dst=$mod_dst + eval_gettext "unexpected mode \$GIT_I18N_VARIABLE_mod_dst" && echo ) >&2 continue ;;
@@ -679,15 +726,18 @@ cmd_summary() { missing_dst=t total_commits= + GIT_I18N_VARIABLE_name=$name + GIT_I18N_VARIABLE_sha1_src=$sha1_src + GIT_I18N_VARIABLE_sha1_dst=$sha1_dst case "$missing_src,$missing_dst" in t,) - errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_src")" + errmsg="$(eval_gettext " Warn: \$GIT_I18N_VARIABLE_name doesn't contain commit \$GIT_I18N_VARIABLE_sha1_src")" ;; ,t) - errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_dst")" + errmsg="$(eval_gettext " Warn: \$GIT_I18N_VARIABLE_name doesn't contain commit \$GIT_I18N_VARIABLE_sha1_dst")" ;; t,t) - errmsg="$(eval_gettext " Warn: \$name doesn't contain commits \$sha1_src and \$sha1_dst")" + errmsg="$(eval_gettext " Warn: \$GIT_I18N_VARIABLE_name doesn't contain commits \$GIT_I18N_VARIABLE_sha1_src and \$sha1_dst")" ;; *) errmsg=
@@ -837,8 +887,10 @@ cmd_status() clear_local_git_env cd "$path" && eval cmd_status "$orig_args" - ) || - die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" + ) || { + GIT_I18N_VARIABLE_path=$path + die "$(eval_gettext "Failed to recurse into submodule path '\$GIT_I18N_VARIABLE_path'")" + } fi done }
@@ -882,7 +934,8 @@ cmd_sync() ;; esac - say "$(eval_gettext "Synchronizing submodule url for '\$name'")" + GIT_I18N_VARIABLE_name=$name + say "$(eval_gettext "Synchronizing submodule url for '\$GIT_I18N_VARIABLE_name'")" git config submodule."$name".url "$url" if test -e "$path"/.git
Signature · 1 line
1.7.5.1
PATCH 6/6 i18n win32: add test eval_gettext variable prefix
In reply to Ævar Arnfjörð BjarmasonChange the eval_gettext() invocations to use the GIT_I18N_VARIABLE_ prefix for variables used in eval_gettext. On Windows environment variables are case insensitive, so e.g. $PATH clashes with $path. By using a sufficiently unique prefix we work around that issue.
--- t/t0201-gettext-fallbacks.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
t/t0201-gettext-fallbacks.sh +2 -2
@@ -41,10 +41,10 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v ' test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces and quotes' ' - cmdline="git am" && + GIT_I18N_VARIABLE_cmdline="git am" && export cmdline; printf "When you have resolved this problem run \"git am --resolved\"." >expect && - eval_gettext "When you have resolved this problem run \"\$cmdline --resolved\"." >actual + eval_gettext "When you have resolved this problem run \"\$GIT_I18N_VARIABLE_cmdline --resolved\"." >actual test_i18ncmp expect actual '
Signature · 1 line
1.7.5.1