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

[PATCH] gc: remove gc.pid file at end of execution

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Sep 26, 2013, 09:18 UTC
Message-ID
<1380187098-8519-1-git-send-email-Matthieu.Moy@imag.fr>

This file isn't really harmful, but isn't useful either, and can create minor annoyance for the user:

* It's confusing, as the presence of a *.pid file often implies that a
  process is currently running. A user running "ls .git/" and finding
  this file may incorrectly guess that a "git gc" is currently running.
* Leaving this file means that a "git gc" in an already gc-ed repo is
  no-longer a no-op. A user running "git gc" in a set of repositories,
  and then synchronizing this set (e.g. rsync -av, unison, ...) will see
  all the gc.pid files as changed, which creates useless noise.

This patch unlinks the file after the garbage collection is done, so that gc.pid is actually present only during execution.

Future versions of Git may want to use the information left in the gc.pid file (e.g. for policies like "don't attempt to run a gc if one has already been ran less than X hours ago"). If so, this patch can safely be reverted. For now, let's not bother the users.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 builtin/gc.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/builtin/gc.c b/builtin/gc.c
index 891a2c2..db39963 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -316,5 +316,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 		warning(_("There are too many unreachable loose objects; "
 			"run 'git prune' to remove them."));
 
+	/*
+	 * The file isn't harmful, but isn't useful either.
+	 */
+	unlink(git_path("gc.pid"));
 	return 0;
 }
-- 
1.8.4.474.g128a96c
Next: Jonathan Nieder
Message 1 of 5 in “gc: remove gc.pid file at end of execution”
  1. gc: remove gc.pid file at end of executionMatthieu Moy, Sep 26, 2013
  2. Jonathan NiederSep 28, 2013
  3. Duy NguyenSep 28, 2013
  4. Junio C HamanoOct 16, 2013
  5. gc: remove gc.pid file at end of executionJonathan Nieder, Oct 16, 2013

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.