Skip to content

Commit cec13b9

Browse files
avargitster
authored andcommitted
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. dc59418 (cocci & cache.h: apply variable section of "pending" index-compatibility, 2022-11-19) 2. 9ea1378 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6193aaa commit cec13b9

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
991991
struct object_id oid;
992992
const char *parent = "HEAD";
993993

994-
if (!active_nr) {
994+
if (!the_index.cache_nr) {
995995
discard_cache();
996996
if (read_cache() < 0)
997997
die(_("Cannot read index"));

cache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,6 @@ extern struct index_state the_index;
454454

455455
#ifndef USE_THE_INDEX_VARIABLE
456456
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
457-
#define active_nr (the_index.cache_nr)
458-
459457
#define read_cache() repo_read_index(the_repository)
460458
#define discard_cache() discard_index(&the_index)
461459
#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))

contrib/coccinelle/index-compatibility.cocci

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
// the_index.* variables
22
@@
33
identifier AC = active_cache;
4+
identifier AN = active_nr;
45
identifier ACC = active_cache_changed;
56
identifier ACT = active_cache_tree;
67
@@
78
(
89
- AC
910
+ the_index.cache
1011
|
12+
- AN
13+
+ the_index.cache_nr
14+
|
1115
- ACC
1216
+ the_index.cache_changed
1317
|
1418
- ACT
1519
+ the_index.cache_tree
1620
)
1721

18-
@@
19-
identifier AN = active_nr;
20-
identifier f != prepare_to_commit;
21-
@@
22-
f(...) {<...
23-
- AN
24-
+ the_index.cache_nr
25-
...>}
26-
2722
// "the_repository" simple cases
2823
@@
2924
@@

0 commit comments

Comments
 (0)