Commit 5452ae9
committed
lockfile: add holder info file for debugging stale locks
When a lock file is left behind (e.g., after a crash or SIGKILL), the
error message tells users to remove it manually but provides no
information about which process created it. This makes debugging
difficult, especially when multiple Git processes may be running.
Add an opt-in feature that creates a `.holder` file alongside each lock
file containing the PID of the process that created the lock. When
enabled via GIT_LOCK_HOLDER_INFO=1, this PID is displayed in lock
conflict error messages, making it easier to identify stale locks or
debug locking issues.
The holder file is:
- Created only when GIT_LOCK_HOLDER_INFO=1 is set (opt-in)
- Registered as a tempfile for automatic cleanup by signal handlers
- Stored separately from the lock file to maintain backward
compatibility with existing tools that parse lock file contents
Example error message with the feature enabled:
Unable to create '/path/to/.git/index.lock': File exists.
Lock is held by process 12345.
Another git process seems to be running in this repository...
Signed-off-by: Paulo Casaretto <[email protected]>1 parent 6ab38b7 commit 5452ae9
File tree
5 files changed
+176
-12
lines changed- Documentation
- t
5 files changed
+176
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
1013 | 1020 | | |
1014 | 1021 | | |
1015 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
74 | 130 | | |
75 | 131 | | |
76 | 132 | | |
| |||
80 | 136 | | |
81 | 137 | | |
82 | 138 | | |
83 | | - | |
84 | 139 | | |
| 140 | + | |
85 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
86 | 145 | | |
87 | 146 | | |
88 | 147 | | |
| |||
151 | 210 | | |
152 | 211 | | |
153 | 212 | | |
154 | | - | |
155 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
156 | 227 | | |
157 | 228 | | |
158 | 229 | | |
159 | | - | |
160 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
161 | 233 | | |
162 | 234 | | |
163 | 235 | | |
| |||
207 | 279 | | |
208 | 280 | | |
209 | 281 | | |
| 282 | + | |
| 283 | + | |
210 | 284 | | |
211 | 285 | | |
212 | 286 | | |
| |||
216 | 290 | | |
217 | 291 | | |
218 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
| |||
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
322 | | - | |
323 | | - | |
324 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
325 | 332 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 333 | + | |
330 | 334 | | |
331 | 335 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
0 commit comments