Skip to content

Commit 847a9e5

Browse files
derrickstoleegitster
authored andcommitted
*: remove 'const' qualifier for struct index_state
Several methods specify that they take a 'struct index_state' pointer with the 'const' qualifier because they intend to only query the data, not change it. However, we will be introducing a step very low in the method stack that might modify a sparse-index to become a full index in the case that our queries venture inside a sparse-directory entry. This change only removes the 'const' qualifiers that are necessary for the following change which will actually modify the implementation of index_name_stage_pos(). Signed-off-by: Derrick Stolee <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 839a663 commit 847a9e5

File tree

14 files changed

+68
-68
lines changed

14 files changed

+68
-68
lines changed

attr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
718718
return res;
719719
}
720720

721-
static struct attr_stack *read_attr_from_index(const struct index_state *istate,
721+
static struct attr_stack *read_attr_from_index(struct index_state *istate,
722722
const char *path,
723723
int macro_ok)
724724
{
@@ -748,7 +748,7 @@ static struct attr_stack *read_attr_from_index(const struct index_state *istate,
748748
return res;
749749
}
750750

751-
static struct attr_stack *read_attr(const struct index_state *istate,
751+
static struct attr_stack *read_attr(struct index_state *istate,
752752
const char *path, int macro_ok)
753753
{
754754
struct attr_stack *res = NULL;
@@ -840,7 +840,7 @@ static void push_stack(struct attr_stack **attr_stack_p,
840840
}
841841
}
842842

843-
static void bootstrap_attr_stack(const struct index_state *istate,
843+
static void bootstrap_attr_stack(struct index_state *istate,
844844
struct attr_stack **stack)
845845
{
846846
struct attr_stack *e;
@@ -878,7 +878,7 @@ static void bootstrap_attr_stack(const struct index_state *istate,
878878
push_stack(stack, e, NULL, 0);
879879
}
880880

881-
static void prepare_attr_stack(const struct index_state *istate,
881+
static void prepare_attr_stack(struct index_state *istate,
882882
const char *path, int dirlen,
883883
struct attr_stack **stack)
884884
{
@@ -1078,7 +1078,7 @@ static void determine_macros(struct all_attrs_item *all_attrs,
10781078
* If check->check_nr is non-zero, only attributes in check[] are collected.
10791079
* Otherwise all attributes are collected.
10801080
*/
1081-
static void collect_some_attrs(const struct index_state *istate,
1081+
static void collect_some_attrs(struct index_state *istate,
10821082
const char *path,
10831083
struct attr_check *check)
10841084
{
@@ -1107,7 +1107,7 @@ static void collect_some_attrs(const struct index_state *istate,
11071107
fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
11081108
}
11091109

1110-
void git_check_attr(const struct index_state *istate,
1110+
void git_check_attr(struct index_state *istate,
11111111
const char *path,
11121112
struct attr_check *check)
11131113
{
@@ -1124,7 +1124,7 @@ void git_check_attr(const struct index_state *istate,
11241124
}
11251125
}
11261126

1127-
void git_all_attrs(const struct index_state *istate,
1127+
void git_all_attrs(struct index_state *istate,
11281128
const char *path, struct attr_check *check)
11291129
{
11301130
int i;

attr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ void attr_check_free(struct attr_check *check);
190190
*/
191191
const char *git_attr_name(const struct git_attr *);
192192

193-
void git_check_attr(const struct index_state *istate,
193+
void git_check_attr(struct index_state *istate,
194194
const char *path, struct attr_check *check);
195195

196196
/*
197197
* Retrieve all attributes that apply to the specified path.
198198
* check holds the attributes and their values.
199199
*/
200-
void git_all_attrs(const struct index_state *istate,
200+
void git_all_attrs(struct index_state *istate,
201201
const char *path, struct attr_check *check);
202202

203203
enum git_attr_direction {

builtin/ls-files.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static const char *tag_modified = "";
5757
static const char *tag_skip_worktree = "";
5858
static const char *tag_resolve_undo = "";
5959

60-
static void write_eolinfo(const struct index_state *istate,
60+
static void write_eolinfo(struct index_state *istate,
6161
const struct cache_entry *ce, const char *path)
6262
{
6363
if (show_eol) {
@@ -122,7 +122,7 @@ static void print_debug(const struct cache_entry *ce)
122122
}
123123
}
124124

125-
static void show_dir_entry(const struct index_state *istate,
125+
static void show_dir_entry(struct index_state *istate,
126126
const char *tag, struct dir_entry *ent)
127127
{
128128
int len = max_prefix_len;
@@ -139,7 +139,7 @@ static void show_dir_entry(const struct index_state *istate,
139139
write_name(ent->name);
140140
}
141141

142-
static void show_other_files(const struct index_state *istate,
142+
static void show_other_files(struct index_state *istate,
143143
const struct dir_struct *dir)
144144
{
145145
int i;
@@ -152,7 +152,7 @@ static void show_other_files(const struct index_state *istate,
152152
}
153153
}
154154

155-
static void show_killed_files(const struct index_state *istate,
155+
static void show_killed_files(struct index_state *istate,
156156
const struct dir_struct *dir)
157157
{
158158
int i;
@@ -254,7 +254,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
254254
}
255255
}
256256

257-
static void show_ru_info(const struct index_state *istate)
257+
static void show_ru_info(struct index_state *istate)
258258
{
259259
struct string_list_item *item;
260260

cache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na
800800
* index_name_pos(&index, "f", 1) -> -3
801801
* index_name_pos(&index, "g", 1) -> -5
802802
*/
803-
int index_name_pos(const struct index_state *, const char *name, int namelen);
803+
int index_name_pos(struct index_state *, const char *name, int namelen);
804804

805805
/*
806806
* Some functions return the negative complement of an insert position when a
@@ -850,8 +850,8 @@ int add_file_to_index(struct index_state *, const char *path, int flags);
850850
int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
851851
int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
852852
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
853-
int index_name_is_other(const struct index_state *, const char *, int);
854-
void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);
853+
int index_name_is_other(struct index_state *, const char *, int);
854+
void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
855855

856856
/* do stat comparison even if CE_VALID is true */
857857
#define CE_MATCH_IGNORE_VALID 01

convert.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static const char *gather_convert_stats_ascii(const char *data, unsigned long si
138138
}
139139
}
140140

141-
const char *get_cached_convert_stats_ascii(const struct index_state *istate,
141+
const char *get_cached_convert_stats_ascii(struct index_state *istate,
142142
const char *path)
143143
{
144144
const char *ret;
@@ -222,7 +222,7 @@ static void check_global_conv_flags_eol(const char *path,
222222
}
223223
}
224224

225-
static int has_crlf_in_index(const struct index_state *istate, const char *path)
225+
static int has_crlf_in_index(struct index_state *istate, const char *path)
226226
{
227227
unsigned long sz;
228228
void *data;
@@ -496,7 +496,7 @@ static int encode_to_worktree(const char *path, const char *src, size_t src_len,
496496
return 1;
497497
}
498498

499-
static int crlf_to_git(const struct index_state *istate,
499+
static int crlf_to_git(struct index_state *istate,
500500
const char *path, const char *src, size_t len,
501501
struct strbuf *buf,
502502
enum crlf_action crlf_action, int conv_flags)
@@ -1307,7 +1307,7 @@ struct conv_attrs {
13071307

13081308
static struct attr_check *check;
13091309

1310-
static void convert_attrs(const struct index_state *istate,
1310+
static void convert_attrs(struct index_state *istate,
13111311
struct conv_attrs *ca, const char *path)
13121312
{
13131313
struct attr_check_item *ccheck = NULL;
@@ -1369,7 +1369,7 @@ void reset_parsed_attributes(void)
13691369
user_convert_tail = NULL;
13701370
}
13711371

1372-
int would_convert_to_git_filter_fd(const struct index_state *istate, const char *path)
1372+
int would_convert_to_git_filter_fd(struct index_state *istate, const char *path)
13731373
{
13741374
struct conv_attrs ca;
13751375

@@ -1388,7 +1388,7 @@ int would_convert_to_git_filter_fd(const struct index_state *istate, const char
13881388
return apply_filter(path, NULL, 0, -1, NULL, ca.drv, CAP_CLEAN, NULL, NULL);
13891389
}
13901390

1391-
const char *get_convert_attr_ascii(const struct index_state *istate, const char *path)
1391+
const char *get_convert_attr_ascii(struct index_state *istate, const char *path)
13921392
{
13931393
struct conv_attrs ca;
13941394

@@ -1414,7 +1414,7 @@ const char *get_convert_attr_ascii(const struct index_state *istate, const char
14141414
return "";
14151415
}
14161416

1417-
int convert_to_git(const struct index_state *istate,
1417+
int convert_to_git(struct index_state *istate,
14181418
const char *path, const char *src, size_t len,
14191419
struct strbuf *dst, int conv_flags)
14201420
{
@@ -1448,7 +1448,7 @@ int convert_to_git(const struct index_state *istate,
14481448
return ret | ident_to_git(src, len, dst, ca.ident);
14491449
}
14501450

1451-
void convert_to_git_filter_fd(const struct index_state *istate,
1451+
void convert_to_git_filter_fd(struct index_state *istate,
14521452
const char *path, int fd, struct strbuf *dst,
14531453
int conv_flags)
14541454
{
@@ -1466,7 +1466,7 @@ void convert_to_git_filter_fd(const struct index_state *istate,
14661466
ident_to_git(dst->buf, dst->len, dst, ca.ident);
14671467
}
14681468

1469-
static int convert_to_working_tree_internal(const struct index_state *istate,
1469+
static int convert_to_working_tree_internal(struct index_state *istate,
14701470
const char *path, const char *src,
14711471
size_t len, struct strbuf *dst,
14721472
int normalizing,
@@ -1510,7 +1510,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate,
15101510
return ret | ret_filter;
15111511
}
15121512

1513-
int async_convert_to_working_tree(const struct index_state *istate,
1513+
int async_convert_to_working_tree(struct index_state *istate,
15141514
const char *path, const char *src,
15151515
size_t len, struct strbuf *dst,
15161516
const struct checkout_metadata *meta,
@@ -1519,15 +1519,15 @@ int async_convert_to_working_tree(const struct index_state *istate,
15191519
return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, dco);
15201520
}
15211521

1522-
int convert_to_working_tree(const struct index_state *istate,
1522+
int convert_to_working_tree(struct index_state *istate,
15231523
const char *path, const char *src,
15241524
size_t len, struct strbuf *dst,
15251525
const struct checkout_metadata *meta)
15261526
{
15271527
return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, NULL);
15281528
}
15291529

1530-
int renormalize_buffer(const struct index_state *istate, const char *path,
1530+
int renormalize_buffer(struct index_state *istate, const char *path,
15311531
const char *src, size_t len, struct strbuf *dst)
15321532
{
15331533
int ret = convert_to_working_tree_internal(istate, path, src, len, dst, 1, NULL, NULL);
@@ -1964,7 +1964,7 @@ static struct stream_filter *ident_filter(const struct object_id *oid)
19641964
* Note that you would be crazy to set CRLF, smudge/clean or ident to a
19651965
* large binary blob you would want us not to slurp into the memory!
19661966
*/
1967-
struct stream_filter *get_stream_filter(const struct index_state *istate,
1967+
struct stream_filter *get_stream_filter(struct index_state *istate,
19681968
const char *path,
19691969
const struct object_id *oid)
19701970
{

convert.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,41 @@ struct checkout_metadata {
6565

6666
extern enum eol core_eol;
6767
extern char *check_roundtrip_encoding;
68-
const char *get_cached_convert_stats_ascii(const struct index_state *istate,
68+
const char *get_cached_convert_stats_ascii(struct index_state *istate,
6969
const char *path);
7070
const char *get_wt_convert_stats_ascii(const char *path);
71-
const char *get_convert_attr_ascii(const struct index_state *istate,
71+
const char *get_convert_attr_ascii(struct index_state *istate,
7272
const char *path);
7373

7474
/* returns 1 if *dst was used */
75-
int convert_to_git(const struct index_state *istate,
75+
int convert_to_git(struct index_state *istate,
7676
const char *path, const char *src, size_t len,
7777
struct strbuf *dst, int conv_flags);
78-
int convert_to_working_tree(const struct index_state *istate,
78+
int convert_to_working_tree(struct index_state *istate,
7979
const char *path, const char *src,
8080
size_t len, struct strbuf *dst,
8181
const struct checkout_metadata *meta);
82-
int async_convert_to_working_tree(const struct index_state *istate,
82+
int async_convert_to_working_tree(struct index_state *istate,
8383
const char *path, const char *src,
8484
size_t len, struct strbuf *dst,
8585
const struct checkout_metadata *meta,
8686
void *dco);
8787
int async_query_available_blobs(const char *cmd,
8888
struct string_list *available_paths);
89-
int renormalize_buffer(const struct index_state *istate,
89+
int renormalize_buffer(struct index_state *istate,
9090
const char *path, const char *src, size_t len,
9191
struct strbuf *dst);
92-
static inline int would_convert_to_git(const struct index_state *istate,
92+
static inline int would_convert_to_git(struct index_state *istate,
9393
const char *path)
9494
{
9595
return convert_to_git(istate, path, NULL, 0, NULL, 0);
9696
}
9797
/* Precondition: would_convert_to_git_filter_fd(path) == true */
98-
void convert_to_git_filter_fd(const struct index_state *istate,
98+
void convert_to_git_filter_fd(struct index_state *istate,
9999
const char *path, int fd,
100100
struct strbuf *dst,
101101
int conv_flags);
102-
int would_convert_to_git_filter_fd(const struct index_state *istate,
102+
int would_convert_to_git_filter_fd(struct index_state *istate,
103103
const char *path);
104104

105105
/*
@@ -133,7 +133,7 @@ void reset_parsed_attributes(void);
133133

134134
struct stream_filter; /* opaque */
135135

136-
struct stream_filter *get_stream_filter(const struct index_state *istate,
136+
struct stream_filter *get_stream_filter(struct index_state *istate,
137137
const char *path,
138138
const struct object_id *);
139139
void free_stream_filter(struct stream_filter *);

dir.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
306306
* [1] Only if DO_MATCH_DIRECTORY is passed; otherwise, this is NOT a match.
307307
* [2] Only if DO_MATCH_LEADING_PATHSPEC is passed; otherwise, not a match.
308308
*/
309-
static int match_pathspec_item(const struct index_state *istate,
309+
static int match_pathspec_item(struct index_state *istate,
310310
const struct pathspec_item *item, int prefix,
311311
const char *name, int namelen, unsigned flags)
312312
{
@@ -429,7 +429,7 @@ static int match_pathspec_item(const struct index_state *istate,
429429
* pathspec did not match any names, which could indicate that the
430430
* user mistyped the nth pathspec.
431431
*/
432-
static int do_match_pathspec(const struct index_state *istate,
432+
static int do_match_pathspec(struct index_state *istate,
433433
const struct pathspec *ps,
434434
const char *name, int namelen,
435435
int prefix, char *seen,
@@ -500,7 +500,7 @@ static int do_match_pathspec(const struct index_state *istate,
500500
return retval;
501501
}
502502

503-
static int match_pathspec_with_flags(const struct index_state *istate,
503+
static int match_pathspec_with_flags(struct index_state *istate,
504504
const struct pathspec *ps,
505505
const char *name, int namelen,
506506
int prefix, char *seen, unsigned flags)
@@ -516,7 +516,7 @@ static int match_pathspec_with_flags(const struct index_state *istate,
516516
return negative ? 0 : positive;
517517
}
518518

519-
int match_pathspec(const struct index_state *istate,
519+
int match_pathspec(struct index_state *istate,
520520
const struct pathspec *ps,
521521
const char *name, int namelen,
522522
int prefix, char *seen, int is_dir)
@@ -529,7 +529,7 @@ int match_pathspec(const struct index_state *istate,
529529
/**
530530
* Check if a submodule is a superset of the pathspec
531531
*/
532-
int submodule_path_match(const struct index_state *istate,
532+
int submodule_path_match(struct index_state *istate,
533533
const struct pathspec *ps,
534534
const char *submodule_name,
535535
char *seen)
@@ -892,7 +892,7 @@ void add_pattern(const char *string, const char *base,
892892
add_pattern_to_hashsets(pl, pattern);
893893
}
894894

895-
static int read_skip_worktree_file_from_index(const struct index_state *istate,
895+
static int read_skip_worktree_file_from_index(struct index_state *istate,
896896
const char *path,
897897
size_t *size_out, char **data_out,
898898
struct oid_stat *oid_stat)

0 commit comments

Comments
 (0)