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

[PATCH] repack: call prune_packed_objects() and update_server_info() directly

From
René Scharfe <l.s.r@web.de>
Date
Sep 13, 2014, 07:28 UTC
Message-ID
<5413F201.8030005@web.de>

Call the functions behind git prune-packed and git update-server-info directly instead of using run_command(). This is shorter, easier and quicker.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/repack.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index fc088db..2aae05d 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -377,6 +377,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	/* End of pack replacement. */
 
 	if (delete_redundant) {
+		int opts = 0;
 		sort_string_list(&names);
 		for_each_string_list_item(item, &existing_packs) {
 			char *sha1;
@@ -387,25 +388,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 			if (!string_list_has_string(&names, sha1))
 				remove_redundant_pack(packdir, item->string);
 		}
-		argv_array_push(&cmd_args, "prune-packed");
-		if (quiet)
-			argv_array_push(&cmd_args, "--quiet");
-
-		memset(&cmd, 0, sizeof(cmd));
-		cmd.argv = cmd_args.argv;
-		cmd.git_cmd = 1;
-		run_command(&cmd);
-		argv_array_clear(&cmd_args);
+		if (!quiet && isatty(2))
+			opts |= PRUNE_PACKED_VERBOSE;
+		prune_packed_objects(opts);
 	}
 
-	if (!no_update_server_info) {
-		argv_array_push(&cmd_args, "update-server-info");
-		memset(&cmd, 0, sizeof(cmd));
-		cmd.argv = cmd_args.argv;
-		cmd.git_cmd = 1;
-		run_command(&cmd);
-		argv_array_clear(&cmd_args);
-	}
+	if (!no_update_server_info)
+		update_server_info(0);
 	remove_temporary_files();
 	string_list_clear(&names, 0);
 	string_list_clear(&rollback, 0);
-- 
2.1.0
Next: Stefan Beller
Message 1 of 9 in “repack: call prune_packed_objects() and update_server_info() directly”
  1. repack: call prune_packed_objects() and update_server_info() directlyRené Scharfe, Sep 13, 2014
  2. Stefan BellerSep 13, 2014
  3. Jeff KingSep 13, 2014
  4. 1/3 prune-packed: fix minor memory leakJeff King, Sep 13, 2014
  5. 2/3 make update-server-info more robustJeff King, Sep 13, 2014
  6. René ScharfeSep 14, 2014
  7. Junio C HamanoSep 15, 2014
  8. Jeff KingSep 15, 2014
  9. 3/3 server-info: clean up after writing info/packsJeff King, Sep 13, 2014

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.