summaryrefslogtreecommitdiff
path: root/pack-redundant.c
diff options
context:
space:
mode:
authorLukas Sandström <lukass@etek.chalmers.se>2005-11-18 22:17:50 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-11-22 20:38:16 (GMT)
commitbb931cf9d73d94d9940b6d0ee56b6c13ad42f1a0 (patch)
tree76044169efca82248e9e32124ed795670f9c5875 /pack-redundant.c
parent302ebfe52192fff9a2c1c612dff22325fd073acc (diff)
downloadgit-bb931cf9d73d94d9940b6d0ee56b6c13ad42f1a0.zip
git-bb931cf9d73d94d9940b6d0ee56b6c13ad42f1a0.tar.gz
git-bb931cf9d73d94d9940b6d0ee56b6c13ad42f1a0.tar.bz2
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>
Diffstat (limited to 'pack-redundant.c')
-rw-r--r--pack-redundant.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pack-redundant.c b/pack-redundant.c
index 1519385..9851c29 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -579,6 +579,8 @@ int main(int argc, char **argv)
{
int i;
struct pack_list *min, *red, *pl;
+ struct llist *ignore;
+ char *sha1, buf[42]; /* 40 byte sha1 + \n + \0 */
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -621,6 +623,23 @@ int main(int argc, char **argv)
if (alt_odb)
scan_alt_odb_packs();
+ /* ignore objects given on stdin */
+ llist_init(&ignore);
+ if (!isatty(0)) {
+ while (fgets(buf, sizeof(buf), stdin)) {
+ sha1 = xmalloc(20);
+ if (get_sha1_hex(buf, sha1))
+ die("Bad sha1 on stdin: %s", buf);
+ llist_insert_sorted_unique(ignore, sha1, NULL);
+ }
+ }
+ llist_sorted_difference_inplace(all_objects, ignore);
+ pl = local_packs;
+ while (pl) {
+ llist_sorted_difference_inplace(pl->unique_objects, ignore);
+ pl = pl->next;
+ }
+
minimize(&min);
if (verbose) {
@@ -647,6 +666,8 @@ int main(int argc, char **argv)
pl->pack->pack_name);
pl = pl->next;
}
+ if (verbose)
+ fprintf(stderr, "%luMB of redundant packs in total.\n", pack_set_bytecount(red)/(1024*1024));
return 0;
}