{"thread":{"id":"30267","subject":"[PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","startedAt":"2012-04-17T18:00:58Z","lastAt":"2012-04-24T17:32:35Z","messageCount":6,"participants":["Ramsay Jones","Jens Lehmann","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"189554","messageId":"4F8DAFDA.1020108@ramsay1.demon.co.uk","threadId":"30267","inReplyTo":null,"subject":"[PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-04-17T18:00:58Z","receivedAt":"2012-04-17T18:00:58Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nThe eval_gettext (and eval_gettextln) i18n shell functions call\ngit-sh-i18n--envsubst to process the variable references in the\nstring parameter. Unfortunately, environment variables are case\ninsensitive on windows, which leads to failure on cygwin when\neval_gettext exports $path.\n\nCommit df599e9 (Windows: teach getenv to do a case-sensitive search,\n06-06-2011) attempts to solve this problem on MinGW by overriding\nthe system getenv() function to allow git-sh-i18n--envsubst to read\n$path rather than $PATH from the environment. However, this commit\ndoes not address cygwin at all and, furthermore, does not fix all\nproblems on MinGW.\n\nIn particular, when executing test #38 in t7400-submodule-basic.sh,\nan 'git-sh-i18n-envsubst.exe - Unable To Locate Component' dialog\npops up saying that the application \"failed to start because\nlibiconv2.dll was not found.\" After studying the voluminous trace\noutput from the process monitor, it is clear that the system is\nattempting to use $path, rather than $PATH, to search for the DLL\nfile. (Note that, after dismissing the dialog, the test passes\nanyway!)\n\nAs an alternative, we finesse the problem by renaming the $path\nvariable to $sm_path (submodule path). This fixes the problem on\nMinGW along with all test failures on cygwin (t7400.{7,32,34},\nt7406.3 and t7407.{2,6}). We note that the foreach subcommand\nprovides $path to user scripts (ie it is part of the API), so we\ncan't simply rename it to $sm_path.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Junio,\n\nThis patch is based on the next branch, since there is a (simple)\nconflict with Ben's commit c5bc42b9 (\"Avoid bug in Solaris xpg4/sed\nas used in submodule\", 09-04-2012).\n\nATB,\nRamsay Jones\n\n git-submodule.sh |  161 +++++++++++++++++++++++++++---------------------------\n 1 file changed, 82 insertions(+), 79 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3d94a14..64a70d6 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -101,11 +101,12 @@ module_list()\n module_name()\n {\n \t# Do we have \"submodule.<something>.path = $1\" defined in .gitmodules file?\n+\tsm_path=\"$1\"\n \tre=$(printf '%s\\n' \"$1\" | sed -e 's/[].[^$\\\\*]/\\\\&/g')\n \tname=$( git config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n \t\tsed -n -e 's|^submodule\\.\\(.*\\)\\.path '\"$re\"'$|\\1|p' )\n \ttest -z \"$name\" &&\n-\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$path'\")\"\n+\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$sm_path'\")\"\n \techo \"$name\"\n }\n \n@@ -119,7 +120,7 @@ module_name()\n #\n module_clone()\n {\n-\tpath=$1\n+\tsm_path=$1\n \turl=$2\n \treference=\"$3\"\n \tquiet=\n@@ -130,8 +131,8 @@ module_clone()\n \n \tgitdir=\n \tgitdir_base=\n-\tname=$(module_name \"$path\" 2>/dev/null)\n-\ttest -n \"$name\" || name=\"$path\"\n+\tname=$(module_name \"$sm_path\" 2>/dev/null)\n+\ttest -n \"$name\" || name=\"$sm_path\"\n \tbase_name=$(dirname \"$name\")\n \n \tgitdir=$(git rev-parse --git-dir)\n@@ -140,17 +141,17 @@ module_clone()\n \n \tif test -d \"$gitdir\"\n \tthen\n-\t\tmkdir -p \"$path\"\n+\t\tmkdir -p \"$sm_path\"\n \t\trm -f \"$gitdir/index\"\n \telse\n \t\tmkdir -p \"$gitdir_base\"\n \t\tgit clone $quiet -n ${reference:+\"$reference\"} \\\n-\t\t\t--separate-git-dir \"$gitdir\" \"$url\" \"$path\" ||\n-\t\tdie \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$path' failed\")\"\n+\t\t\t--separate-git-dir \"$gitdir\" \"$url\" \"$sm_path\" ||\n+\t\tdie \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$sm_path' failed\")\"\n \tfi\n \n \ta=$(cd \"$gitdir\" && pwd)/\n-\tb=$(cd \"$path\" && pwd)/\n+\tb=$(cd \"$sm_path\" && pwd)/\n \t# normalize Windows-style absolute paths to POSIX-style absolute paths\n \tcase $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac\n \tcase $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac\n@@ -169,10 +170,10 @@ module_clone()\n \n \t# Turn each leading \"*/\" component into \"../\"\n \trel=$(echo $b | sed -e 's|[^/][^/]*|..|g')\n-\techo \"gitdir: $rel/$a\" >\"$path/.git\"\n+\techo \"gitdir: $rel/$a\" >\"$sm_path/.git\"\n \n \trel=$(echo $a | sed -e 's|[^/][^/]*|..|g')\n-\t(clear_local_git_env; cd \"$path\" && GIT_WORK_TREE=. git config core.worktree \"$rel/$b\")\n+\t(clear_local_git_env; cd \"$sm_path\" && GIT_WORK_TREE=. git config core.worktree \"$rel/$b\")\n }\n \n #\n@@ -223,14 +224,14 @@ cmd_add()\n \tdone\n \n \trepo=$1\n-\tpath=$2\n+\tsm_path=$2\n \n-\tif test -z \"$path\"; then\n-\t\tpath=$(echo \"$repo\" |\n+\tif test -z \"$sm_path\"; then\n+\t\tsm_path=$(echo \"$repo\" |\n \t\t\tsed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n \tfi\n \n-\tif test -z \"$repo\" -o -z \"$path\"; then\n+\tif test -z \"$repo\" -o -z \"$sm_path\"; then\n \t\tusage\n \tfi\n \n@@ -251,7 +252,7 @@ cmd_add()\n \n \t# normalize path:\n \t# multiple //; leading ./; /./; /../; trailing /\n-\tpath=$(printf '%s/\\n' \"$path\" |\n+\tsm_path=$(printf '%s/\\n' \"$sm_path\" |\n \t\tsed -e '\n \t\t\ts|//*|/|g\n \t\t\ts|^\\(\\./\\)*||\n@@ -261,49 +262,49 @@ cmd_add()\n \t\t\ttstart\n \t\t\ts|/*$||\n \t\t')\n-\tgit ls-files --error-unmatch \"$path\" > /dev/null 2>&1 &&\n-\tdie \"$(eval_gettext \"'\\$path' already exists in the index\")\"\n+\tgit ls-files --error-unmatch \"$sm_path\" > /dev/null 2>&1 &&\n+\tdie \"$(eval_gettext \"'\\$sm_path' already exists in the index\")\"\n \n-\tif test -z \"$force\" && ! git add --dry-run --ignore-missing \"$path\" > /dev/null 2>&1\n+\tif test -z \"$force\" && ! git add --dry-run --ignore-missing \"$sm_path\" > /dev/null 2>&1\n \tthen\n \t\teval_gettextln \"The following path is ignored by one of your .gitignore files:\n-\\$path\n+\\$sm_path\n Use -f if you really want to add it.\" >&2\n \t\texit 1\n \tfi\n \n \t# perhaps the path exists and is already a git repo, else clone it\n-\tif test -e \"$path\"\n+\tif test -e \"$sm_path\"\n \tthen\n-\t\tif test -d \"$path\"/.git -o -f \"$path\"/.git\n+\t\tif test -d \"$sm_path\"/.git -o -f \"$sm_path\"/.git\n \t\tthen\n-\t\t\teval_gettextln \"Adding existing repo at '\\$path' to the index\"\n+\t\t\teval_gettextln \"Adding existing repo at '\\$sm_path' to the index\"\n \t\telse\n-\t\t\tdie \"$(eval_gettext \"'\\$path' already exists and is not a valid git repo\")\"\n+\t\t\tdie \"$(eval_gettext \"'\\$sm_path' already exists and is not a valid git repo\")\"\n \t\tfi\n \n \telse\n \n-\t\tmodule_clone \"$path\" \"$realrepo\" \"$reference\" || exit\n+\t\tmodule_clone \"$sm_path\" \"$realrepo\" \"$reference\" || exit\n \t\t(\n \t\t\tclear_local_git_env\n-\t\t\tcd \"$path\" &&\n+\t\t\tcd \"$sm_path\" &&\n \t\t\t# ash fails to wordsplit ${branch:+-b \"$branch\"...}\n \t\t\tcase \"$branch\" in\n \t\t\t'') git checkout -f -q ;;\n \t\t\t?*) git checkout -f -q -B \"$branch\" \"origin/$branch\" ;;\n \t\t\tesac\n-\t\t) || die \"$(eval_gettext \"Unable to checkout submodule '\\$path'\")\"\n+\t\t) || die \"$(eval_gettext \"Unable to checkout submodule '\\$sm_path'\")\"\n \tfi\n-\tgit config submodule.\"$path\".url \"$realrepo\"\n+\tgit config submodule.\"$sm_path\".url \"$realrepo\"\n \n-\tgit add $force \"$path\" ||\n-\tdie \"$(eval_gettext \"Failed to add submodule '\\$path'\")\"\n+\tgit add $force \"$sm_path\" ||\n+\tdie \"$(eval_gettext \"Failed to add submodule '\\$sm_path'\")\"\n \n-\tgit config -f .gitmodules submodule.\"$path\".path \"$path\" &&\n-\tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" &&\n+\tgit config -f .gitmodules submodule.\"$sm_path\".path \"$sm_path\" &&\n+\tgit config -f .gitmodules submodule.\"$sm_path\".url \"$repo\" &&\n \tgit add --force .gitmodules ||\n-\tdie \"$(eval_gettext \"Failed to register submodule '\\$path'\")\"\n+\tdie \"$(eval_gettext \"Failed to register submodule '\\$sm_path'\")\"\n }\n \n #\n@@ -341,23 +342,25 @@ cmd_foreach()\n \texec 3<&0\n \n \tmodule_list |\n-\twhile read mode sha1 stage path\n+\twhile read mode sha1 stage sm_path\n \tdo\n-\t\tif test -e \"$path\"/.git\n+\t\tif test -e \"$sm_path\"/.git\n \t\tthen\n-\t\t\tsay \"$(eval_gettext \"Entering '\\$prefix\\$path'\")\"\n-\t\t\tname=$(module_name \"$path\")\n+\t\t\tsay \"$(eval_gettext \"Entering '\\$prefix\\$sm_path'\")\"\n+\t\t\tname=$(module_name \"$sm_path\")\n \t\t\t(\n-\t\t\t\tprefix=\"$prefix$path/\"\n+\t\t\t\tprefix=\"$prefix$sm_path/\"\n \t\t\t\tclear_local_git_env\n-\t\t\t\tcd \"$path\" &&\n+\t\t\t\t# we make $path available to scripts ...\n+\t\t\t\tpath=$sm_path\n+\t\t\t\tcd \"$sm_path\" &&\n \t\t\t\teval \"$@\" &&\n \t\t\t\tif test -n \"$recursive\"\n \t\t\t\tthen\n \t\t\t\t\tcmd_foreach \"--recursive\" \"$@\"\n \t\t\t\tfi\n \t\t\t) <&3 3<&- ||\n-\t\t\tdie \"$(eval_gettext \"Stopping at '\\$path'; script returned non-zero status.\")\"\n+\t\t\tdie \"$(eval_gettext \"Stopping at '\\$sm_path'; script returned non-zero status.\")\"\n \t\tfi\n \tdone\n }\n@@ -391,15 +394,15 @@ cmd_init()\n \tdone\n \n \tmodule_list \"$@\" |\n-\twhile read mode sha1 stage path\n+\twhile read mode sha1 stage sm_path\n \tdo\n \t\t# Skip already registered paths\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$sm_path\") || exit\n \t\tif test -z \"$(git config \"submodule.$name.url\")\"\n \t\tthen\n \t\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n \t\t\ttest -z \"$url\" &&\n-\t\t\tdie \"$(eval_gettext \"No url found for submodule path '\\$path' in .gitmodules\")\"\n+\t\t\tdie \"$(eval_gettext \"No url found for submodule path '\\$sm_path' in .gitmodules\")\"\n \n \t\t\t# Possibly a url relative to parent\n \t\t\tcase \"$url\" in\n@@ -408,7 +411,7 @@ cmd_init()\n \t\t\t\t;;\n \t\t\tesac\n \t\t\tgit config submodule.\"$name\".url \"$url\" ||\n-\t\t\tdie \"$(eval_gettext \"Failed to register url for submodule path '\\$path'\")\"\n+\t\t\tdie \"$(eval_gettext \"Failed to register url for submodule path '\\$sm_path'\")\"\n \t\tfi\n \n \t\t# Copy \"update\" setting when it is not set yet\n@@ -416,9 +419,9 @@ cmd_init()\n \t\ttest -z \"$upd\" ||\n \t\ttest -n \"$(git config submodule.\"$name\".update)\" ||\n \t\tgit config submodule.\"$name\".update \"$upd\" ||\n-\t\tdie \"$(eval_gettext \"Failed to register update mode for submodule path '\\$path'\")\"\n+\t\tdie \"$(eval_gettext \"Failed to register update mode for submodule path '\\$sm_path'\")\"\n \n-\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) registered for path '\\$path'\")\"\n+\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) registered for path '\\$sm_path'\")\"\n \tdone\n }\n \n@@ -490,14 +493,14 @@ cmd_update()\n \tcloned_modules=\n \tmodule_list \"$@\" | {\n \terr=\n-\twhile read mode sha1 stage path\n+\twhile read mode sha1 stage sm_path\n \tdo\n \t\tif test \"$stage\" = U\n \t\tthen\n-\t\t\techo >&2 \"Skipping unmerged submodule $path\"\n+\t\t\techo >&2 \"Skipping unmerged submodule $sm_path\"\n \t\t\tcontinue\n \t\tfi\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$sm_path\") || exit\n \t\turl=$(git config submodule.\"$name\".url)\n \t\tif ! test -z \"$update\"\n \t\tthen\n@@ -508,7 +511,7 @@ cmd_update()\n \n \t\tif test \"$update_module\" = \"none\"\n \t\tthen\n-\t\t\techo \"Skipping submodule '$path'\"\n+\t\t\techo \"Skipping submodule '$sm_path'\"\n \t\t\tcontinue\n \t\tfi\n \n@@ -517,20 +520,20 @@ cmd_update()\n \t\t\t# Only mention uninitialized submodules when its\n \t\t\t# path have been specified\n \t\t\ttest \"$#\" != \"0\" &&\n-\t\t\tsay \"$(eval_gettext \"Submodule path '\\$path' not initialized\n+\t\t\tsay \"$(eval_gettext \"Submodule path '\\$sm_path' not initialized\n Maybe you want to use 'update --init'?\")\"\n \t\t\tcontinue\n \t\tfi\n \n-\t\tif ! test -d \"$path\"/.git -o -f \"$path\"/.git\n+\t\tif ! test -d \"$sm_path\"/.git -o -f \"$sm_path\"/.git\n \t\tthen\n-\t\t\tmodule_clone \"$path\" \"$url\" \"$reference\"|| exit\n+\t\t\tmodule_clone \"$sm_path\" \"$url\" \"$reference\"|| exit\n \t\t\tcloned_modules=\"$cloned_modules;$name\"\n \t\t\tsubsha1=\n \t\telse\n-\t\t\tsubsha1=$(clear_local_git_env; cd \"$path\" &&\n+\t\t\tsubsha1=$(clear_local_git_env; cd \"$sm_path\" &&\n \t\t\t\tgit rev-parse --verify HEAD) ||\n-\t\t\tdie \"$(eval_gettext \"Unable to find current revision in submodule path '\\$path'\")\"\n+\t\t\tdie \"$(eval_gettext \"Unable to find current revision in submodule path '\\$sm_path'\")\"\n \t\tfi\n \n \t\tif test \"$subsha1\" != \"$sha1\"\n@@ -546,10 +549,10 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tthen\n \t\t\t\t# Run fetch only if $sha1 isn't present or it\n \t\t\t\t# is not reachable from a ref.\n-\t\t\t\t(clear_local_git_env; cd \"$path\" &&\n+\t\t\t\t(clear_local_git_env; cd \"$sm_path\" &&\n \t\t\t\t\t( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&\n \t\t\t\t\t test -z \"$rev\") || git-fetch)) ||\n-\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$path'\")\"\n+\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n \t\t\tfi\n \n \t\t\t# Is this something we just cloned?\n@@ -563,24 +566,24 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tcase \"$update_module\" in\n \t\t\trebase)\n \t\t\t\tcommand=\"git rebase\"\n-\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to rebase '\\$sha1' in submodule path '\\$path'\")\"\n-\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$path': rebased into '\\$sha1'\")\"\n+\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to rebase '\\$sha1' in submodule path '\\$sm_path'\")\"\n+\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$sm_path': rebased into '\\$sha1'\")\"\n \t\t\t\tmust_die_on_failure=yes\n \t\t\t\t;;\n \t\t\tmerge)\n \t\t\t\tcommand=\"git merge\"\n-\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to merge '\\$sha1' in submodule path '\\$path'\")\"\n-\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$path': merged in '\\$sha1'\")\"\n+\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to merge '\\$sha1' in submodule path '\\$sm_path'\")\"\n+\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$sm_path': merged in '\\$sha1'\")\"\n \t\t\t\tmust_die_on_failure=yes\n \t\t\t\t;;\n \t\t\t*)\n \t\t\t\tcommand=\"git checkout $subforce -q\"\n-\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to checkout '\\$sha1' in submodule path '\\$path'\")\"\n-\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$path': checked out '\\$sha1'\")\"\n+\t\t\t\tdie_msg=\"$(eval_gettext \"Unable to checkout '\\$sha1' in submodule path '\\$sm_path'\")\"\n+\t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$sm_path': checked out '\\$sha1'\")\"\n \t\t\t\t;;\n \t\t\tesac\n \n-\t\t\tif (clear_local_git_env; cd \"$path\" && $command \"$sha1\")\n+\t\t\tif (clear_local_git_env; cd \"$sm_path\" && $command \"$sha1\")\n \t\t\tthen\n \t\t\t\tsay \"$say_msg\"\n \t\t\telif test -n \"$must_die_on_failure\"\n@@ -594,11 +597,11 @@ Maybe you want to use 'update --init'?\")\"\n \n \t\tif test -n \"$recursive\"\n \t\tthen\n-\t\t\t(clear_local_git_env; cd \"$path\" && eval cmd_update \"$orig_flags\")\n+\t\t\t(clear_local_git_env; cd \"$sm_path\" && eval cmd_update \"$orig_flags\")\n \t\t\tres=$?\n \t\t\tif test $res -gt 0\n \t\t\tthen\n-\t\t\t\tdie_msg=\"$(eval_gettext \"Failed to recurse into submodule path '\\$path'\")\"\n+\t\t\t\tdie_msg=\"$(eval_gettext \"Failed to recurse into submodule path '\\$sm_path'\")\"\n \t\t\t\tif test $res -eq 1\n \t\t\t\tthen\n \t\t\t\t\terr=\"${err};$die_msg\"\n@@ -885,30 +888,30 @@ cmd_status()\n \tdone\n \n \tmodule_list \"$@\" |\n-\twhile read mode sha1 stage path\n+\twhile read mode sha1 stage sm_path\n \tdo\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$sm_path\") || exit\n \t\turl=$(git config submodule.\"$name\".url)\n-\t\tdisplaypath=\"$prefix$path\"\n+\t\tdisplaypath=\"$prefix$sm_path\"\n \t\tif test \"$stage\" = U\n \t\tthen\n \t\t\tsay \"U$sha1 $displaypath\"\n \t\t\tcontinue\n \t\tfi\n-\t\tif test -z \"$url\" || ! test -d \"$path\"/.git -o -f \"$path\"/.git\n+\t\tif test -z \"$url\" || ! test -d \"$sm_path\"/.git -o -f \"$sm_path\"/.git\n \t\tthen\n \t\t\tsay \"-$sha1 $displaypath\"\n \t\t\tcontinue;\n \t\tfi\n-\t\tset_name_rev \"$path\" \"$sha1\"\n-\t\tif git diff-files --ignore-submodules=dirty --quiet -- \"$path\"\n+\t\tset_name_rev \"$sm_path\" \"$sha1\"\n+\t\tif git diff-files --ignore-submodules=dirty --quiet -- \"$sm_path\"\n \t\tthen\n \t\t\tsay \" $sha1 $displaypath$revname\"\n \t\telse\n \t\t\tif test -z \"$cached\"\n \t\t\tthen\n-\t\t\t\tsha1=$(clear_local_git_env; cd \"$path\" && git rev-parse --verify HEAD)\n-\t\t\t\tset_name_rev \"$path\" \"$sha1\"\n+\t\t\t\tsha1=$(clear_local_git_env; cd \"$sm_path\" && git rev-parse --verify HEAD)\n+\t\t\t\tset_name_rev \"$sm_path\" \"$sha1\"\n \t\t\tfi\n \t\t\tsay \"+$sha1 $displaypath$revname\"\n \t\tfi\n@@ -918,10 +921,10 @@ cmd_status()\n \t\t\t(\n \t\t\t\tprefix=\"$displaypath/\"\n \t\t\t\tclear_local_git_env\n-\t\t\t\tcd \"$path\" &&\n+\t\t\t\tcd \"$sm_path\" &&\n \t\t\t\teval cmd_status \"$orig_args\"\n \t\t\t) ||\n-\t\t\tdie \"$(eval_gettext \"Failed to recurse into submodule path '\\$path'\")\"\n+\t\t\tdie \"$(eval_gettext \"Failed to recurse into submodule path '\\$sm_path'\")\"\n \t\tfi\n \tdone\n }\n@@ -953,9 +956,9 @@ cmd_sync()\n \tdone\n \tcd_to_toplevel\n \tmodule_list \"$@\" |\n-\twhile read mode sha1 stage path\n+\twhile read mode sha1 stage sm_path\n \tdo\n-\t\tname=$(module_name \"$path\")\n+\t\tname=$(module_name \"$sm_path\")\n \t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n \n \t\t# Possibly a url relative to parent\n@@ -970,11 +973,11 @@ cmd_sync()\n \t\t\tsay \"$(eval_gettext \"Synchronizing submodule url for '\\$name'\")\"\n \t\t\tgit config submodule.\"$name\".url \"$url\"\n \n-\t\t\tif test -e \"$path\"/.git\n+\t\t\tif test -e \"$sm_path\"/.git\n \t\t\tthen\n \t\t\t(\n \t\t\t\tclear_local_git_env\n-\t\t\t\tcd \"$path\"\n+\t\t\t\tcd \"$sm_path\"\n \t\t\t\tremote=$(get_default_remote)\n \t\t\t\tgit config remote.\"$remote\".url \"$url\"\n \t\t\t)\n-- \n1.7.10\n"},{"id":"189619","messageId":"4F8EA009.5080405@web.de","threadId":"30267","inReplyTo":"4F8DAFDA.1020108@ramsay1.demon.co.uk","subject":"Re: [PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-04-18T11:05:45Z","receivedAt":"2012-04-18T11:05:45Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 17.04.2012 20:00, schrieb Ramsay Jones:\n> \n> The eval_gettext (and eval_gettextln) i18n shell functions call\n> git-sh-i18n--envsubst to process the variable references in the\n> string parameter. Unfortunately, environment variables are case\n> insensitive on windows, which leads to failure on cygwin when\n> eval_gettext exports $path.\n> \n> Commit df599e9 (Windows: teach getenv to do a case-sensitive search,\n> 06-06-2011) attempts to solve this problem on MinGW by overriding\n> the system getenv() function to allow git-sh-i18n--envsubst to read\n> $path rather than $PATH from the environment. However, this commit\n> does not address cygwin at all and, furthermore, does not fix all\n> problems on MinGW.\n> \n> In particular, when executing test #38 in t7400-submodule-basic.sh,\n> an 'git-sh-i18n-envsubst.exe - Unable To Locate Component' dialog\n> pops up saying that the application \"failed to start because\n> libiconv2.dll was not found.\" After studying the voluminous trace\n> output from the process monitor, it is clear that the system is\n> attempting to use $path, rather than $PATH, to search for the DLL\n> file. (Note that, after dismissing the dialog, the test passes\n> anyway!)\n> \n> As an alternative, we finesse the problem by renaming the $path\n> variable to $sm_path (submodule path). This fixes the problem on\n> MinGW along with all test failures on cygwin (t7400.{7,32,34},\n> t7406.3 and t7407.{2,6}). We note that the foreach subcommand\n> provides $path to user scripts (ie it is part of the API), so we\n> can't simply rename it to $sm_path.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n> ---\n\nTo me it makes sense to rename the problematic $path variable to\nget rid of this problem.\n\n>  git-submodule.sh |  161 +++++++++++++++++++++++++++---------------------------\n>  1 file changed, 82 insertions(+), 79 deletions(-)\n> \n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 3d94a14..64a70d6 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -101,11 +101,12 @@ module_list()\n>  module_name()\n>  {\n>  \t# Do we have \"submodule.<something>.path = $1\" defined in .gitmodules file?\n> +\tsm_path=\"$1\"\n>  \tre=$(printf '%s\\n' \"$1\" | sed -e 's/[].[^$\\\\*]/\\\\&/g')\n>  \tname=$( git config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n>  \t\tsed -n -e 's|^submodule\\.\\(.*\\)\\.path '\"$re\"'$|\\1|p' )\n>  \ttest -z \"$name\" &&\n> -\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$path'\")\"\n> +\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$sm_path'\")\"\n>  \techo \"$name\"\n>  }\n\nAnd as an extra this part fixes the bug that the die won't print the\nsubmodule path in case of an error as to do that it would have had\nto use $1 here ;-)\n"},{"id":"189636","messageId":"4F8F03C7.7000309@kdbg.org","threadId":"30267","inReplyTo":"4F8EA009.5080405@web.de","subject":"Re: [PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-04-18T18:11:19Z","receivedAt":"2012-04-18T18:11:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 18.04.2012 13:05, schrieb Jens Lehmann:\n> Am 17.04.2012 20:00, schrieb Ramsay Jones:\n>> In particular, when executing test #38 in t7400-submodule-basic.sh,\n>> an 'git-sh-i18n-envsubst.exe - Unable To Locate Component' dialog\n>> pops up saying that the application \"failed to start because\n>> libiconv2.dll was not found.\"\n\nI also observed this error, and this patch fixes it (and at that also\npasses the test suite).\n\nThanks, Ramsay!\n\n-- Hannes\n"},{"id":"189654","messageId":"4F8F1EAC.5040704@ramsay1.demon.co.uk","threadId":"30267","inReplyTo":"4F8EA009.5080405@web.de","subject":"Re: [PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-04-18T20:06:04Z","receivedAt":"2012-04-18T20:06:04Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Jens Lehmann wrote:\n>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n>> ---\n> \n> To me it makes sense to rename the problematic $path variable to\n> get rid of this problem.\n\n>>  git-submodule.sh |  161 +++++++++++++++++++++++++++---------------------------\n>>  1 file changed, 82 insertions(+), 79 deletions(-)\n>>\n>> diff --git a/git-submodule.sh b/git-submodule.sh\n>> index 3d94a14..64a70d6 100755\n>> --- a/git-submodule.sh\n>> +++ b/git-submodule.sh\n>> @@ -101,11 +101,12 @@ module_list()\n>>  module_name()\n>>  {\n>>  \t# Do we have \"submodule.<something>.path = $1\" defined in .gitmodules file?\n>> +\tsm_path=\"$1\"\n>>  \tre=$(printf '%s\\n' \"$1\" | sed -e 's/[].[^$\\\\*]/\\\\&/g')\n>>  \tname=$( git config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n>>  \t\tsed -n -e 's|^submodule\\.\\(.*\\)\\.path '\"$re\"'$|\\1|p' )\n>>  \ttest -z \"$name\" &&\n>> -\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$path'\")\"\n>> +\tdie \"$(eval_gettext \"No submodule mapping found in .gitmodules for path '\\$sm_path'\")\"\n>>  \techo \"$name\"\n>>  }\n> \n> And as an extra this part fixes the bug that the die won't print the\n> submodule path in case of an error as to do that it would have had\n> to use $1 here ;-)\n\nYes, I noted that this was an independent fix when I first sent this to the\nlist (as an RFC) in the v1.7.8 rc time frame.\n\nI had intended to either add a separate patch to fix this, or note it in the commit\nmessage, but I obviously forgot.\n\n[Junio, which alternative would you prefer?]\n\nThanks!\n\nATB,\nRamsay Jones\n"},{"id":"189675","messageId":"7v4nsgk3os.fsf@alter.siamese.dyndns.org","threadId":"30267","inReplyTo":"4F8DAFDA.1020108@ramsay1.demon.co.uk","subject":"Re: [PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-18T23:42:11Z","receivedAt":"2012-04-18T23:42:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> As an alternative, we finesse the problem by renaming the $path\n> variable to $sm_path (submodule path). This fixes the problem on\n> MinGW along with all test failures on cygwin (t7400.{7,32,34},\n> t7406.3 and t7407.{2,6}). We note that the foreach subcommand\n> provides $path to user scripts (ie it is part of the API), so we\n> can't simply rename it to $sm_path.\n\nWhich might mean that foreach is unusable on systems whose environment\nvariables are case insensitive, as whatever command spawned by foreach\nhas its $PATH clobberred.  It is not a regression to them, so it is not\nurgent to address it, but going forward, perhaps we can encourage users\nof _all_ platforms to use $sm_path for portability?\n"},{"id":"189973","messageId":"4F96E3B3.2080408@ramsay1.demon.co.uk","threadId":"30267","inReplyTo":"7v4nsgk3os.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-submodule.sh: Don't use $path variable in eval_gettext string","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-04-24T17:32:35Z","receivedAt":"2012-04-24T17:32:35Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n> \n>> As an alternative, we finesse the problem by renaming the $path\n>> variable to $sm_path (submodule path). This fixes the problem on\n>> MinGW along with all test failures on cygwin (t7400.{7,32,34},\n>> t7406.3 and t7407.{2,6}). We note that the foreach subcommand\n>> provides $path to user scripts (ie it is part of the API), so we\n>> can't simply rename it to $sm_path.\n> \n> Which might mean that foreach is unusable on systems whose environment\n> variables are case insensitive, as whatever command spawned by foreach\n> has its $PATH clobberred.  \n\n[sorry for the late reply; I've been away from email for nearly a week.]\n\nNo, the foreach command is (mostly) fine; given the fact that the user\nscript is eval-ed in a context in which $path is not exported. The reason\nfor the 'mostly' is simply that the user could shoot himself in the\nfoot by export-ing $path in their script, so that something like:\n\n    $ git submodule foreach 'export path; echo $path `git rev-parse HEAD`'\n\nwill indeed fail (ie git rev-parse will not execute).\n\nHow likely is this to happen? I suspect it would be somewhat rare.\n\nHmm, does it deserve a note in the docs?\n\n>                            It is not a regression to them, so it is not\n> urgent to address it, but going forward, perhaps we can encourage users\n> of _all_ platforms to use $sm_path for portability?\n\nMaybe, but I don't have strong feelings either way. Using $sm_path rather\nthan $path would, of course, eliminate even the above (very unlikely)\nproblem ...\n\nATB,\nRamsay Jones\n"}]}