git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Lukas Sandström <lukass@etek.chalmers.se>
Date
Nov 18, 2005, 22:17 UTC
Message-ID
<437E530E.1020803@etek.chalmers.se>

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
Next: Lukas Sandström
Message 1 of 3 in “Make git-pack-redundant take a list of unimportant objs on stdin”
  1. Make git-pack-redundant take a list of unimportant objs on stdinLukas Sandström, Nov 18, 2005
  2. Document the "ignore objects" feature of git-pack-redundantLukas Sandström, Nov 18, 2005
  3. Lukas SandströmNov 21, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.