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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <ps@xxxxxx>
---
 t/t1509-root-worktree.sh | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/t/t1509-root-worktree.sh b/t/t1509-root-worktree.sh
index 553a3f6..acfa133 100755
--- a/t/t1509-root-worktree.sh
+++ b/t/t1509-root-worktree.sh
@@ -237,6 +237,45 @@ 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"
+	echo "Cloning into '$DIR'..." >expected
+	echo "warning: You appear to have cloned an empty repository." >>expected
+	git clone "$URL" 2>result >result
+	rm -r "$DIR"
+	test_cmp expected result
+}
+
+test_expect_success 'go to /clones' 'mkdir /clones && cd /clones'
+test_expect_success 'simple clone of /' '
+	echo "fatal: No directory name could be guessed." > expected &&
+	echo "Please specify a directory on the command line" >> expected &&
+	test_expect_code 128 git clone / 2>result >result &&
+	test_cmp expected result'
+
+test_expect_success 'clone with file://' '
+	test_clone_expect_dir file://127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://user@' '
+	test_clone_expect_dir file://user@127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://user:password@' '
+	test_clone_expect_dir file://user:password@127.0.0.1/ 127.0.0.1'
+test_expect_success 'clone with file://:port' '
+	test_clone_expect_dir file://127.0.0.1:9999/ 127.0.0.1'
+test_expect_success 'clone with file://user:password@: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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]