refs: use name "prefix" consistently

In the context of the for_each_ref() functions, call the prefix that references must start with "prefix". (In some places it was called "base".) This is clearer, and also prevents confusion with another planned use of the word "base". Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jun 18, 2016 at 06:15 UTC 4633a846f5cf085bc11de702d0e78177aa44a907
2 files changed +19 -19
refs/files-backend.c
+12 -12
@@ -542,7 +542,7 @@ static struct ref_entry *current_ref;
542 typedef int each_ref_entry_fn(struct ref_entry *entry, void *cb_data);
543
544 struct ref_entry_cb {
545 - const char *base;
545 + const char *prefix;
546 int trim;
547 int flags;
548 each_ref_fn *fn;
@@ -559,7 +559,7 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data)
559 struct ref_entry *old_current_ref;
560 int retval;
561
562 - if (!starts_with(entry->name, data->base))
562 + if (!starts_with(entry->name, data->prefix))
563 return 0;
564
565 if (!(data->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
@@ -1824,12 +1824,12 @@ int peel_ref(const char *refname, unsigned char *sha1)
1824
1825 /*
1826 * Call fn for each reference in the specified ref_cache, omitting
1827 - * references not in the containing_dir of base. fn is called for all
1828 - * references, including broken ones. If fn ever returns a non-zero
1827 + * references not in the containing_dir of prefix. Call fn for all
1828 + * references, including broken ones. If fn ever returns a non-zero
1829 * value, stop the iteration and return that value; otherwise, return
1830 * 0.
1831 */
1832 -static int do_for_each_entry(struct ref_cache *refs, const char *base,
1832 +static int do_for_each_entry(struct ref_cache *refs, const char *prefix,
1833 each_ref_entry_fn fn, void *cb_data)
1834 {
1835 struct packed_ref_cache *packed_ref_cache;
@@ -1846,8 +1846,8 @@ static int do_for_each_entry(struct ref_cache *refs, const char *base,
1846 * disk.
1847 */
1848 loose_dir = get_loose_refs(refs);
1849 - if (base && *base) {
1850 - loose_dir = find_containing_dir(loose_dir, base, 0);
1849 + if (prefix && *prefix) {
1850 + loose_dir = find_containing_dir(loose_dir, prefix, 0);
1851 }
1852 if (loose_dir)
1853 prime_ref_dir(loose_dir);
@@ -1855,8 +1855,8 @@ static int do_for_each_entry(struct ref_cache *refs, const char *base,
1855 packed_ref_cache = get_packed_ref_cache(refs);
1856 acquire_packed_ref_cache(packed_ref_cache);
1857 packed_dir = get_packed_ref_dir(packed_ref_cache);
1858 - if (base && *base) {
1859 - packed_dir = find_containing_dir(packed_dir, base, 0);
1858 + if (prefix && *prefix) {
1859 + packed_dir = find_containing_dir(packed_dir, prefix, 0);
1860 }
1861
1862 if (packed_dir && loose_dir) {
@@ -1878,14 +1878,14 @@ static int do_for_each_entry(struct ref_cache *refs, const char *base,
1878 return retval;
1879 }
1880
1881 -int do_for_each_ref(const char *submodule, const char *base,
1881 +int do_for_each_ref(const char *submodule, const char *prefix,
1882 each_ref_fn fn, int trim, int flags, void *cb_data)
1883 {
1884 struct ref_entry_cb data;
1885 struct ref_cache *refs;
1886
1887 refs = get_ref_cache(submodule);
1888 - data.base = base;
1888 + data.prefix = prefix;
1889 data.trim = trim;
1890 data.flags = flags;
1891 data.fn = fn;
@@ -1896,7 +1896,7 @@ int do_for_each_ref(const char *submodule, const char *base,
1896 if (ref_paranoia)
1897 data.flags |= DO_FOR_EACH_INCLUDE_BROKEN;
1898
1899 - return do_for_each_entry(refs, base, do_one_ref, &data);
1899 + return do_for_each_entry(refs, prefix, do_one_ref, &data);
1900 }
1901
1902 /*
refs/refs-internal.h
+7 -7
@@ -250,16 +250,16 @@ int rename_ref_available(const char *oldname, const char *newname);
250
251 /*
252 * Call fn for each reference in the specified submodule for which the
253 - * refname begins with base. If trim is non-zero, then trim that many
254 - * characters off the beginning of each refname before passing the
255 - * refname to fn. flags can be DO_FOR_EACH_INCLUDE_BROKEN to include
256 - * broken references in the iteration. If fn ever returns a non-zero
257 - * value, stop the iteration and return that value; otherwise, return
258 - * 0.
253 + * refname begins with prefix. If trim is non-zero, then trim that
254 + * many characters off the beginning of each refname before passing
255 + * the refname to fn. flags can be DO_FOR_EACH_INCLUDE_BROKEN to
256 + * include broken references in the iteration. If fn ever returns a
257 + * non-zero value, stop the iteration and return that value;
258 + * otherwise, return 0.
259 *
260 * This is the common backend for the for_each_*ref* functions.
261 */
262 -int do_for_each_ref(const char *submodule, const char *base,
262 +int do_for_each_ref(const char *submodule, const char *prefix,
263 each_ref_fn fn, int trim, int flags, void *cb_data);
264
265 /*