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

Subsystems: the rest

STALE3711d

3 messages, 1 author, 2016-06-15 · open the first message on its own page

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

From: Lukas Sandström <hidden>
Date: 2016-06-15 22:42:12

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 <redacted>

---

 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

[PATCH] Document the "ignore objects" feature of git-pack-redundant

From: Lukas Sandström <hidden>
Date: 2016-06-15 22:42:12

Signed-off-by: Lukas Sandström <redacted>

---

 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

Re: [PATCH] Make git-pack-redundant take a list of unimportant objs on stdin

From: Lukas Sandström <hidden>
Date: 2016-06-15 22:42:13

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 <redacted>
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help