summaryrefslogtreecommitdiff
path: root/t/t1006-cat-file.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-07-10 07:45:47 -0400
committerJunio C Hamano <gitster@pobox.com>2013-07-12 09:18:12 -0700
commit93d2a607ba05fba31442941d0425019120993846 (patch)
treef2fe7d26dc9e6a517a0a526eb0c6879ede4feab1 /t/t1006-cat-file.sh
parentb71bd48017981f7257d8c0a5096825321b4fb49b (diff)
downloadgit-93d2a607ba05fba31442941d0425019120993846.tar.gz
cat-file: add --batch-check=<format>
The `cat-file --batch-check` command can be used to quickly get information about a large number of objects. However, it provides a fixed set of information. This patch adds an optional <format> option to --batch-check to allow a caller to specify which items they are interested in, and in which order to output them. This is not very exciting for now, since we provide the same limited set that you could already get. However, it opens the door to adding new format items in the future without breaking backwards compatibility (or forcing callers to pay the cost to calculate uninteresting items). Since the --batch option shares code with --batch-check, it receives the same feature, though it is less likely to be of interest there. The format atom names are chosen to match their counterparts in for-each-ref. Though we do not (yet) share any code with for-each-ref's formatter, this keeps the interface as consistent as possible, and may help later on if the implementations are unified. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1006-cat-file.sh')
-rwxr-xr-xt/t1006-cat-file.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index c2f25039e8..4e911fb43d 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -72,6 +72,12 @@ $content"
echo_without_newline $sha1 | git cat-file --batch-check >actual &&
test_cmp expect actual
'
+
+ test_expect_success "custom --batch-check format" '
+ echo "$type $sha1" >expect &&
+ echo $sha1 | git cat-file --batch-check="%(objecttype) %(objectname)" >actual &&
+ test_cmp expect actual
+ '
}
hello_content="Hello World"