summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-04-17 10:52:48 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-04-17 13:54:39 -0700
commitb7994af0f92e6cf150544aebe3c3fc526faaf2c3 (patch)
tree91f3353ce20796fea21fdf32e56ae8325924602e /t
parentRefactor type_from_string() to allow continuing after detecting an error (diff)
downloadtgif-b7994af0f92e6cf150544aebe3c3fc526faaf2c3.tar.xz
type_from_string_gently: make sure length matches
When commit fe8e3b7 refactored type_from_string to allow input that was not NUL-terminated, it switched to using strncmp instead of strcmp. But this means we check only the first "len" bytes of the strings, and ignore any remaining bytes in the object_type_string. We should make sure that it is also "len" bytes, or else we would accept "comm" as "commit", and so forth. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1007-hash-object.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index f83df8eb8b..ebb3a69c8c 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -201,4 +201,12 @@ test_expect_success 'corrupt tag' '
test_must_fail git hash-object -t tag --stdin </dev/null
'
+test_expect_success 'hash-object complains about bogus type name' '
+ test_must_fail git hash-object -t bogus --stdin </dev/null
+'
+
+test_expect_success 'hash-object complains about truncated type name' '
+ test_must_fail git hash-object -t bl --stdin </dev/null
+'
+
test_done