Commit 1b5074e
builtin/maintenance: fix locking race when handling "gc" task
The "gc" task has a similar locking race as the one that we have fixed
for the "pack-refs" and "reflog-expire" tasks in preceding commits. Fix
this by splitting up the logic of the "gc" task:
- We execute `gc_before_repack()` in the foreground, which contains
the logic that git-gc(1) itself would execute in the foreground, as
well.
- We spawn git-gc(1) after detaching, but with a new hidden flag that
suppresses calling `gc_before_repack()`.
Like this we have roughly the same logic as git-gc(1) itself and know to
repack refs and reflogs before detaching, thus fixing the race.
Note that `gc_before_repack()` is renamed to `gc_foreground_tasks()` to
better reflect what this function does.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent d2b084c commit 1b5074e
2 files changed
+33
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
820 | | - | |
| 819 | + | |
| 820 | + | |
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| |||
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
| 840 | + | |
840 | 841 | | |
841 | 842 | | |
842 | 843 | | |
| |||
869 | 870 | | |
870 | 871 | | |
871 | 872 | | |
| 873 | + | |
| 874 | + | |
872 | 875 | | |
873 | 876 | | |
874 | 877 | | |
| |||
952 | 955 | | |
953 | 956 | | |
954 | 957 | | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
959 | 963 | | |
960 | | - | |
961 | | - | |
962 | | - | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
963 | 968 | | |
964 | 969 | | |
965 | 970 | | |
| |||
988 | 993 | | |
989 | 994 | | |
990 | 995 | | |
991 | | - | |
992 | | - | |
| 996 | + | |
| 997 | + | |
993 | 998 | | |
994 | 999 | | |
995 | 1000 | | |
| |||
1225 | 1230 | | |
1226 | 1231 | | |
1227 | 1232 | | |
1228 | | - | |
1229 | | - | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1230 | 1241 | | |
1231 | 1242 | | |
1232 | 1243 | | |
| |||
1240 | 1251 | | |
1241 | 1252 | | |
1242 | 1253 | | |
| 1254 | + | |
1243 | 1255 | | |
1244 | 1256 | | |
1245 | 1257 | | |
| |||
1571 | 1583 | | |
1572 | 1584 | | |
1573 | 1585 | | |
1574 | | - | |
| 1586 | + | |
| 1587 | + | |
1575 | 1588 | | |
1576 | 1589 | | |
1577 | 1590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
0 commit comments