[PATCH 5/6] i18n win32: add git-submodule 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.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
git-submodule.sh | 151 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 102 insertions(+), 49 deletions(-)
Show changes to git-submodule.sh +102 −49
diff --git a/git-submodule.sh b/git-submodule.sh
index c1d3a5e..dea4f63 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
--
1.7.5.1