@matheusbsbs / matheus-bagliano / commits / bb931cf9d7
Fork 0

Make git-pack-redundant take a list of unimportant objs on stdin

This lets us do "git-fsck-objects --full --unreachable | cut -d ' ' -f3 | git-pack-redundant --all", which will keep git-pack-redundant from keeping packs just because they contain unreachable objects. Also add some more --verbose output. Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Lukas Sandström committed Nov 18, 2005 at 23:17 UTC bb931cf9d73d94d9940b6d0ee56b6c13ad42f1a0
1 file changed +21
pack-redundant.c
+21
@@ -579,6 +579,8 @@ int main(int argc, char **argv)
579 {
580 int i;
581 struct pack_list *min, *red, *pl;
582 + struct llist *ignore;
583 + char *sha1, buf[42]; /* 40 byte sha1 + \n + \0 */
584
585 for (i = 1; i < argc; i++) {
586 const char *arg = argv[i];
@@ -621,6 +623,23 @@ int main(int argc, char **argv)
623 if (alt_odb)
624 scan_alt_odb_packs();
625
626 + /* ignore objects given on stdin */
627 + llist_init(&ignore);
628 + if (!isatty(0)) {
629 + while (fgets(buf, sizeof(buf), stdin)) {
630 + sha1 = xmalloc(20);
631 + if (get_sha1_hex(buf, sha1))
632 + die("Bad sha1 on stdin: %s", buf);
633 + llist_insert_sorted_unique(ignore, sha1, NULL);
634 + }
635 + }
636 + llist_sorted_difference_inplace(all_objects, ignore);
637 + pl = local_packs;
638 + while (pl) {
639 + llist_sorted_difference_inplace(pl->unique_objects, ignore);
640 + pl = pl->next;
641 + }
642 +
643 minimize(&min);
644
645 if (verbose) {
@@ -647,6 +666,8 @@ int main(int argc, char **argv)
666 pl->pack->pack_name);
667 pl = pl->next;
668 }
669 + if (verbose)
670 + fprintf(stderr, "%luMB of redundant packs in total.\n", pack_set_bytecount(red)/(1024*1024));
671
672 return 0;
673 }