summaryrefslogtreecommitdiff
path: root/t/t1506-rev-parse-diagnosis.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-09 13:38:05 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-09 13:38:05 -0800
commit3d6e0f745e5b958387c9116ff5ba6247b990e6e7 (patch)
treef4b3b7e72272491fa01df6c8a750f4bcdf648f1a /t/t1506-rev-parse-diagnosis.sh
parent979f792951913d75f992f87022b75610303a614f (diff)
downloadgit-3d6e0f745e5b958387c9116ff5ba6247b990e6e7.tar.gz
get_sha1: teach ":$n:<path>" the same relative path logic
We taught the object name parser to take ":./<path>", ":../<path>", etc. and understand them to be relative to the current working directory. Given that ":<path>" is just a short-hand for ":0:<path>" (i.e. "take stage #0 of that path"), we should allow ":$n:<path>" to interpret them the same way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1506-rev-parse-diagnosis.sh')
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 18664702b9..9f8adb1f82 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -34,6 +34,8 @@ test_expect_success 'correct file objects' '
test_expect_success 'correct relative file objects (0)' '
git rev-parse :file.txt >expected &&
git rev-parse :./file.txt >result &&
+ test_cmp expected result &&
+ git rev-parse :0:./file.txt >result &&
test_cmp expected result
'
@@ -68,6 +70,28 @@ test_expect_success 'correct relative file objects (4)' '
)
'
+test_expect_success 'correct relative file objects (5)' '
+ git rev-parse :subdir/file.txt >expected &&
+ (
+ cd subdir &&
+ git rev-parse :./file.txt >result &&
+ test_cmp ../expected result &&
+ git rev-parse :0:./file.txt >result &&
+ test_cmp ../expected result
+ )
+'
+
+test_expect_success 'correct relative file objects (6)' '
+ git rev-parse :file.txt >expected &&
+ (
+ cd subdir &&
+ git rev-parse :../file.txt >result &&
+ test_cmp ../expected result &&
+ git rev-parse :0:../file.txt >result &&
+ test_cmp ../expected result
+ )
+'
+
test_expect_success 'incorrect revision id' '
test_must_fail git rev-parse foobar:file.txt 2>error &&
grep "Invalid object name '"'"'foobar'"'"'." error &&