This test verifies that the following expressions all evaluate to the
full refname "refs/remotes/origin/heads/master":

 - refs/remotes/origin/heads/master
 - remotes/origin/heads/master
 - origin/heads/master
 - origin/master

Currently the last of these fail, because the "$remote/$branch" syntax only
works for remotes with conventional (refs/heads/*:refs/remotes/origin/*)
refspecs.

In order for users of namespaced remote refs (or any other unconventional
refspec configuration) to be able to use the "$remote/$branch" syntax, we
need to extend the parsing of "$remote/$branch" expressions to take the
configured refspecs into account (i.e. look up the fetch refspecs for
$remote, and map "refs/heads/$branch" through the refspecs to find the
corresponding remote-tracking branch name).

Mirroring the expansion of the above 4 expressions into the full refname,
the same 4 expression should also be shortened into "origin/master" when
abbreviating them into their shortest unambiguous representation, e.g.
when running "git rev-parse --abbrev-ref" on them. A (currently failing)
test verifying this behavior is also added by this patch.

Signed-off-by: Johan Herland <jo...@herland.net>
---
 t/t7900-working-with-namespaced-remote-refs.sh | 28 ++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/t/t7900-working-with-namespaced-remote-refs.sh 
b/t/t7900-working-with-namespaced-remote-refs.sh
index af03ac9..cc25e76 100755
--- a/t/t7900-working-with-namespaced-remote-refs.sh
+++ b/t/t7900-working-with-namespaced-remote-refs.sh
@@ -85,4 +85,32 @@ test_expect_success 'work-around "clone" with namespaced 
remote refs' '
        test_clone client
 '
 
+test_expect_success 'enter client repo' '
+       cd client
+'
+
+test_expect_failure 'short-hand notation expands correctly for remote-tracking 
branches' '
+       echo refs/remotes/origin/heads/master > expect &&
+       git rev-parse --symbolic-full-name refs/remotes/origin/heads/master > 
actual &&
+       test_cmp expect actual &&
+       git rev-parse --symbolic-full-name remotes/origin/heads/master > actual 
&&
+       test_cmp expect actual &&
+       git rev-parse --symbolic-full-name origin/heads/master > actual &&
+       test_cmp expect actual &&
+       git rev-parse --symbolic-full-name origin/master > actual &&
+       test_cmp expect actual
+'
+
+test_expect_failure 'remote-tracking branches are shortened correctly' '
+       echo origin/master > expect &&
+       git rev-parse --abbrev-ref refs/remotes/origin/heads/master > actual &&
+       test_cmp expect actual &&
+       git rev-parse --abbrev-ref remotes/origin/heads/master > actual &&
+       test_cmp expect actual &&
+       git rev-parse --abbrev-ref origin/heads/master > actual &&
+       test_cmp expect actual &&
+       git rev-parse --abbrev-ref origin/master > actual &&
+       test_cmp expect actual
+'
+
 test_done
-- 
1.8.1.3.704.g33f7d4f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to