From: Johan Herland <johan@herland.net>
To: gitster@pobox.com
Cc: git@vger.kernel.org, johan@herland.net
Subject: [PATCHv3 2/8] t2024: Show failure to use refspec when DWIMming remote branch names
Date: Sun, 21 Apr 2013 23:52:00 +0200 [thread overview]
Message-ID: <1366581126-3880-3-git-send-email-johan@herland.net> (raw)
In-Reply-To: <1366581126-3880-1-git-send-email-johan@herland.net>
When using "git checkout foo" to DWIM the creation of local "foo" from some
existing upstream "foo", we assume conventional refspecs as created by "git
clone" or "git remote add", and fail to work correctly if the current
refspecs do not follow the conventional "refs/remotes/$remote/*" pattern.
Improved-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Johan Herland <johan@herland.net>
---
t/t2024-checkout-dwim.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index 1452bea..b1e3444 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -24,6 +24,7 @@ test_branch_upstream () {
}
test_expect_success 'setup' '
+ test_commit my_master &&
git init repo_a &&
(
cd repo_a &&
@@ -58,7 +59,7 @@ test_expect_success 'checkout of non-existing branch fails' '
test_branch master
'
-test_expect_success 'checkout of branch from multiple remotes fails' '
+test_expect_success 'checkout of branch from multiple remotes fails #1' '
git checkout -B master &&
test_might_fail git branch -D foo &&
@@ -96,4 +97,71 @@ test_expect_success '--no-guess suppresses branch auto-vivification' '
test_branch master
'
+test_expect_success 'setup more remotes with unconventional refspecs' '
+ git checkout -B master &&
+ git init repo_c &&
+ (
+ cd repo_c &&
+ test_commit c_master &&
+ git checkout -b bar &&
+ test_commit c_bar
+ git checkout -b spam &&
+ test_commit c_spam
+ ) &&
+ git init repo_d &&
+ (
+ cd repo_d &&
+ test_commit d_master &&
+ git checkout -b baz &&
+ test_commit f_baz
+ git checkout -b eggs &&
+ test_commit c_eggs
+ ) &&
+ git remote add repo_c repo_c &&
+ git config remote.repo_c.fetch \
+ "+refs/heads/*:refs/remotes/extra_dir/repo_c/extra_dir/*" &&
+ git remote add repo_d repo_d &&
+ git config remote.repo_d.fetch \
+ "+refs/heads/*:refs/repo_d/*" &&
+ git fetch --all
+'
+
+test_expect_failure 'checkout of branch from multiple remotes fails #2' '
+ git checkout -B master &&
+ test_might_fail git branch -D bar &&
+
+ test_must_fail git checkout bar &&
+ test_must_fail git rev-parse --verify refs/heads/bar &&
+ test_branch master
+'
+
+test_expect_failure 'checkout of branch from multiple remotes fails #3' '
+ git checkout -B master &&
+ test_might_fail git branch -D baz &&
+
+ test_must_fail git checkout baz &&
+ test_must_fail git rev-parse --verify refs/heads/baz &&
+ test_branch master
+'
+
+test_expect_failure 'checkout of branch from a single remote succeeds #3' '
+ git checkout -B master &&
+ test_might_fail git branch -D spam &&
+
+ git checkout spam &&
+ test_branch spam &&
+ test_cmp_rev refs/remotes/extra_dir/repo_c/extra_dir/spam HEAD &&
+ test_branch_upstream spam repo_c spam
+'
+
+test_expect_failure 'checkout of branch from a single remote succeeds #4' '
+ git checkout -B master &&
+ test_might_fail git branch -D eggs &&
+
+ git checkout eggs &&
+ test_branch eggs &&
+ test_cmp_rev refs/repo_d/eggs HEAD &&
+ test_branch_upstream eggs repo_d eggs
+'
+
test_done
--
1.8.1.3.704.g33f7d4f
next prev parent reply other threads:[~2013-04-21 21:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-21 21:51 [PATCHv3 0/8] Improving the search for remote-tracking branches Johan Herland
2013-04-21 21:51 ` [PATCHv3 1/8] t2024: Add tests verifying current DWIM behavior of 'git checkout <branch>' Johan Herland
2013-04-21 21:52 ` Johan Herland [this message]
2013-04-21 21:52 ` [PATCHv3 3/8] checkout: Use remote refspecs when DWIMming tracking branches Johan Herland
2013-04-21 21:52 ` [PATCHv3 4/8] t3200.39: tracking setup should fail if there is no matching refspec Johan Herland
2013-04-21 21:52 ` [PATCHv3 5/8] t7201.24: Add refspec to keep --track working Johan Herland
2013-04-21 21:52 ` [PATCHv3 6/8] t9114.2: Don't use --track option against "svn-remote"-tracking branches Johan Herland
2013-04-21 21:52 ` [PATCHv3 7/8] branch.c: Validate tracking branches with refspecs instead of refs/remotes/* Johan Herland
2013-04-21 21:52 ` [PATCHv3 8/8] glossary: Update and rephrase the definition of a remote-tracking branch Johan Herland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366581126-3880-3-git-send-email-johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).