338
}
339
}
340
341
-static void batch_object_write(const char *obj_name, struct batch_options *opt,
341
+static void batch_object_write(const char *obj_name,
342
+ struct strbuf *scratch,
343
+ struct batch_options *opt,
344
struct expand_data *data)
345
{
344
- struct strbuf buf = STRBUF_INIT;
345
-
346
if (!data->skip_object_info &&
347
oid_object_info_extended(the_repository, &data->oid, &data->info,
348
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
352
return;
353
}
354
355
- strbuf_expand(&buf, opt->format, expand_format, data);
356
- strbuf_addch(&buf, '\n');
357
- batch_write(opt, buf.buf, buf.len);
358
- strbuf_release(&buf);
355
+ strbuf_reset(scratch);
356
+ strbuf_expand(scratch, opt->format, expand_format, data);
357
+ strbuf_addch(scratch, '\n');
358
+ batch_write(opt, scratch->buf, scratch->len);
359
360
if (opt->print_contents) {
361
print_object_or_die(opt, data);
363
}
364
}
365
366
-static void batch_one_object(const char *obj_name, struct batch_options *opt,
366
+static void batch_one_object(const char *obj_name,
367
+ struct strbuf *scratch,
368
+ struct batch_options *opt,
369
struct expand_data *data)
370
{
371
struct object_context ctx;
407
return;
408
}
409
408
- batch_object_write(obj_name, opt, data);
410
+ batch_object_write(obj_name, scratch, opt, data);
411
}
412
413
struct object_cb_data {
414
struct batch_options *opt;
415
struct expand_data *expand;
416
struct oidset *seen;
417
+ struct strbuf *scratch;
418
};
419
420
static int batch_object_cb(const struct object_id *oid, void *vdata)
421
{
422
struct object_cb_data *data = vdata;
423
oidcpy(&data->expand->oid, oid);
421
- batch_object_write(NULL, data->opt, data->expand);
424
+ batch_object_write(NULL, data->scratch, data->opt, data->expand);
425
return 0;
426
}
427
512
513
cb.opt = opt;
514
cb.expand = &data;
515
+ cb.scratch = &output;
516
517
if (opt->unordered) {
518
struct oidset seen = OIDSET_INIT;
535
oid_array_clear(&sa);
536
}
537
538
+ strbuf_release(&output);
539
return 0;
540
}
541
564
data.rest = p;
565
}
566
562
- batch_one_object(input.buf, opt, &data);
567
+ batch_one_object(input.buf, &output, opt, &data);
568
}
569
570
strbuf_release(&input);
571
+ strbuf_release(&output);
572
warn_on_object_refname_ambiguity = save_warning;
573
return retval;
574
}