summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2019-05-14 08:05:05 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-05-15 10:58:02 +0900
commit2ed2e19958f2bcf59cac18a69b27f74ba7079a2f (patch)
tree356c3b377d3c0c6b7c8c8b2f49d1acaf5ee10997 /t
parenthelp_unknown_ref(): duplicate collected refnames (diff)
downloadtgif-2ed2e19958f2bcf59cac18a69b27f74ba7079a2f.tar.xz
help_unknown_ref(): check for refname ambiguity
When the user asks to merge "foo" and we suggest "origin/foo" instead, we do so by simply chopping off "refs/remotes/" from the front of the suggested ref. This is usually fine, but it's possible that the resulting name is ambiguous (e.g., you have "refs/heads/origin/foo", too). Let's use shorten_unambiguous_ref() to do this the right way, which should usually yield the same "origin/foo", but "remotes/origin/foo" if necessary. Note that in this situation there may be other options (e.g., we could suggest "heads/origin/foo" as well). I'll leave that up for debate; the focus here is just to avoid giving advice that does not actually do what we expect. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7600-merge.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 592850cef7..36b2c8c91f 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -836,4 +836,10 @@ test_expect_success 'merge suggests matching remote refname' '
grep origin/not-local stderr
'
+test_expect_success 'suggested names are not ambiguous' '
+ git update-ref refs/heads/origin/not-local HEAD &&
+ test_must_fail git merge not-local 2>stderr &&
+ grep remotes/origin/not-local stderr
+'
+
test_done