cocci & cache.h: fully apply "active_nr" part of index-compatibility
Apply the "active_nr" part of "index-compatibility.pending.cocci", which was left out in [1] due to an in-flight conflict. As of [2] the topic we conflicted with has been merged to "master", so we can fully apply this rule. 1. dc594180d9e (cocci & cache.h: apply variable section of "pending" index-compatibility, 2022-11-19) 2. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Feb 10, 2023 at 11:28 UTC
cec13b9514868cf38b41330bbc3ea91a7961dd00
3 files changed
+5
-12
builtin/commit.c
+1
-1
@@ -991,7 +991,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
991
struct object_id oid;
992
const char *parent = "HEAD";
993
994
- if (!active_nr) {
994
+ if (!the_index.cache_nr) {
995
discard_cache();
996
if (read_cache() < 0)
997
die(_("Cannot read index"));
cache.h
-2
@@ -454,8 +454,6 @@ extern struct index_state the_index;
454
455
#ifndef USE_THE_INDEX_VARIABLE
456
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
457
-#define active_nr (the_index.cache_nr)
458
-
457
#define read_cache() repo_read_index(the_repository)
458
#define discard_cache() discard_index(&the_index)
459
#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
contrib/coccinelle/index-compatibility.cocci
+4
-9
@@ -1,6 +1,7 @@
1
// the_index.* variables
2
@@
3
identifier AC = active_cache;
4
+identifier AN = active_nr;
5
identifier ACC = active_cache_changed;
6
identifier ACT = active_cache_tree;
7
@@
@@ -8,6 +9,9 @@ identifier ACT = active_cache_tree;
9
- AC
10
+ the_index.cache
11
|
12
+- AN
13
++ the_index.cache_nr
14
+|
15
- ACC
16
+ the_index.cache_changed
17
|
@@ -15,15 +19,6 @@ identifier ACT = active_cache_tree;
19
+ the_index.cache_tree
20
)
21
18
-@@
19
-identifier AN = active_nr;
20
-identifier f != prepare_to_commit;
21
-@@
22
- f(...) {<...
23
-- AN
24
-+ the_index.cache_nr
25
- ...>}
26
-
22
// "the_repository" simple cases
23
@@
24
@@