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

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

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:06:02

On Wed, Jul 29, 2015 at 11:51 AM, Patrick Steinhardt [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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>
---
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
+'
I'd say something here about current style omitting the space after
the redirection operator (>), however, this script uniformly includes
the space, and being consistent with the existing style is important,
so I won't mention it. ;-)
+test_clone_expect_dir() {
+       URL="$1"
+       DIR="$2"
+       echo "Cloning into '$DIR'..." >expected
+       echo "warning: You appear to have cloned an empty repository." >>expected
    echo >expected <<-\EOF
    Cloning into...
    warning: You appear...
    EOF

is more readable and maintainable.
+       git clone "$URL" 2>result >result
    git clone "$URL" >result 2>&1
+       rm -r "$DIR"
+       test_cmp expected result
+}
While not mandatory since it works as expected in its current form, it
would be nice to see a fully intact &&-chain in this function. That
way, if someone some day adds code which doesn't impact 'result' but
which might somehow fail, then the failure will be noticed.
+
+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 &&
    cat >expected <<-\EOF
    fatal: No directory...
    Please specify...
    EOF
+       test_expect_code 128 git clone / 2>result >result &&
    test_expect_code 128 git clone / >result 2>&1 &&
+       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help