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:
Junio C Hamano
2009-03-21 23:08:27 -07:00
2 changed files with 61 additions and 3 deletions

View File

@ -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"