332
"--stdout", "--thin", "--delta-base-offset",
333
NULL);
334
strvec_pushv(&pack_objects.args, pack_options->v);
335
+ if (revs->filter.choice)
336
+ strvec_pushf(&pack_objects.args, "--filter=%s",
337
+ list_objects_filter_spec(&revs->filter));
338
pack_objects.in = -1;
339
pack_objects.out = bundle_fd;
340
pack_objects.git_cmd = 1;
502
int bundle_to_stdout;
503
int ref_count = 0;
504
struct rev_info revs, revs_copy;
502
- int min_version = the_hash_algo == &hash_algos[GIT_HASH_SHA1] ? 2 : 3;
505
+ int min_version = 2;
506
struct bundle_prerequisites_info bpi;
507
int i;
508
509
+ /* init revs to list objects for pack-objects later */
510
+ save_commit_buffer = 0;
511
+ repo_init_revisions(r, &revs, NULL);
512
+
513
+ /*
514
+ * Pre-initialize the '--objects' flag so we can parse a
515
+ * --filter option successfully.
516
+ */
517
+ revs.tree_objects = revs.blob_objects = 1;
518
+
519
+ argc = setup_revisions(argc, argv, &revs, NULL);
520
+
521
+ /*
522
+ * Reasons to require version 3:
523
+ *
524
+ * 1. @object-format is required because our hash algorithm is not
525
+ * SHA1.
526
+ * 2. @filter is required because we parsed an object filter.
527
+ */
528
+ if (the_hash_algo != &hash_algos[GIT_HASH_SHA1] || revs.filter.choice)
529
+ min_version = 3;
530
+
531
+ if (argc > 1) {
532
+ error(_("unrecognized argument: %s"), argv[1]);
533
+ goto err;
534
+ }
535
+
536
bundle_to_stdout = !strcmp(path, "-");
537
if (bundle_to_stdout)
538
bundle_fd = 1;
555
write_or_die(bundle_fd, capability, strlen(capability));
556
write_or_die(bundle_fd, the_hash_algo->name, strlen(the_hash_algo->name));
557
write_or_die(bundle_fd, "\n", 1);
528
- }
529
-
530
- /* init revs to list objects for pack-objects later */
531
- save_commit_buffer = 0;
532
- repo_init_revisions(r, &revs, NULL);
558
534
- argc = setup_revisions(argc, argv, &revs, NULL);
535
-
536
- if (argc > 1) {
537
- error(_("unrecognized argument: %s"), argv[1]);
538
- goto err;
559
+ if (revs.filter.choice) {
560
+ const char *value = expand_list_objects_filter_spec(&revs.filter);
561
+ capability = "@filter=";
562
+ write_or_die(bundle_fd, capability, strlen(capability));
563
+ write_or_die(bundle_fd, value, strlen(value));
564
+ write_or_die(bundle_fd, "\n", 1);
565
+ }
566
}
567
568
/* save revs.pending in revs_copy for later use */
585
bpi.fd = bundle_fd;
586
bpi.pending = &revs_copy.pending;
587
588
+ /*
589
+ * Remove any object walking here. We only care about commits and
590
+ * tags here. The revs_copy has the right instances of these values.
591
+ */
592
revs.blob_objects = revs.tree_objects = 0;
593
traverse_commit_list(&revs, write_bundle_prerequisites, NULL, &bpi);
594
object_array_remove_duplicates(&revs_copy.pending);