All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin
@ 2005-11-18 22:17 Lukas Sandström
  2005-11-18 22:20 ` [PATCH] Document the "ignore objects" feature of git-pack-redundant Lukas Sandström
  2005-11-21 11:45 ` [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin Lukas Sandström
  0 siblings, 2 replies; 3+ messages in thread
From: Lukas Sandström @ 2005-11-18 22:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Lukas Sandström

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>

---

 pack-redundant.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

applies-to: 3771756c044fa4338acc9f6acac3971f2309cc7c
4173f0c77793b13ad50d9c1a1ff5da32fec5e573
diff --git a/pack-redundant.c b/pack-redundant.c
index fb6cb48..f3097a1 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;
 }
---
0.99.9.GIT

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-21 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-18 22:17 [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin Lukas Sandström
2005-11-18 22:20 ` [PATCH] Document the "ignore objects" feature of git-pack-redundant Lukas Sandström
2005-11-21 11:45 ` [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin Lukas Sandström

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.