diff options
-rw-r--r-- | builtin/clone.c | 3 | ||||
-rwxr-xr-x | t/t5603-clone-dirname.sh | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index e18839d107..ed484cb6f4 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -174,7 +174,8 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) /* * Strip .{bundle,git}. */ - strip_suffix(start, is_bundle ? ".bundle" : ".git" , &len); + len = end - start; + strip_suffix_mem(start, &len, is_bundle ? ".bundle" : ".git"); if (is_bare) dir = xstrfmt("%.*s.git", (int)len, start); diff --git a/t/t5603-clone-dirname.sh b/t/t5603-clone-dirname.sh index 52f61a090a..765cc434ef 100755 --- a/t/t5603-clone-dirname.sh +++ b/t/t5603-clone-dirname.sh @@ -47,7 +47,7 @@ test_clone_dir host:foo foo.git bare test_clone_dir host:foo.git foo test_clone_dir host:foo.git foo.git bare test_clone_dir host:foo/.git foo -test_clone_dir host:foo/.git foo.git bare fail +test_clone_dir host:foo/.git foo.git bare # similar, but using ssh URL rather than host:path syntax test_clone_dir ssh://host/foo foo @@ -55,22 +55,22 @@ test_clone_dir ssh://host/foo foo.git bare test_clone_dir ssh://host/foo.git foo test_clone_dir ssh://host/foo.git foo.git bare test_clone_dir ssh://host/foo/.git foo -test_clone_dir ssh://host/foo/.git foo.git bare fail +test_clone_dir ssh://host/foo/.git foo.git bare # we should remove trailing slashes and .git suffixes test_clone_dir ssh://host/foo/ foo test_clone_dir ssh://host/foo/// foo test_clone_dir ssh://host/foo/.git/ foo -test_clone_dir ssh://host/foo.git/ foo fail -test_clone_dir ssh://host/foo.git/// foo fail +test_clone_dir ssh://host/foo.git/ foo +test_clone_dir ssh://host/foo.git/// foo test_clone_dir ssh://host/foo///.git/ foo test_clone_dir ssh://host/foo/.git/// foo test_clone_dir host:foo/ foo test_clone_dir host:foo/// foo -test_clone_dir host:foo.git/ foo fail +test_clone_dir host:foo.git/ foo test_clone_dir host:foo/.git/ foo -test_clone_dir host:foo.git/// foo fail +test_clone_dir host:foo.git/// foo test_clone_dir host:foo///.git/ foo test_clone_dir host:foo/.git/// foo |