]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/gc.c
maintenance: take a lock on the objects directory
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 17 Sep 2020 18:11:48 +0000 (18:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Sep 2020 18:30:05 +0000 (11:30 -0700)
commitd7514f6ed57d20bcc9dcfb43016b95dba82ba790
treee5fb5acb0e4b14f471c5f541edce34671127a140
parent090511bc0b73bf3054f11df6f275ad3a3abbf34f
maintenance: take a lock on the objects directory

Performing maintenance on a Git repository involves writing data to the
.git directory, which is not safe to do with multiple writers attempting
the same operation. Ensure that only one 'git maintenance' process is
running at a time by holding a file-based lock. Simply the presence of
the .git/maintenance.lock file will prevent future maintenance. This
lock is never committed, since it does not represent meaningful data.
Instead, it is only a placeholder.

If the lock file already exists, then no maintenance tasks are
attempted. This will become very important later when we implement the
'prefetch' task, as this is our stop-gap from creating a recursive process
loop between 'git fetch' and 'git maintenance run --auto'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c