diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-03-21 23:08:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-21 23:08:27 -0700 |
commit | 8af95ca0174f05344e36d05b61844c8af4764b92 (patch) | |
tree | 90af6ed4c1ef939ebf90b0e6be2f0d59638782c2 /git-submodule.sh | |
parent | 2aa93deec047763cff750196610268fd7227cfc9 (diff) | |
parent | db75ada559dd4de99fedd1fc4f62a9273f032dd3 (diff) | |
download | git-8af95ca0174f05344e36d05b61844c8af4764b92.tar.gz |
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
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" |