diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-03-11 21:50:29 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-11 21:50:29 +0100 |
commit | 500ff119682eaa6d5047b40e54688219a57716ca (patch) | |
tree | a911f4f85436ea1fd5c8b3f4d5b7b70154156f91 /git-submodule.sh | |
parent | Merge branch 'jc/maint-1.6.0-keep-pack' (diff) | |
parent | git submodule: Fix adding of submodules at paths with ./, .. and // (diff) | |
download | git-500ff119682eaa6d5047b40e54688219a57716ca.tar.xz git-500ff119682eaa6d5047b40e54688219a57716ca.zip |
Merge branch 'mg/maint-submodule-normalize-path'
* mg/maint-submodule-normalize-path:
git submodule: Fix adding of submodules at paths with ./, .. and //
git submodule: Add test cases for git submodule add
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 204aab671e..0a27232b90 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -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" |