git.vger.kernel.org archive mirror
 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

* [PATCH] Document the "ignore objects" feature of git-pack-redundant
  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 ` Lukas Sandström
  2005-11-21 11:45 ` [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin Lukas Sandström
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Sandström @ 2005-11-18 22:20 UTC (permalink / raw)
  To: git; +Cc: Lukas Sandström, Junio C Hamano

Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>

---

 Documentation/git-pack-redundant.txt |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

applies-to: 5053091ee7d1f4b32b18a21f4b255cf1141cf72c
e417344dab21aca41fbc1f99d935ef033e53e3a8
diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt
index 2e23cbc..9fe86ae 100644
--- a/Documentation/git-pack-redundant.txt
+++ b/Documentation/git-pack-redundant.txt
@@ -16,6 +16,14 @@ This program computes which packs in you
 are redundant. The output is suitable for piping to
 'xargs rm' if you are in the root of the repository.
 
+git-pack-redundant accepts a list of objects on standard input. Any objects
+given will be ignored when checking which packs are required. This makes the 
+following command useful when wanting to remove packs which contain unreachable
+objects.
+
+git-fsck-objects --full --unreachable | cut -d ' ' -f3 | \
+git-pack-redundant --all | xargs rm
+
 OPTIONS
 -------
 
---
0.99.9.GIT

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

* Re: [PATCH] Make git-pack-redundant take a list of unimportant objs on   stdin
  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 ` Lukas Sandström
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Sandström @ 2005-11-21 11:45 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Lukas Sandström, Git Mailing List

Lukas Sandström wrote:
> 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>
> 

The patch which documents this feature was committed (9a888b758f48d88d1e83c9765e33d4452710d5a5),
but not the feature. Did you just miss the patch, or is there something wrong with it?

/Lukas

^ permalink raw reply	[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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).