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

[PATCH] gc --auto: do not run 'pack-refs' and 'reflog expire' twice

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 31, 2014, 04:33 UTC
Message-ID
<1409459610-8695-1-git-send-email-pclouds@gmail.com>

In the --auto code path, gc_before_repack() is called once in parent process then again in the forked process. Stop the second run.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/gc.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/builtin/gc.c b/builtin/gc.c
index 8d219d8..fb0cff3 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -261,6 +261,11 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
 
 static int gc_before_repack(void)
 {
+	static int nr_runs;
+
+	if (nr_runs++)
+		return 0;
+
 	if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD))
 		return error(FAILED_RUN, pack_refs_cmd.argv[0]);
 
-- 
2.1.0.rc0.78.gc0d8480
Next: Junio C Hamano
Message 1 of 4 in “gc --auto: do not run 'pack-refs' and 'reflog expire' twice”
  1. gc --auto: do not run 'pack-refs' and 'reflog expire' twiceNguyễn Thái Ngọc Duy, Aug 31, 2014
  2. Junio C HamanoSep 2, 2014
  3. Junio C HamanoSep 2, 2014
  4. Duy NguyenSep 4, 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.