зеркало из https://github.com/microsoft/git.git
Merge branch 'mg/maint-submodule-normalize-path' into maint
* mg/maint-submodule-normalize-path: git submodule: Fix adding of submodules at paths with ./, .. and // git submodule: Add test cases for git submodule add
This commit is contained in:
Коммит
8af95ca017
|
@ -167,9 +167,18 @@ cmd_add()
|
|||
;;
|
||||
esac
|
||||
|
||||
# strip trailing slashes from path
|
||||
path=$(echo "$path" | sed -e 's|/*$||')
|
||||
|
||||
# normalize path:
|
||||
# multiple //; leading ./; /./; /../; trailing /
|
||||
path=$(printf '%s/\n' "$path" |
|
||||
sed -e '
|
||||
s|//*|/|g
|
||||
s|^\(\./\)*||
|
||||
s|/\./|/|g
|
||||
:start
|
||||
s|\([^/]*\)/\.\./||
|
||||
tstart
|
||||
s|/*$||
|
||||
')
|
||||
git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
|
||||
die "'$path' already exists in the index"
|
||||
|
||||
|
|
|
@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
|
|||
GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
|
||||
'
|
||||
|
||||
test_expect_success 'Prepare submodule add testing' '
|
||||
submodurl=$(pwd)
|
||||
(
|
||||
mkdir addtest &&
|
||||
cd addtest &&
|
||||
git init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add' '
|
||||
(
|
||||
cd addtest &&
|
||||
git submodule add "$submodurl" submod &&
|
||||
git submodule init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add with ./ in path' '
|
||||
(
|
||||
cd addtest &&
|
||||
git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
|
||||
git submodule init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add with // in path' '
|
||||
(
|
||||
cd addtest &&
|
||||
git submodule add "$submodurl" slashslashsubmod///frotz// &&
|
||||
git submodule init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add with /.. in path' '
|
||||
(
|
||||
cd addtest &&
|
||||
git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
|
||||
git submodule init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add with ./, /.. and // in path' '
|
||||
(
|
||||
cd addtest &&
|
||||
git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
|
||||
git submodule init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'status should fail for unmapped paths' '
|
||||
if git submodule status
|
||||
then
|
||||
|
|
Загрузка…
Ссылка в новой задаче