cocci & cache.h: apply pending "index_cache_pos" rule
Apply the rule added in [1] to change "cache_name_pos" to "index_name_pos", which allows us to get rid of another "USE_THE_INDEX_COMPATIBILITY_MACROS" macro. The replacement of "USE_THE_INDEX_COMPATIBILITY_MACROS" here with "USE_THE_INDEX_VARIABLE" is a manual change on top, now that these files only use "&the_index", and don't need any compatibility macros (or functions). 1. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) 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
babed893f52a44771dd9d85329ee3bd64438adfb
5 files changed
+10
-9
builtin/mv.c
+5
-3
@@ -3,7 +3,7 @@
3
*
4
* Copyright (C) 2006 Johannes Schindelin
5
*/
6
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
6
+#define USE_THE_INDEX_VARIABLE
7
#include "builtin.h"
8
#include "config.h"
9
#include "pathspec.h"
@@ -489,7 +489,8 @@ remove_entry:
489
if ((mode & SPARSE) &&
490
path_in_sparse_checkout(dst, &the_index)) {
491
/* from out-of-cone to in-cone */
492
- int dst_pos = cache_name_pos(dst, strlen(dst));
492
+ int dst_pos = index_name_pos(&the_index, dst,
493
+ strlen(dst));
494
struct cache_entry *dst_ce = the_index.cache[dst_pos];
495
496
dst_ce->ce_flags &= ~CE_SKIP_WORKTREE;
@@ -500,7 +501,8 @@ remove_entry:
501
!(mode & SPARSE) &&
502
!path_in_sparse_checkout(dst, &the_index)) {
503
/* from in-cone to out-of-cone */
503
- int dst_pos = cache_name_pos(dst, strlen(dst));
504
+ int dst_pos = index_name_pos(&the_index, dst,
505
+ strlen(dst));
506
struct cache_entry *dst_ce = the_index.cache[dst_pos];
507
508
/*
builtin/update-index.c
+2
-2
@@ -3,7 +3,7 @@
3
*
4
* Copyright (C) Linus Torvalds, 2005
5
*/
6
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
6
+#define USE_THE_INDEX_VARIABLE
7
#include "cache.h"
8
#include "bulk-checkin.h"
9
#include "config.h"
@@ -381,7 +381,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno)
381
if (has_symlink_leading_path(path, len))
382
return error("'%s' is beyond a symbolic link", path);
383
384
- pos = cache_name_pos(path, len);
384
+ pos = index_name_pos(&the_index, path, len);
385
ce = pos < 0 ? NULL : the_index.cache[pos];
386
if (ce && ce_skip_worktree(ce)) {
387
/*
cache.h
-1
@@ -456,7 +456,6 @@ extern struct index_state the_index;
456
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
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))
459
#endif
460
#endif
461
#endif
contrib/coccinelle/index-compatibility.cocci
+3
@@ -91,6 +91,9 @@ identifier ACT = active_cache_tree;
91
|
92
- resolve_undo_clear
93
+ resolve_undo_clear_index
94
+|
95
+- cache_name_pos
96
++ index_name_pos
97
)
98
(
99
+ &the_index,
contrib/coccinelle/index-compatibility.pending.cocci
-3
@@ -15,9 +15,6 @@
15
(
16
- discard_cache
17
+ discard_index
18
-|
19
-- cache_name_pos
20
-+ index_name_pos
18
)
19
(
20
+ &the_index,