read-cache: mark cache_entry pointers const
ie_match_stat and ie_modified only derefence their struct cache_entry pointers for reading. Add const to the parameter declaration here and do the same for the static helper function used by them, as it's the same there as well. This allows callers to pass in const pointers. Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jun 2, 2013 at 17:46 UTC
21a6b9fa4212277d925b789795e83ac96c2aaa01
2 files changed
+12
-10
cache.h
+2
-2
@@ -482,8 +482,8 @@ extern void *read_blob_data_from_index(struct index_state *, const char *, unsig
482
#define CE_MATCH_RACY_IS_DIRTY 02
483
/* do stat comparison even if CE_SKIP_WORKTREE is true */
484
#define CE_MATCH_IGNORE_SKIP_WORKTREE 04
485
-extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
486
-extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
485
+extern int ie_match_stat(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
486
+extern int ie_modified(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
487
488
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern sastisfies GFNM_ONESTAR */
489
read-cache.c
+10
-8
@@ -91,7 +91,7 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
91
ce_mark_uptodate(ce);
92
}
93
94
-static int ce_compare_data(struct cache_entry *ce, struct stat *st)
94
+static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
95
{
96
int match = -1;
97
int fd = open(ce->name, O_RDONLY);
@@ -105,7 +105,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
105
return match;
106
}
107
108
-static int ce_compare_link(struct cache_entry *ce, size_t expected_size)
108
+static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
109
{
110
int match = -1;
111
void *buffer;
@@ -126,7 +126,7 @@ static int ce_compare_link(struct cache_entry *ce, size_t expected_size)
126
return match;
127
}
128
129
-static int ce_compare_gitlink(struct cache_entry *ce)
129
+static int ce_compare_gitlink(const struct cache_entry *ce)
130
{
131
unsigned char sha1[20];
132
@@ -143,7 +143,7 @@ static int ce_compare_gitlink(struct cache_entry *ce)
143
return hashcmp(sha1, ce->sha1);
144
}
145
146
-static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
146
+static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)
147
{
148
switch (st->st_mode & S_IFMT) {
149
case S_IFREG:
@@ -163,7 +163,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
163
return 0;
164
}
165
166
-static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
166
+static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
167
{
168
unsigned int changed = 0;
169
@@ -239,7 +239,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
239
return changed;
240
}
241
242
-static int is_racy_timestamp(const struct index_state *istate, struct cache_entry *ce)
242
+static int is_racy_timestamp(const struct index_state *istate,
243
+ const struct cache_entry *ce)
244
{
245
return (!S_ISGITLINK(ce->ce_mode) &&
246
istate->timestamp.sec &&
@@ -255,7 +256,7 @@ static int is_racy_timestamp(const struct index_state *istate, struct cache_entr
256
}
257
258
int ie_match_stat(const struct index_state *istate,
258
- struct cache_entry *ce, struct stat *st,
259
+ const struct cache_entry *ce, struct stat *st,
260
unsigned int options)
261
{
262
unsigned int changed;
@@ -311,7 +312,8 @@ int ie_match_stat(const struct index_state *istate,
312
}
313
314
int ie_modified(const struct index_state *istate,
314
- struct cache_entry *ce, struct stat *st, unsigned int options)
315
+ const struct cache_entry *ce,
316
+ struct stat *st, unsigned int options)
317
{
318
int changed, changed_fs;
319