summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-11 20:31:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-11 20:31:07 (GMT)
commitf4c52a05277f8f5901f7663f6ab339271b814872 (patch)
tree994c7cbe55b25f15a952eea7f6df7e8f3f39877b /t
parent71e120202fe073bd2e4e9db59ca01ab7c5e72f7e (diff)
parent798c35fcd8a71a094ca68ac05d81e08c5ac8166d (diff)
downloadgit-f4c52a05277f8f5901f7663f6ab339271b814872.zip
git-f4c52a05277f8f5901f7663f6ab339271b814872.tar.gz
git-f4c52a05277f8f5901f7663f6ab339271b814872.tar.bz2
Merge branch 'nd/warn-ambiguous-object-name'
"git cmd <name>", when <name> happens to be a 40-hex string, directly uses the 40-hex string as an object name, even if a ref "refs/<some hierarchy>/<name>" exists. This disambiguation order is unlikely to change, but we should warn about the ambiguity just like we warn when more than one refs/ hierachies share the same name. * nd/warn-ambiguous-object-name: get_sha1: warn about full or short object names that look like refs
Diffstat (limited to 't')
-rwxr-xr-xt/t1512-rev-parse-disambiguation.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 6b3d797..db22808 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -261,4 +261,22 @@ test_expect_success 'rev-parse --disambiguate' '
test "$(sed -e "s/^\(.........\).*/\1/" actual | sort -u)" = 000000000
'
+test_expect_success 'ambiguous 40-hex ref' '
+ TREE=$(git mktree </dev/null) &&
+ REF=`git rev-parse HEAD` &&
+ VAL=$(git commit-tree $TREE </dev/null) &&
+ git update-ref refs/heads/$REF $VAL &&
+ test `git rev-parse $REF 2>err` = $REF &&
+ grep "refname.*${REF}.*ambiguous" err
+'
+
+test_expect_success 'ambiguous short sha1 ref' '
+ TREE=$(git mktree </dev/null) &&
+ REF=`git rev-parse --short HEAD` &&
+ VAL=$(git commit-tree $TREE </dev/null) &&
+ git update-ref refs/heads/$REF $VAL &&
+ test `git rev-parse $REF 2>err` = $VAL &&
+ grep "refname.*${REF}.*ambiguous" err
+'
+
test_done