summaryrefslogtreecommitdiff
path: root/t/t1402-check-ref-format.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-08-05 22:39:22 -0500
committerJunio C Hamano <gitster@pobox.com>2010-08-06 10:01:45 -0700
commit49cc460d88f5bae79b45ce2db16674f36b6cf38a (patch)
tree5b347503edd9e9000e53565144e9f4617c28858f /t/t1402-check-ref-format.sh
parentcfbe22f03f9be1f3bbbd33240dcb127099d4346e (diff)
downloadgit-49cc460d88f5bae79b45ce2db16674f36b6cf38a.tar.gz
Allow "check-ref-format --branch" from subdirectory
check-ref-format --branch requires access to the repository to resolve refs like @{-1}. Noticed by Nguyễn Thái Ngọc Duy. Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1402-check-ref-format.sh')
-rwxr-xr-xt/t1402-check-ref-format.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh
index eb45afb018..782e75d000 100755
--- a/t/t1402-check-ref-format.sh
+++ b/t/t1402-check-ref-format.sh
@@ -41,6 +41,23 @@ test_expect_success "check-ref-format --branch @{-1}" '
refname2=$(git check-ref-format --branch @{-2}) &&
test "$refname2" = master'
+test_expect_success 'check-ref-format --branch from subdir' '
+ mkdir subdir &&
+
+ T=$(git write-tree) &&
+ sha1=$(echo A | git commit-tree $T) &&
+ git update-ref refs/heads/master $sha1 &&
+ git update-ref refs/remotes/origin/master $sha1
+ git checkout master &&
+ git checkout origin/master &&
+ git checkout master &&
+ refname=$(
+ cd subdir &&
+ git check-ref-format --branch @{-1}
+ ) &&
+ test "$refname" = "$sha1"
+'
+
valid_ref_normalized() {
test_expect_success "ref name '$1' simplifies to '$2'" "
refname=\$(git check-ref-format --print '$1') &&