Thread (31 messages) flat view 31 messages, 3 authors, 2016-06-15
STALE3735d

[PATCH v3 6/6] clone: add tests for cloning with empty path

From: Patrick Steinhardt <hidden>
Date: 2016-06-15 23:06:04
Subsystem: the rest · Maintainer: Linus Torvalds

Test behavior of `git clone` when working with an empty path
component. This may be the case when cloning a file system's root
directory or from a remote server's root.

Signed-off-by: Patrick Steinhardt <redacted>
---
 t/t1509-root-worktree.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
diff --git a/t/t1509-root-worktree.sh b/t/t1509-root-worktree.sh
index 553a3f6..d521ca3 100755
--- a/t/t1509-root-worktree.sh
+++ b/t/t1509-root-worktree.sh
@@ -237,6 +237,49 @@ test_foobar_foobar
 
 test_expect_success 'cleanup' 'rm -rf /.git'
 
+say "clone .git at root without reponame"
+
+test_expect_success 'go to /' 'cd /'
+test_expect_success 'setup' '
+	echo "Initialized empty Git repository in /.git/" > expected &&
+	git init > result &&
+	test_cmp expected result
+'
+
+test_clone_expect_dir() {
+	URL="$1"
+	DIR="$2"
+	cat <<-EOF >expected &&
+		Cloning into '$DIR'...
+		warning: You appear to have cloned an empty repository.
+		EOF
+	git clone "$URL" >result 2>&1 &&
+	rm -rf "$DIR" &&
+	test_cmp expected result
+}
+
+test_expect_success 'go to /clones' 'mkdir /clones && cd /clones'
+test_expect_success 'simple clone of /' '
+	cat <<-EOF >expected &&
+		fatal: No directory name could be guessed.
+		Please specify a directory on the command line
+		EOF
+	test_expect_code 128 git clone / >result 2>&1 &&
+	test_cmp expected result'
+
+test_expect_success 'clone with file://host/' '
+	test_clone_expect_dir file://127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://user@host/' '
+	test_clone_expect_dir file://user@127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://user:password@host/' '
+	test_clone_expect_dir file://user:password@127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://host:port/' '
+	test_clone_expect_dir file://127.0.0.1:9999/ 127.0.0.1'
+test_expect_success 'clone with file://user:password@host:port' '
+	test_clone_expect_dir file://user:password@127.0.0.1:9999/ 127.0.0.1'
+
+test_expect_success 'cleanup' 'rm -rf /.git /clones'
+
 say "auto bare gitdir"
 
 # DESTROYYYYY!!!!!
-- 
2.5.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help