|
17 | 17 | #include "object-store.h"
|
18 | 18 | #include "promisor-remote.h"
|
19 | 19 |
|
| 20 | +enum batch_mode { |
| 21 | + BATCH_MODE_CONTENTS, |
| 22 | + BATCH_MODE_INFO, |
| 23 | +}; |
| 24 | + |
20 | 25 | struct batch_options {
|
21 | 26 | int enabled;
|
22 | 27 | int follow_symlinks;
|
23 |
| - int print_contents; |
| 28 | + enum batch_mode batch_mode; |
24 | 29 | int buffer_output;
|
25 | 30 | int all_objects;
|
26 | 31 | int unordered;
|
@@ -386,7 +391,7 @@ static void batch_object_write(const char *obj_name,
|
386 | 391 | strbuf_addch(scratch, '\n');
|
387 | 392 | batch_write(opt, scratch->buf, scratch->len);
|
388 | 393 |
|
389 |
| - if (opt->print_contents) { |
| 394 | + if (opt->batch_mode == BATCH_MODE_CONTENTS) { |
390 | 395 | print_object_or_die(opt, data);
|
391 | 396 | batch_write(opt, "\n", 1);
|
392 | 397 | }
|
@@ -536,7 +541,7 @@ static int batch_objects(struct batch_options *opt)
|
536 | 541 | * If we are printing out the object, then always fill in the type,
|
537 | 542 | * since we will want to decide whether or not to stream.
|
538 | 543 | */
|
539 |
| - if (opt->print_contents) |
| 544 | + if (opt->batch_mode == BATCH_MODE_CONTENTS) |
540 | 545 | data.info.typep = &data.type;
|
541 | 546 |
|
542 | 547 | if (opt->all_objects) {
|
@@ -635,7 +640,14 @@ static int batch_option_callback(const struct option *opt,
|
635 | 640 | }
|
636 | 641 |
|
637 | 642 | bo->enabled = 1;
|
638 |
| - bo->print_contents = !strcmp(opt->long_name, "batch"); |
| 643 | + |
| 644 | + if (!strcmp(opt->long_name, "batch")) |
| 645 | + bo->batch_mode = BATCH_MODE_CONTENTS; |
| 646 | + else if (!strcmp(opt->long_name, "batch-check")) |
| 647 | + bo->batch_mode = BATCH_MODE_INFO; |
| 648 | + else |
| 649 | + BUG("%s given to batch-option-callback", opt->long_name); |
| 650 | + |
639 | 651 | bo->format = arg;
|
640 | 652 |
|
641 | 653 | return 0;
|
|
0 commit comments