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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Oct 17, 2011 at 04:38 UTC
79c7ca54e1ae3f8c42baa6f792fd84d6cdab1af3
1 file changed
+20
-20
refs.c
+20
-20
@@ -134,15 +134,15 @@ static struct ref_entry *search_ref_array(struct ref_array *array, const char *n
134
* Future: need to be in "struct repository"
135
* when doing a full libification.
136
*/
137
-static struct cached_refs {
138
- struct cached_refs *next;
137
+static struct ref_cache {
138
+ struct ref_cache *next;
139
char did_loose;
140
char did_packed;
141
struct ref_array loose;
142
struct ref_array packed;
143
/* The submodule name, or "" for the main repo. */
144
char name[FLEX_ARRAY];
145
-} *cached_refs;
145
+} *ref_cache;
146
147
static struct ref_entry *current_ref;
148
@@ -158,7 +158,7 @@ static void free_ref_array(struct ref_array *array)
158
array->refs = NULL;
159
}
160
161
-static void clear_cached_refs(struct cached_refs *ca)
161
+static void clear_ref_cache(struct ref_cache *ca)
162
{
163
if (ca->did_loose)
164
free_ref_array(&ca->loose);
@@ -167,27 +167,27 @@ static void clear_cached_refs(struct cached_refs *ca)
167
ca->did_loose = ca->did_packed = 0;
168
}
169
170
-static struct cached_refs *create_cached_refs(const char *submodule)
170
+static struct ref_cache *create_ref_cache(const char *submodule)
171
{
172
int len;
173
- struct cached_refs *refs;
173
+ struct ref_cache *refs;
174
if (!submodule)
175
submodule = "";
176
len = strlen(submodule) + 1;
177
- refs = xcalloc(1, sizeof(struct cached_refs) + len);
177
+ refs = xcalloc(1, sizeof(struct ref_cache) + len);
178
memcpy(refs->name, submodule, len);
179
return refs;
180
}
181
182
/*
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
184
* the main repository, use submodule==NULL. The returned structure
185
* will be allocated and initialized but not necessarily populated; it
186
* should not be freed.
187
*/
188
-static struct cached_refs *get_cached_refs(const char *submodule)
188
+static struct ref_cache *get_ref_cache(const char *submodule)
189
{
190
- struct cached_refs *refs = cached_refs;
190
+ struct ref_cache *refs = ref_cache;
191
if (!submodule)
192
submodule = "";
193
while (refs) {
@@ -196,17 +196,17 @@ static struct cached_refs *get_cached_refs(const char *submodule)
196
refs = refs->next;
197
}
198
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;
202
return refs;
203
}
204
205
-static void invalidate_cached_refs(void)
205
+static void invalidate_ref_cache(void)
206
{
207
- struct cached_refs *refs = cached_refs;
207
+ struct ref_cache *refs = ref_cache;
208
while (refs) {
209
- clear_cached_refs(refs);
209
+ clear_ref_cache(refs);
210
refs = refs->next;
211
}
212
}
@@ -257,7 +257,7 @@ void clear_extra_refs(void)
257
258
static struct ref_array *get_packed_refs(const char *submodule)
259
{
260
- struct cached_refs *refs = get_cached_refs(submodule);
260
+ struct ref_cache *refs = get_ref_cache(submodule);
261
262
if (!refs->did_packed) {
263
const char *packed_refs_file;
@@ -379,7 +379,7 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
379
380
static struct ref_array *get_loose_refs(const char *submodule)
381
{
382
- struct cached_refs *refs = get_cached_refs(submodule);
382
+ struct ref_cache *refs = get_ref_cache(submodule);
383
384
if (!refs->did_loose) {
385
get_ref_dir(submodule, "refs", &refs->loose);
@@ -1228,7 +1228,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
1228
ret |= repack_without_ref(refname);
1229
1230
unlink_or_warn(git_path("logs/%s", lock->ref_name));
1231
- invalidate_cached_refs();
1231
+ invalidate_ref_cache();
1232
unlock_ref(lock);
1233
return ret;
1234
}
@@ -1527,7 +1527,7 @@ int write_ref_sha1(struct ref_lock *lock,
1527
unlock_ref(lock);
1528
return -1;
1529
}
1530
- invalidate_cached_refs();
1530
+ invalidate_ref_cache();
1531
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
1532
(strcmp(lock->ref_name, lock->orig_ref_name) &&
1533
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {