test-dump-untracked-cache: don't modify the untracked cache
[gitweb.git] / reflog-walk.c
index f8e743a23bef06bbf144339dc79f2186ec40805b..85b8a54241048bb2cc037c2c114b49e7c7e7968b 100644 (file)
@@ -56,12 +56,11 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
                }
        }
        if (reflogs->nr == 0) {
-               int len = strlen(ref);
-               char *refname = xmalloc(len + 12);
-               sprintf(refname, "refs/%s", ref);
+               char *refname = xstrfmt("refs/%s", ref);
                for_each_reflog_ent(refname, read_one_reflog, reflogs);
                if (reflogs->nr == 0) {
-                       sprintf(refname, "refs/heads/%s", ref);
+                       free(refname);
+                       refname = xstrfmt("refs/heads/%s", ref);
                        for_each_reflog_ent(refname, read_one_reflog, reflogs);
                }
                free(refname);