aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorAdam Roben <aroben@apple.com>2008-04-23 15:17:46 -0400
committerJunio C Hamano <gitster@pobox.com>2008-05-05 21:17:32 -0700
commit05d5667fec9650b049f47edd8cca23a43b135365 (patch)
tree1d7e42cd7e960d31bca1e73d91105b473f51c205 /t
parent4814dbe830baf5a72d8abbbfcc60eeea478b47c2 (diff)
downloadgit-05d5667fec9650b049f47edd8cca23a43b135365.tar.gz
git-05d5667fec9650b049f47edd8cca23a43b135365.tar.xz
git-cat-file: Add --batch-check option
This new option allows multiple objects to be specified on stdin. For each object specified, a line of the following form is printed: <sha1> SP <type> SP <size> LF If the object does not exist in the repository, a line of the following form is printed: <object> SP missing LF Signed-off-by: Adam Roben <aroben@apple.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1006-cat-file.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 0f7cc0371..decba0274 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -67,6 +67,19 @@ run_tests () {
false
fi
'
+
+ test_expect_success "--batch-check output of $type is correct" '
+ expect="$sha1 $type $size"
+ actual="$(echo_without_newline $sha1 | git cat-file --batch-check)"
+ if test "z$expect" = "z$actual"
+ then
+ : happy
+ else
+ echo "Oops: expected $expect"
+ echo "but got $actual"
+ false
+ fi
+ '
}
hello_content="Hello World"
@@ -118,4 +131,56 @@ test_expect_success \
"Reach a blob from a tag pointing to it" \
"test '$hello_content' = \"\$(git cat-file blob $tag_sha1)\""
+for opt in t s e p
+do
+ test_expect_success "Passing -$opt with --batch-check fails" '
+ test_must_fail git cat-file --batch-check -$opt $hello_sha1
+ '
+
+ test_expect_success "Passing --batch-check with -$opt fails" '
+ test_must_fail git cat-file -$opt --batch-check $hello_sha1
+ '
+done
+
+test_expect_success "Passing <type> with --batch-check fails" '
+ test_must_fail git cat-file --batch-check blob $hello_sha1
+'
+
+test_expect_success "Passing --batch-check with <type> fails" '
+ test_must_fail git cat-file blob --batch-check $hello_sha1
+'
+
+test_expect_success "Passing sha1 with --batch-check fails" '
+ test_must_fail git cat-file --batch-check $hello_sha1
+'
+
+test_expect_success "--batch-check for a non-existent object" '
+ test "deadbeef missing" = \
+ "$(echo_without_newline deadbeef | git cat-file --batch-check)"
+'
+
+test_expect_success "--batch-check for an emtpy line" '
+ test " missing" = "$(echo | git cat-file --batch-check)"
+'
+
+batch_check_input="$hello_sha1
+$tree_sha1
+$commit_sha1
+$tag_sha1
+deadbeef
+
+"
+
+batch_check_output="$hello_sha1 blob $hello_size
+$tree_sha1 tree $tree_size
+$commit_sha1 commit $commit_size
+$tag_sha1 tag $tag_size
+deadbeef missing
+ missing"
+
+test_expect_success "--batch-check with multiple sha1s gives correct format" '
+ test "$batch_check_output" = \
+ "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
+'
+
test_done