Commit 09d5dc3
committed
Simplify cache API
Earlier, add_file_to_index() invalidated the path in the cache-tree
but remove_file_from_cache() did not, and the user of the latter
needed to invalidate the entry himself. This led to a few bugs due to
missed invalidate calls already. This patch makes the management of
cache-tree less error prone by making more invalidate calls from lower
level cache API functions.
The rules are:
- If you are going to write the index, you should either maintain
cache_tree correctly.
- If you cannot, alternatively you can remove the entire cache_tree
by calling cache_tree_free() before you call write_cache().
- When you modify the index, cache_tree_invalidate_path() should be
called with the path you are modifying, to discard the entry from
the cache-tree structure.
- The following cache API functions exported from read-cache.c (and
the macro whose names have "cache" instead of "index")
automatically call cache_tree_invalidate_path() for you:
- remove_file_from_index();
- add_file_to_index();
- add_index_entry();
You can modify the index bypassing the above API functions
(e.g. find an existing cache entry from the index and modify it in
place). You need to call cache_tree_invalidate_path() yourself in
such a case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 611d813 commit 09d5dc3
File tree
6 files changed
+4
-19
lines changed6 files changed
+4
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2394 | 2394 | | |
2395 | 2395 | | |
2396 | 2396 | | |
2397 | | - | |
2398 | 2397 | | |
2399 | 2398 | | |
2400 | 2399 | | |
| |||
2549 | 2548 | | |
2550 | 2549 | | |
2551 | 2550 | | |
2552 | | - | |
2553 | 2551 | | |
2554 | 2552 | | |
2555 | 2553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 279 | + | |
| 280 | + | |
284 | 281 | | |
285 | 282 | | |
286 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | 230 | | |
232 | 231 | | |
233 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | 198 | | |
204 | 199 | | |
205 | 200 | | |
| |||
239 | 234 | | |
240 | 235 | | |
241 | 236 | | |
242 | | - | |
243 | 237 | | |
244 | 238 | | |
245 | 239 | | |
| |||
284 | 278 | | |
285 | 279 | | |
286 | 280 | | |
287 | | - | |
288 | 281 | | |
289 | 282 | | |
290 | 283 | | |
| |||
367 | 360 | | |
368 | 361 | | |
369 | 362 | | |
370 | | - | |
371 | 363 | | |
372 | 364 | | |
373 | 365 | | |
| |||
474 | 466 | | |
475 | 467 | | |
476 | 468 | | |
477 | | - | |
478 | 469 | | |
479 | 470 | | |
480 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
| |||
430 | 431 | | |
431 | 432 | | |
432 | 433 | | |
433 | | - | |
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
| 676 | + | |
676 | 677 | | |
677 | 678 | | |
678 | 679 | | |
| |||
0 commit comments