path: root/builtin/tag.c
diff options
authorNguyễn Thái Ngọc Duy <>2011-11-13 10:22:14 (GMT)
committerJunio C Hamano <>2011-11-13 20:21:06 (GMT)
commitc6893323917cbf4cb66c29ba2ac03014a44f0f0c (patch)
treecc14f88d5ebfd114e5c80f74506eff6c9a5fa68b /builtin/tag.c
parentbc1bbe0c19a6ff39522b4fa3259f34150e308e1f (diff)
Convert many resolve_ref() calls to read_ref*() and ref_exists()
resolve_ref() may return a pointer to a static buffer, which is not safe for long-term use because if another resolve_ref() call happens, the buffer may be changed. Many call sites though do not care about this buffer. They simply check if the return value is NULL or not. Convert all these call sites to new wrappers to reduce resolve_ref() calls from 57 to 34. If we change resolve_ref() prototype later on to avoid passing static buffer out, this helps reduce changes. Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/tag.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 9b6fd95..439249d 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -174,7 +174,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)
had_error = 1;
- if (!resolve_ref(ref, sha1, 1, NULL)) {
+ if (read_ref(ref, sha1)) {
error(_("tag '%s' not found."), *p);
had_error = 1;
@@ -518,7 +518,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (strbuf_check_tag_ref(&ref, tag))
die(_("'%s' is not a valid tag name."), tag);
- if (!resolve_ref(ref.buf, prev, 1, NULL))
+ if (read_ref(ref.buf, prev))
else if (!force)
die(_("tag '%s' already exists"), tag);