threads / discuss / 35020

"git gc" leaving gc.pid files around

Subject: "git gc" leaving gc.pid files around

## tl;dr

2 messages between Sep 25, 2013 and Sep 25, 2013.

replies: 1people: 2as markdown or json

Matthieu Moy· Sep 25, 2013, 18:29 UTC · lore
Hi,

Since 64a99eb47, "git gc" creates a lock file gc.pid while running. I just noticed that the file is never deleted. The locking mechanism works, but leaving these files around creates a minor annoyance.

For example, I run "git gc" in all my repos from time to time (in a cron job). It normally does nothing in repos that have not changed, but now, it updates the gc.pid file.

As a result, all the gc.pid files show up in unison (synchronization tool between machines) for example.

Is there any reason not to do something like this:
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -316,5 +316,6 @@ 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."));
 
+       unlink(git_path("gc.pid"));
        return 0;
 }

?
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Duy Nguyen· Sep 25, 2013, 19:06 UTC · re: Matthieu Moy · lore

Re: "git gc" leaving gc.pid files around

On Thu, Sep 26, 2013 at 1:29 AM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 26 quoted lines
> Hi,
>
> Since 64a99eb47, "git gc" creates a lock file gc.pid while running. I
> just noticed that the file is never deleted. The locking mechanism
> works, but leaving these files around creates a minor annoyance.
>
> For example, I run "git gc" in all my repos from time to time (in a cron
> job). It normally does nothing in repos that have not changed, but now,
> it updates the gc.pid file.
>
> As a result, all the gc.pid files show up in unison (synchronization
> tool between machines) for example.
>
> Is there any reason not to do something like this:
>
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -316,5 +316,6 @@ 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."));
>
> +       unlink(git_path("gc.pid"));
>         return 0;
>  }
>
> ?

I considered this and decided it was not a big problem for another file lying around in .git. Moreover it could provide the last gc time to gc itself, so we could avoid running gc too often, for example no more than one gc a day. But if it causes actual annoyance, I think unlink() is ok.

-- 
Duy

← back to recent threads