aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-03-30 05:07:15 +0200
committerJunio C Hamano <gitster@pobox.com>2009-03-30 01:22:53 -0700
commit2a8177b63d39503b182248b04ffcc75e3495754c (patch)
tree3aa3fa4f7fa0fc216166c1946efe1d5d33657249 /refs.c
parenteaa759b9141f125d7e55a4b08b60497845d3c52e (diff)
downloadgit-2a8177b63d39503b182248b04ffcc75e3495754c.tar.gz
git-2a8177b63d39503b182248b04ffcc75e3495754c.tar.xz
refs: add "for_each_ref_in" function to refactor "for_each_*_ref" functions
The "for_each_{tag,branch,remote,replace,}_ref" functions are redefined in terms of "for_each_ref_in" so that we can lose the hardcoded length of prefix strings from the code. Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index aeef257ee..2d198a1ad 100644
--- a/refs.c
+++ b/refs.c
@@ -647,19 +647,24 @@ int for_each_ref(each_ref_fn fn, void *cb_data)
return do_for_each_ref("refs/", fn, 0, 0, cb_data);
}
+int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
+{
+ return do_for_each_ref(prefix, fn, strlen(prefix), 0, cb_data);
+}
+
int for_each_tag_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/tags/", fn, 10, 0, cb_data);
+ return for_each_ref_in("refs/tags/", fn, cb_data);
}
int for_each_branch_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/heads/", fn, 11, 0, cb_data);
+ return for_each_ref_in("refs/heads/", fn, cb_data);
}
int for_each_remote_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/remotes/", fn, 13, 0, cb_data);
+ return for_each_ref_in("refs/remotes/", fn, cb_data);
}
int for_each_rawref(each_ref_fn fn, void *cb_data)