tree-walk: copy object ID before use
[gitweb.git] / builtin / show-branch.c
index 363cf8509af5bf640da60c36118b841da06918fe..934e5149448783e32acc8b605f202384af7d96ee 100644 (file)
@@ -412,7 +412,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
        /* If both heads/foo and tags/foo exists, get_sha1 would
         * get confused.
         */
-       if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
+       if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
                ofs = 5;
        return append_ref(refname + ofs, oid, 0);
 }
@@ -427,7 +427,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
        /* If both heads/foo and tags/foo exists, get_sha1 would
         * get confused.
         */
-       if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
+       if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
                ofs = 5;
        return append_ref(refname + ofs, oid, 0);
 }
@@ -485,7 +485,7 @@ static void snarf_refs(int head, int remotes)
 static int rev_is_head(const char *head, const char *name,
                       unsigned char *head_sha1, unsigned char *sha1)
 {
-       if (!head || (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
+       if (!head || (head_sha1 && sha1 && !hasheq(head_sha1, sha1)))
                return 0;
        skip_prefix(head, "refs/heads/", &head);
        if (!skip_prefix(name, "refs/heads/", &name))
@@ -604,6 +604,7 @@ static int parse_reflog_param(const struct option *opt, const char *arg,
 {
        char *ep;
        const char **base = (const char **)opt->value;
+       BUG_ON_OPT_NEG(unset);
        if (!arg)
                arg = "";
        reflog = strtoul(arg, &ep, 10);
@@ -674,7 +675,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                { OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
                            N_("show <n> most recent ref-log entries starting at "
                               "base"),
-                           PARSE_OPT_OPTARG,
+                           PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
                            parse_reflog_param },
                OPT_END()
        };