summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-07-25 02:21:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-07-25 02:21:21 (GMT)
commit356df9bd8df58eb759fedaee8a8d1a7dc0872f8f (patch)
tree3ed41eb0da59c4a6e1b668c3392295ee334f978b /builtin
parent2bf3501150145d1f05678c20ab8e8d66f849851f (diff)
parentd099b7173dabdeeb1f339151ac2169b3a91bf631 (diff)
downloadgit-356df9bd8df58eb759fedaee8a8d1a7dc0872f8f.zip
git-356df9bd8df58eb759fedaee8a8d1a7dc0872f8f.tar.gz
git-356df9bd8df58eb759fedaee8a8d1a7dc0872f8f.tar.bz2
Merge branch 'jk/cat-file-batch-optim'
If somebody wants to only know on-disk footprint of an object without having to know its type or payload size, we can bypass a lot of code to cheaply learn it. * jk/cat-file-batch-optim: Fix some sparse warnings sha1_object_info_extended: pass object_info to helpers sha1_object_info_extended: make type calculation optional packed_object_info: make type lookup optional packed_object_info: hoist delta type resolution to helper sha1_loose_object_info: make type lookup optional sha1_object_info_extended: rename "status" to "type" cat-file: disable object/refname ambiguity check for batch mode
Diffstat (limited to 'builtin')
-rw-r--r--builtin/cat-file.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 0e64b41..163ce6c 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -150,7 +150,9 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
if (!data->mark_query)
strbuf_addstr(sb, sha1_to_hex(data->sha1));
} else if (is_atom("objecttype", atom, len)) {
- if (!data->mark_query)
+ if (data->mark_query)
+ data->info.typep = &data->type;
+ else
strbuf_addstr(sb, typename(data->type));
} else if (is_atom("objectsize", atom, len)) {
if (data->mark_query)
@@ -229,8 +231,7 @@ static int batch_one_object(const char *obj_name, struct batch_options *opt,
return 0;
}
- data->type = sha1_object_info_extended(data->sha1, &data->info);
- if (data->type <= 0) {
+ if (sha1_object_info_extended(data->sha1, &data->info) < 0) {
printf("%s missing\n", obj_name);
fflush(stdout);
return 0;
@@ -266,6 +267,15 @@ static int batch_objects(struct batch_options *opt)
strbuf_expand(&buf, opt->format, expand_format, &data);
data.mark_query = 0;
+ /*
+ * We are going to call get_sha1 on a potentially very large number of
+ * objects. In most large cases, these will be actual object sha1s. The
+ * cost to double-check that each one is not also a ref (just so we can
+ * warn) ends up dwarfing the actual cost of the object lookups
+ * themselves. We can work around it by just turning off the warning.
+ */
+ warn_on_object_refname_ambiguity = 0;
+
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
char *p;
int error;