* [PATCH] git-submodules.sh: fix '/././' path normalization
@ 2015-01-30 15:14 Patrick Steinhardt
2015-02-02 20:02 ` Jens Lehmann
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Steinhardt @ 2015-01-30 15:14 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt
When we add a new submodule the path of the submodule is being normalized. We
fail to normalize multiple adjacent '/./', though. Thus 'path/to/././submodule'
will become 'path/to/./submodule' where it should be 'path/to/submodule'
instead.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
git-submodule.sh | 2 +-
t/t7400-submodule-basic.sh | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 9245abf..36797c3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -423,7 +423,7 @@ cmd_add()
sed -e '
s|//*|/|g
s|^\(\./\)*||
- s|/\./|/|g
+ s|/\(\./\)*|/|g
:start
s|\([^/]*\)/\.\./||
tstart
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 7c88245..5811a98 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '
test_cmp empty untracked
'
+test_expect_success 'submodule add with /././ in path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
+ (
+ cd addtest &&
+ git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
+ git submodule init
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/dotslashdotsubmod/frotz ../../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
+'
+
test_expect_success 'submodule add with // in path' '
echo "refs/heads/master" >expect &&
>empty &&
--
2.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] git-submodules.sh: fix '/././' path normalization
2015-01-30 15:14 [PATCH] git-submodules.sh: fix '/././' path normalization Patrick Steinhardt
@ 2015-02-02 20:02 ` Jens Lehmann
0 siblings, 0 replies; 2+ messages in thread
From: Jens Lehmann @ 2015-02-02 20:02 UTC (permalink / raw)
To: Patrick Steinhardt, git; +Cc: Junio C Hamano
Am 30.01.2015 um 16:14 schrieb Patrick Steinhardt:
> When we add a new submodule the path of the submodule is being normalized. We
> fail to normalize multiple adjacent '/./', though. Thus 'path/to/././submodule'
> will become 'path/to/./submodule' where it should be 'path/to/submodule'
> instead.
Thanks, nicely done and fixes the issue you noticed: Ack from me.
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> git-submodule.sh | 2 +-
> t/t7400-submodule-basic.sh | 17 +++++++++++++++++
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 9245abf..36797c3 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -423,7 +423,7 @@ cmd_add()
> sed -e '
> s|//*|/|g
> s|^\(\./\)*||
> - s|/\./|/|g
> + s|/\(\./\)*|/|g
> :start
> s|\([^/]*\)/\.\./||
> tstart
> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index 7c88245..5811a98 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '
> test_cmp empty untracked
> '
>
> +test_expect_success 'submodule add with /././ in path' '
> + echo "refs/heads/master" >expect &&
> + >empty &&
> +
> + (
> + cd addtest &&
> + git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
> + git submodule init
> + ) &&
> +
> + rm -f heads head untracked &&
> + inspect addtest/dotslashdotsubmod/frotz ../../.. &&
> + test_cmp expect heads &&
> + test_cmp expect head &&
> + test_cmp empty untracked
> +'
> +
> test_expect_success 'submodule add with // in path' '
> echo "refs/heads/master" >expect &&
> >empty &&
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-02 20:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 15:14 [PATCH] git-submodules.sh: fix '/././' path normalization Patrick Steinhardt
2015-02-02 20:02 ` Jens Lehmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).