aboutsummaryrefslogtreecommitdiff
path: root/t/t2024-checkout-dwim.sh
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2013-04-21 23:52:05 +0200
committerJunio C Hamano <gitster@pobox.com>2013-04-21 15:14:42 -0700
commit41c21f22d0fc06f1f22489621980396aea9f7a62 (patch)
treedfb6ff062d97df67d525ee80b4e1040e0a3e2a01 /t/t2024-checkout-dwim.sh
parent983b17d4bbedd426d4fdd8a95df4dcd292c1a695 (diff)
downloadgit-41c21f22d0fc06f1f22489621980396aea9f7a62.tar.gz
git-41c21f22d0fc06f1f22489621980396aea9f7a62.tar.xz
branch.c: Validate tracking branches with refspecs instead of refs/remotes/*
The current code for validating tracking branches (e.g. the argument to the -t/--track option) hardcodes refs/heads/* and refs/remotes/* as the potential locations for tracking branches. This works with the refspecs created by "git clone" or "git remote add", but is suboptimal in other cases: - If "refs/remotes/foo/bar" exists without any association to a remote (i.e. there is no remote named "foo", or no remote with a refspec that matches "refs/remotes/foo/bar"), then it is impossible to set up a valid upstream config that tracks it. Currently, the code defaults to using "refs/remotes/foo/bar" from repo "." as the upstream, which works, but is probably not what the user had in mind when running "git branch baz --track foo/bar". - If the user has tweaked the fetch refspec for a remote to put its remote-tracking branches outside of refs/remotes/*, e.g. by running git config remote.foo.fetch "+refs/heads/*:refs/foo_stuff/*" then the current code will refuse to use its remote-tracking branches as --track arguments, since they do not match refs/remotes/*. This patch removes the "refs/remotes/*" requirement for upstream branches, and replaces it with explicit checking of the refspecs for each remote to determine whether a given --track argument is a valid remote-tracking branch. This solves both of the above problems, since the matching refspec guarantees that there is a both a remote name and a remote branch name that can be used for the upstream config. However, this means that refs located within refs/remotes/* without a corresponding remote/refspec will no longer be usable as upstreams. The few existing tests which depended on this behavioral quirk has already been fixed in the preceding patches. This patch fixes the last remaining test failure in t2024-checkout-dwim. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2024-checkout-dwim.sh')
-rwxr-xr-xt/t2024-checkout-dwim.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index 31e3d47b8..dee55e428 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -154,7 +154,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #3' '
test_branch_upstream spam repo_c spam
'
-test_expect_failure 'checkout of branch from a single remote succeeds #4' '
+test_expect_success 'checkout of branch from a single remote succeeds #4' '
git checkout -B master &&
test_might_fail git branch -D eggs &&