summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index 7ccd721..6ca04d3 100644
--- a/refs.c
+++ b/refs.c
@@ -68,6 +68,15 @@ static int do_for_each_ref(const char *base, int (*fn)(const char *path, const u
return retval;
}
+int head_ref(int (*fn)(const char *path, const unsigned char *sha1))
+{
+ unsigned char sha1[20];
+ const char *headpath = git_path("HEAD");
+ if (!read_ref(headpath, sha1))
+ fn(headpath, sha1);
+ return do_for_each_ref(get_refs_directory(), fn);
+}
+
int for_each_ref(int (*fn)(const char *path, const unsigned char *sha1))
{
return do_for_each_ref(get_refs_directory(), fn);