2007-11-07 04:29:20 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git ls-remote'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
>file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git tag mark &&
|
|
|
|
git show-ref --tags -d | sed -e "s/ / /" >expected.tag &&
|
|
|
|
(
|
|
|
|
echo "$(git rev-parse HEAD) HEAD"
|
|
|
|
git show-ref -d | sed -e "s/ / /"
|
|
|
|
) >expected.all &&
|
|
|
|
|
2008-05-04 09:37:59 +04:00
|
|
|
git remote add self "$(pwd)/.git"
|
2007-11-07 04:29:20 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ls-remote --tags .git' '
|
|
|
|
|
|
|
|
git ls-remote --tags .git >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected.tag actual
|
2007-11-07 04:29:20 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ls-remote .git' '
|
|
|
|
|
|
|
|
git ls-remote .git >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected.all actual
|
2007-11-07 04:29:20 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ls-remote --tags self' '
|
|
|
|
|
|
|
|
git ls-remote --tags self >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected.tag actual
|
2007-11-07 04:29:20 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ls-remote self' '
|
|
|
|
|
|
|
|
git ls-remote self >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected.all actual
|
2007-11-07 04:29:20 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
ls-remote: fall-back to default remotes when no remote specified
Instead of breaking execution when no remote (as specified in the
variable dest) is specified when git-ls-remote is invoked, continue on
and let remote_get() handle it.
This way, we are able to use the default remotes (eg. "origin",
branch.<name>.remote), as git-fetch, git-push, and other users of
remote_get(), do.
If no suitable remote is found, exit with a message describing the
issue, instead of just the usage text, as we do previously.
Add several tests to check that git-ls-remote handles the
no-remote-specified situation.
Also add a test that "git ls-remote <pattern>" does not work; we are
unable to guess the remote in that situation, as are git-fetch and
git-push.
In that test, we are testing for messages coming from two separate
processes, but we should be OK, because the second message is triggered
by closing the fd which must happen after the first message is printed.
(analysis by Jeff King.)
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 21:21:13 +04:00
|
|
|
test_expect_success 'dies when no remote specified and no default remotes found' '
|
|
|
|
|
|
|
|
test_must_fail git ls-remote
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'use "origin" when no remote specified' '
|
|
|
|
|
2010-05-11 21:20:23 +04:00
|
|
|
URL="$(pwd)/.git" &&
|
|
|
|
echo "From $URL" >exp_err &&
|
|
|
|
|
|
|
|
git remote add origin "$URL" &&
|
|
|
|
git ls-remote 2>actual_err >actual &&
|
|
|
|
|
|
|
|
test_cmp exp_err actual_err &&
|
ls-remote: fall-back to default remotes when no remote specified
Instead of breaking execution when no remote (as specified in the
variable dest) is specified when git-ls-remote is invoked, continue on
and let remote_get() handle it.
This way, we are able to use the default remotes (eg. "origin",
branch.<name>.remote), as git-fetch, git-push, and other users of
remote_get(), do.
If no suitable remote is found, exit with a message describing the
issue, instead of just the usage text, as we do previously.
Add several tests to check that git-ls-remote handles the
no-remote-specified situation.
Also add a test that "git ls-remote <pattern>" does not work; we are
unable to guess the remote in that situation, as are git-fetch and
git-push.
In that test, we are testing for messages coming from two separate
processes, but we should be OK, because the second message is triggered
by closing the fd which must happen after the first message is printed.
(analysis by Jeff King.)
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 21:21:13 +04:00
|
|
|
test_cmp expected.all actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2010-05-11 21:20:23 +04:00
|
|
|
test_expect_success 'suppress "From <url>" with -q' '
|
|
|
|
|
|
|
|
git ls-remote -q 2>actual_err &&
|
|
|
|
test_must_fail test_cmp exp_err actual_err
|
|
|
|
|
|
|
|
'
|
|
|
|
|
ls-remote: fall-back to default remotes when no remote specified
Instead of breaking execution when no remote (as specified in the
variable dest) is specified when git-ls-remote is invoked, continue on
and let remote_get() handle it.
This way, we are able to use the default remotes (eg. "origin",
branch.<name>.remote), as git-fetch, git-push, and other users of
remote_get(), do.
If no suitable remote is found, exit with a message describing the
issue, instead of just the usage text, as we do previously.
Add several tests to check that git-ls-remote handles the
no-remote-specified situation.
Also add a test that "git ls-remote <pattern>" does not work; we are
unable to guess the remote in that situation, as are git-fetch and
git-push.
In that test, we are testing for messages coming from two separate
processes, but we should be OK, because the second message is triggered
by closing the fd which must happen after the first message is printed.
(analysis by Jeff King.)
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 21:21:13 +04:00
|
|
|
test_expect_success 'use branch.<name>.remote if possible' '
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test that we are indeed using branch.<name>.remote, not "origin", even
|
|
|
|
# though the "origin" remote has been set.
|
|
|
|
#
|
|
|
|
|
|
|
|
# setup a new remote to differentiate from "origin"
|
|
|
|
git clone . other.git &&
|
|
|
|
(
|
|
|
|
cd other.git &&
|
|
|
|
echo "$(git rev-parse HEAD) HEAD"
|
|
|
|
git show-ref | sed -e "s/ / /"
|
|
|
|
) >exp &&
|
|
|
|
|
2010-05-11 21:20:23 +04:00
|
|
|
URL="other.git" &&
|
|
|
|
echo "From $URL" >exp_err &&
|
|
|
|
|
|
|
|
git remote add other $URL &&
|
ls-remote: fall-back to default remotes when no remote specified
Instead of breaking execution when no remote (as specified in the
variable dest) is specified when git-ls-remote is invoked, continue on
and let remote_get() handle it.
This way, we are able to use the default remotes (eg. "origin",
branch.<name>.remote), as git-fetch, git-push, and other users of
remote_get(), do.
If no suitable remote is found, exit with a message describing the
issue, instead of just the usage text, as we do previously.
Add several tests to check that git-ls-remote handles the
no-remote-specified situation.
Also add a test that "git ls-remote <pattern>" does not work; we are
unable to guess the remote in that situation, as are git-fetch and
git-push.
In that test, we are testing for messages coming from two separate
processes, but we should be OK, because the second message is triggered
by closing the fd which must happen after the first message is printed.
(analysis by Jeff King.)
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 21:21:13 +04:00
|
|
|
git config branch.master.remote other &&
|
|
|
|
|
2010-05-11 21:20:23 +04:00
|
|
|
git ls-remote 2>actual_err >actual &&
|
|
|
|
test_cmp exp_err actual_err &&
|
ls-remote: fall-back to default remotes when no remote specified
Instead of breaking execution when no remote (as specified in the
variable dest) is specified when git-ls-remote is invoked, continue on
and let remote_get() handle it.
This way, we are able to use the default remotes (eg. "origin",
branch.<name>.remote), as git-fetch, git-push, and other users of
remote_get(), do.
If no suitable remote is found, exit with a message describing the
issue, instead of just the usage text, as we do previously.
Add several tests to check that git-ls-remote handles the
no-remote-specified situation.
Also add a test that "git ls-remote <pattern>" does not work; we are
unable to guess the remote in that situation, as are git-fetch and
git-push.
In that test, we are testing for messages coming from two separate
processes, but we should be OK, because the second message is triggered
by closing the fd which must happen after the first message is printed.
(analysis by Jeff King.)
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 21:21:13 +04:00
|
|
|
test_cmp exp actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >exp <<EOF
|
|
|
|
fatal: 'refs*master' does not appear to be a git repository
|
|
|
|
fatal: The remote end hung up unexpectedly
|
|
|
|
EOF
|
|
|
|
test_expect_success 'confuses pattern as remote when no remote specified' '
|
|
|
|
#
|
|
|
|
# Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly,
|
|
|
|
# confuses <pattern> for <remote>. Although ugly, this behaviour is akin
|
|
|
|
# to the confusion of refspecs for remotes by git-fetch and git-push,
|
|
|
|
# eg:
|
|
|
|
#
|
|
|
|
# $ git fetch branch
|
|
|
|
#
|
|
|
|
|
|
|
|
# We could just as easily have used "master"; the "*" emphasizes its
|
|
|
|
# role as a pattern.
|
|
|
|
test_must_fail git ls-remote refs*master >actual 2>&1 &&
|
|
|
|
test_cmp exp actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-07 04:29:20 +03:00
|
|
|
test_done
|