提交 62899139 编写于 作者: J Junio C Hamano

Merge branch 'jk/cat-file-buffered-batch-all'

"git cat-file --batch-all" has been sped up, by taking advantage
of the fact that it does not have to read a list of objects, in two
ways.

* jk/cat-file-buffered-batch-all:
  cat-file: default to --buffer when --batch-all-objects is used
  cat-file: avoid noop calls to sha1_object_info_extended
......@@ -154,6 +154,13 @@ struct expand_data {
* elements above, so you can retrieve the response from there.
*/
struct object_info info;
/*
* This flag will be true if the requested batch format and options
* don't require us to call sha1_object_info, which can then be
* optimized out.
*/
unsigned skip_object_info : 1;
};
static int is_atom(const char *atom, const char *s, int slen)
......@@ -258,7 +265,8 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
{
struct strbuf buf = STRBUF_INIT;
if (sha1_object_info_extended(data->sha1, &data->info, LOOKUP_REPLACE_OBJECT) < 0) {
if (!data->skip_object_info &&
sha1_object_info_extended(data->sha1, &data->info, LOOKUP_REPLACE_OBJECT) < 0) {
printf("%s missing\n", obj_name ? obj_name : sha1_to_hex(data->sha1));
fflush(stdout);
return;
......@@ -369,6 +377,13 @@ static int batch_objects(struct batch_options *opt)
strbuf_expand(&buf, opt->format, expand_format, &data);
data.mark_query = 0;
if (opt->all_objects) {
struct object_info empty;
memset(&empty, 0, sizeof(empty));
if (!memcmp(&data.info, &empty, sizeof(empty)))
data.skip_object_info = 1;
}
/*
* If we are printing out the object, then always fill in the type,
* since we will want to decide whether or not to stream.
......@@ -489,6 +504,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
git_config(git_cat_file_config, NULL);
batch.buffer_output = -1;
argc = parse_options(argc, argv, prefix, options, cat_file_usage, 0);
if (opt) {
......@@ -512,6 +528,9 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
usage_with_options(cat_file_usage, options);
}
if (batch.buffer_output < 0)
batch.buffer_output = batch.all_objects;
if (batch.enabled)
return batch_objects(&batch);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册