aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-02-05 17:52:21 +0700
committerJunio C Hamano <gitster@pobox.com>2011-02-07 15:05:25 -0800
commitc879daa23729547fb28aa7e8783c5e4e619a9e7c (patch)
tree0c73b7150204bf11f9ca90683b36e3229fb22279 /t
parentcf7b1cad0e8b024538de975dff5893262cec72d7 (diff)
downloadgit-c879daa23729547fb28aa7e8783c5e4e619a9e7c.tar.gz
git-c879daa23729547fb28aa7e8783c5e4e619a9e7c.tar.xz
Make hash-object more robust against malformed objects
Commits, trees and tags have structure. Don't let users feed git with malformed ones. Sooner or later git will die() when encountering them. Note that this patch does not check semantics. A tree that points to non-existent objects is perfectly OK (and should be so, users may choose to add commit first, then its associated tree for example). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1007-hash-object.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index dd32432d6..6d52b824b 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -188,4 +188,17 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
pop_repo
done
+test_expect_success 'corrupt tree' '
+ echo abc >malformed-tree
+ test_must_fail git hash-object -t tree malformed-tree
+'
+
+test_expect_success 'corrupt commit' '
+ test_must_fail git hash-object -t commit --stdin </dev/null
+'
+
+test_expect_success 'corrupt tag' '
+ test_must_fail git hash-object -t tag --stdin </dev/null
+'
+
test_done