Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 refs.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/refs.c b/refs.c
index d856b1a..8ef1cb0 100644
--- a/refs.c
+++ b/refs.c
@@ -1721,32 +1721,33 @@ static int do_for_each_ref(struct ref_cache *refs, 
const char *base,
        return do_for_each_entry(refs, base, do_one_ref, &data);
 }
 
-static int do_head_ref(const char *submodule, each_ref_fn fn, void *cb_data)
+static int do_one_head_ref(const char *ref, const char *submodule,
+                     each_ref_fn fn, void *cb_data)
 {
        unsigned char sha1[20];
        int flag;
 
        if (submodule) {
-               if (resolve_gitlink_ref(submodule, "HEAD", sha1) == 0)
-                       return fn("HEAD", sha1, 0, cb_data);
+               if (resolve_gitlink_ref(submodule, ref, sha1) == 0)
+                       return fn(ref, sha1, 0, cb_data);
 
                return 0;
        }
 
-       if (!read_ref_full("HEAD", sha1, 1, &flag))
-               return fn("HEAD", sha1, flag, cb_data);
+       if (!read_ref_full(ref, sha1, 1, &flag))
+               return fn(ref, sha1, flag, cb_data);
 
        return 0;
 }
 
 int head_ref(each_ref_fn fn, void *cb_data)
 {
-       return do_head_ref(NULL, fn, cb_data);
+       return do_one_head_ref("HEAD", NULL, fn, cb_data);
 }
 
 int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
 {
-       return do_head_ref(submodule, fn, cb_data);
+       return do_one_head_ref("HEAD", submodule, fn, cb_data);
 }
 
 int for_each_ref(each_ref_fn fn, void *cb_data)
-- 
1.8.5.1.77.g42c48fa

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to