Skip to content

Commit babed89

Browse files
avargitster
authored andcommitted
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. 0e6550a (cocci: add a index-compatibility.pending.cocci, 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cec13b9 commit babed89

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

builtin/mv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 2006 Johannes Schindelin
55
*/
6-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
6+
#define USE_THE_INDEX_VARIABLE
77
#include "builtin.h"
88
#include "config.h"
99
#include "pathspec.h"
@@ -489,7 +489,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
489489
if ((mode & SPARSE) &&
490490
path_in_sparse_checkout(dst, &the_index)) {
491491
/* 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));
493494
struct cache_entry *dst_ce = the_index.cache[dst_pos];
494495

495496
dst_ce->ce_flags &= ~CE_SKIP_WORKTREE;
@@ -500,7 +501,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
500501
!(mode & SPARSE) &&
501502
!path_in_sparse_checkout(dst, &the_index)) {
502503
/* 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));
504506
struct cache_entry *dst_ce = the_index.cache[dst_pos];
505507

506508
/*

builtin/update-index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) Linus Torvalds, 2005
55
*/
6-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
6+
#define USE_THE_INDEX_VARIABLE
77
#include "cache.h"
88
#include "bulk-checkin.h"
99
#include "config.h"
@@ -381,7 +381,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno)
381381
if (has_symlink_leading_path(path, len))
382382
return error("'%s' is beyond a symbolic link", path);
383383

384-
pos = cache_name_pos(path, len);
384+
pos = index_name_pos(&the_index, path, len);
385385
ce = pos < 0 ? NULL : the_index.cache[pos];
386386
if (ce && ce_skip_worktree(ce)) {
387387
/*

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ extern struct index_state the_index;
456456
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
457457
#define read_cache() repo_read_index(the_repository)
458458
#define discard_cache() discard_index(&the_index)
459-
#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
460459
#endif
461460
#endif
462461
#endif

contrib/coccinelle/index-compatibility.cocci

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ identifier ACT = active_cache_tree;
9191
|
9292
- resolve_undo_clear
9393
+ resolve_undo_clear_index
94+
|
95+
- cache_name_pos
96+
+ index_name_pos
9497
)
9598
(
9699
+ &the_index,

contrib/coccinelle/index-compatibility.pending.cocci

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
(
1616
- discard_cache
1717
+ discard_index
18-
|
19-
- cache_name_pos
20-
+ index_name_pos
2118
)
2219
(
2320
+ &the_index,

0 commit comments

Comments
 (0)