{"thread":{"id":"38472","subject":"[PATCH] git-submodules.sh: fix '/././' path normalization","startedAt":"2015-01-30T15:14:03Z","lastAt":"2015-02-02T20:02:12Z","messageCount":2,"participants":["Patrick Steinhardt","Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"255433","messageId":"1422630843-9559-1-git-send-email-ps@pks.im","threadId":"38472","inReplyTo":null,"subject":"[PATCH] git-submodules.sh: fix '/././' path normalization","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2015-01-30T15:14:03Z","receivedAt":"2015-01-30T15:14:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When we add a new submodule the path of the submodule is being normalized. We\nfail to normalize multiple adjacent '/./', though. Thus 'path/to/././submodule'\nwill become 'path/to/./submodule' where it should be 'path/to/submodule'\ninstead.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n git-submodule.sh           |  2 +-\n t/t7400-submodule-basic.sh | 17 +++++++++++++++++\n 2 files changed, 18 insertions(+), 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 9245abf..36797c3 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -423,7 +423,7 @@ cmd_add()\n \t\tsed -e '\n \t\t\ts|//*|/|g\n \t\t\ts|^\\(\\./\\)*||\n-\t\t\ts|/\\./|/|g\n+\t\t\ts|/\\(\\./\\)*|/|g\n \t\t\t:start\n \t\t\ts|\\([^/]*\\)/\\.\\./||\n \t\t\ttstart\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 7c88245..5811a98 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '\n \ttest_cmp empty untracked\n '\n \n+test_expect_success 'submodule add with /././ in path' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n+\t(\n+\t\tcd addtest &&\n+\t\tgit submodule add \"$submodurl\" dotslashdotsubmod/././frotz/./ &&\n+\t\tgit submodule init\n+\t) &&\n+\n+\trm -f heads head untracked &&\n+\tinspect addtest/dotslashdotsubmod/frotz ../../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n+'\n+\n test_expect_success 'submodule add with // in path' '\n \techo \"refs/heads/master\" >expect &&\n \t>empty &&\n-- \n2.2.2\n"},{"id":"255534","messageId":"54CFD7C4.4030000@web.de","threadId":"38472","inReplyTo":"1422630843-9559-1-git-send-email-ps@pks.im","subject":"Re: [PATCH] git-submodules.sh: fix '/././' path normalization","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2015-02-02T20:02:12Z","receivedAt":"2015-02-02T20:02:12Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 30.01.2015 um 16:14 schrieb Patrick Steinhardt:\n> When we add a new submodule the path of the submodule is being normalized. We\n> fail to normalize multiple adjacent '/./', though. Thus 'path/to/././submodule'\n> will become 'path/to/./submodule' where it should be 'path/to/submodule'\n> instead.\n\nThanks, nicely done and fixes the issue you noticed: Ack from me.\n\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>   git-submodule.sh           |  2 +-\n>   t/t7400-submodule-basic.sh | 17 +++++++++++++++++\n>   2 files changed, 18 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 9245abf..36797c3 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -423,7 +423,7 @@ cmd_add()\n>   \t\tsed -e '\n>   \t\t\ts|//*|/|g\n>   \t\t\ts|^\\(\\./\\)*||\n> -\t\t\ts|/\\./|/|g\n> +\t\t\ts|/\\(\\./\\)*|/|g\n>   \t\t\t:start\n>   \t\t\ts|\\([^/]*\\)/\\.\\./||\n>   \t\t\ttstart\n> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n> index 7c88245..5811a98 100755\n> --- a/t/t7400-submodule-basic.sh\n> +++ b/t/t7400-submodule-basic.sh\n> @@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '\n>   \ttest_cmp empty untracked\n>   '\n>\n> +test_expect_success 'submodule add with /././ in path' '\n> +\techo \"refs/heads/master\" >expect &&\n> +\t>empty &&\n> +\n> +\t(\n> +\t\tcd addtest &&\n> +\t\tgit submodule add \"$submodurl\" dotslashdotsubmod/././frotz/./ &&\n> +\t\tgit submodule init\n> +\t) &&\n> +\n> +\trm -f heads head untracked &&\n> +\tinspect addtest/dotslashdotsubmod/frotz ../../.. &&\n> +\ttest_cmp expect heads &&\n> +\ttest_cmp expect head &&\n> +\ttest_cmp empty untracked\n> +'\n> +\n>   test_expect_success 'submodule add with // in path' '\n>   \techo \"refs/heads/master\" >expect &&\n>   \t>empty &&\n>\n"}]}