Skip to content

Commit 79c7ca5

Browse files
mhaggergitster
authored andcommitted
invalidate_ref_cache(): rename function from invalidate_cached_refs()
It is the cache that is being invalidated, not the references, and the new name makes this unambiguous. Rename other items analogously: * struct cached_refs -> struct ref_cache * cached_refs (the variable) -> ref_cache * clear_cached_refs() -> clear_ref_cache() * create_cached_refs() -> create_ref_cache() * get_cached_refs() -> get_ref_cache() Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b0e15f commit 79c7ca5

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

refs.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ static struct ref_entry *search_ref_array(struct ref_array *array, const char *n
134134
* Future: need to be in "struct repository"
135135
* when doing a full libification.
136136
*/
137-
static struct cached_refs {
138-
struct cached_refs *next;
137+
static struct ref_cache {
138+
struct ref_cache *next;
139139
char did_loose;
140140
char did_packed;
141141
struct ref_array loose;
142142
struct ref_array packed;
143143
/* The submodule name, or "" for the main repo. */
144144
char name[FLEX_ARRAY];
145-
} *cached_refs;
145+
} *ref_cache;
146146

147147
static struct ref_entry *current_ref;
148148

@@ -158,7 +158,7 @@ static void free_ref_array(struct ref_array *array)
158158
array->refs = NULL;
159159
}
160160

161-
static void clear_cached_refs(struct cached_refs *ca)
161+
static void clear_ref_cache(struct ref_cache *ca)
162162
{
163163
if (ca->did_loose)
164164
free_ref_array(&ca->loose);
@@ -167,27 +167,27 @@ static void clear_cached_refs(struct cached_refs *ca)
167167
ca->did_loose = ca->did_packed = 0;
168168
}
169169

170-
static struct cached_refs *create_cached_refs(const char *submodule)
170+
static struct ref_cache *create_ref_cache(const char *submodule)
171171
{
172172
int len;
173-
struct cached_refs *refs;
173+
struct ref_cache *refs;
174174
if (!submodule)
175175
submodule = "";
176176
len = strlen(submodule) + 1;
177-
refs = xcalloc(1, sizeof(struct cached_refs) + len);
177+
refs = xcalloc(1, sizeof(struct ref_cache) + len);
178178
memcpy(refs->name, submodule, len);
179179
return refs;
180180
}
181181

182182
/*
183-
* Return a pointer to a cached_refs for the specified submodule. For
183+
* Return a pointer to a ref_cache for the specified submodule. For
184184
* the main repository, use submodule==NULL. The returned structure
185185
* will be allocated and initialized but not necessarily populated; it
186186
* should not be freed.
187187
*/
188-
static struct cached_refs *get_cached_refs(const char *submodule)
188+
static struct ref_cache *get_ref_cache(const char *submodule)
189189
{
190-
struct cached_refs *refs = cached_refs;
190+
struct ref_cache *refs = ref_cache;
191191
if (!submodule)
192192
submodule = "";
193193
while (refs) {
@@ -196,17 +196,17 @@ static struct cached_refs *get_cached_refs(const char *submodule)
196196
refs = refs->next;
197197
}
198198

199-
refs = create_cached_refs(submodule);
200-
refs->next = cached_refs;
201-
cached_refs = refs;
199+
refs = create_ref_cache(submodule);
200+
refs->next = ref_cache;
201+
ref_cache = refs;
202202
return refs;
203203
}
204204

205-
static void invalidate_cached_refs(void)
205+
static void invalidate_ref_cache(void)
206206
{
207-
struct cached_refs *refs = cached_refs;
207+
struct ref_cache *refs = ref_cache;
208208
while (refs) {
209-
clear_cached_refs(refs);
209+
clear_ref_cache(refs);
210210
refs = refs->next;
211211
}
212212
}
@@ -257,7 +257,7 @@ void clear_extra_refs(void)
257257

258258
static struct ref_array *get_packed_refs(const char *submodule)
259259
{
260-
struct cached_refs *refs = get_cached_refs(submodule);
260+
struct ref_cache *refs = get_ref_cache(submodule);
261261

262262
if (!refs->did_packed) {
263263
const char *packed_refs_file;
@@ -379,7 +379,7 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
379379

380380
static struct ref_array *get_loose_refs(const char *submodule)
381381
{
382-
struct cached_refs *refs = get_cached_refs(submodule);
382+
struct ref_cache *refs = get_ref_cache(submodule);
383383

384384
if (!refs->did_loose) {
385385
get_ref_dir(submodule, "refs", &refs->loose);
@@ -1228,7 +1228,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
12281228
ret |= repack_without_ref(refname);
12291229

12301230
unlink_or_warn(git_path("logs/%s", lock->ref_name));
1231-
invalidate_cached_refs();
1231+
invalidate_ref_cache();
12321232
unlock_ref(lock);
12331233
return ret;
12341234
}
@@ -1527,7 +1527,7 @@ int write_ref_sha1(struct ref_lock *lock,
15271527
unlock_ref(lock);
15281528
return -1;
15291529
}
1530-
invalidate_cached_refs();
1530+
invalidate_ref_cache();
15311531
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
15321532
(strcmp(lock->ref_name, lock->orig_ref_name) &&
15331533
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {

0 commit comments

Comments
 (0)