summaryrefslogtreecommitdiff
path: root/t/t1007-hash-object.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-10-03 13:30:38 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-10-03 13:30:38 -0700
commit4e34e20c9fd25a91dad0003547b43cfa00b2740c (patch)
treeb29a6aa0732ac177ec905e60d2171fad6f397dd0 /t/t1007-hash-object.sh
parentMerge branch 'kd/mailinfo-quoted-string' (diff)
parentfsck: handle bad trees like other errors (diff)
downloadtgif-4e34e20c9fd25a91dad0003547b43cfa00b2740c.tar.xz
Merge branch 'dt/tree-fsck'
The codepath in "git fsck" to detect malformed tree objects has been updated not to die but keep going after detecting them. * dt/tree-fsck: fsck: handle bad trees like other errors tree-walk: be more specific about corrupt tree errors
Diffstat (limited to 't/t1007-hash-object.sh')
-rwxr-xr-xt/t1007-hash-object.sh25
1 files changed, 23 insertions, 2 deletions
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index acca9ac562..c5245c5cb4 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -183,9 +183,30 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
pop_repo
done
-test_expect_success 'corrupt tree' '
+test_expect_success 'too-short tree' '
echo abc >malformed-tree &&
- test_must_fail git hash-object -t tree malformed-tree
+ test_must_fail git hash-object -t tree malformed-tree 2>err &&
+ test_i18ngrep "too-short tree object" err
+'
+
+hex2oct() {
+ perl -ne 'printf "\\%03o", hex for /../g'
+}
+
+test_expect_success 'malformed mode in tree' '
+ hex_sha1=$(echo foo | git hash-object --stdin -w) &&
+ bin_sha1=$(echo $hex_sha1 | hex2oct) &&
+ printf "9100644 \0$bin_sha1" >tree-with-malformed-mode &&
+ test_must_fail git hash-object -t tree tree-with-malformed-mode 2>err &&
+ test_i18ngrep "malformed mode in tree entry" err
+'
+
+test_expect_success 'empty filename in tree' '
+ hex_sha1=$(echo foo | git hash-object --stdin -w) &&
+ bin_sha1=$(echo $hex_sha1 | hex2oct) &&
+ printf "100644 \0$bin_sha1" >tree-with-empty-filename &&
+ test_must_fail git hash-object -t tree tree-with-empty-filename 2>err &&
+ test_i18ngrep "empty filename in tree entry" err
'
test_expect_success 'corrupt commit' '