builtin-rm: use warning() instead of fprintf(stderr, "warning: ")
[gitweb.git] / builtin-for-each-ref.c
index e59bd8075e44a8de23503a8a59c5fdd2575a9243..5cbb4b081d63b52393a5f85716ba6961a18fa59e 100644 (file)
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
 
 static const char *copy_line(const char *buf)
 {
-       const char *eol = strchr(buf, '\n');
-       if (!eol) // simulate strchrnul()
-               eol = buf + strlen(buf);
+       const char *eol = strchrnul(buf, '\n');
        return xmemdupz(buf, eol - buf);
 }
 
@@ -622,14 +620,16 @@ static char *get_short_ref(struct refinfo *ref)
                for (j = 0; j < i; j++) {
                        const char *rule = ref_rev_parse_rules[j];
                        unsigned char short_objectname[20];
+                       char refname[PATH_MAX];
 
                        /*
                         * the short name is ambiguous, if it resolves
                         * (with this previous rule) to a valid ref
                         * read_ref() returns 0 on success
                         */
-                       if (!read_ref(mkpath(rule, short_name_len, short_name),
-                                     short_objectname))
+                       mksnpath(refname, sizeof(refname),
+                                rule, short_name_len, short_name);
+                       if (!read_ref(refname, short_objectname))
                                break;
                }
 
@@ -943,7 +943,6 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
                return -1;
 
        *sort_tail = s = xcalloc(1, sizeof(*s));
-       sort_tail = &s->next;
 
        if (*arg == '-') {
                s->reverse = 1;