Re: [PATCH v2 6/6] clone: add tests for cloning with empty path
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jul 30, 2015, 18:18 UTC
- Message-ID
- <CAPig+cQ5wR8xp8erAHBzEMEs62ddULrrML53GNVuuie3kd9EvA@mail.gmail.com>
- In-Reply-To
- <1438185076-28870-7-git-send-email-ps@pks.im>
On Wed, Jul 29, 2015 at 11:51 AM, Patrick Steinhardt <ps@pks.im> wrote:
Show 22 quoted lines
> 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@pks.im> > --- > 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. ;-)
Show 5 quoted lines
> +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...
EOFis 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.
Show 5 quoted lines
> + > +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 &&
Show 20 quoted lines
> + 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