t1001-read-tree-m-2way.sh: use the $( ... ) construct for command substitution
[gitweb.git] / commit.c
index 6ceee6acbc0a6c3c44d38e91c9f138a89fb3d075..0f28902bc351fef9d621cfe290f887921ec779c4 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -141,12 +141,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)
                return 1;
        }
        pos = -pos - 1;
-       if (commit_graft_alloc <= ++commit_graft_nr) {
-               commit_graft_alloc = alloc_nr(commit_graft_alloc);
-               commit_graft = xrealloc(commit_graft,
-                                       sizeof(*commit_graft) *
-                                       commit_graft_alloc);
-       }
+       ALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);
+       commit_graft_nr++;
        if (pos < commit_graft_nr)
                memmove(commit_graft + pos + 1,
                        commit_graft + pos,
@@ -542,7 +538,7 @@ define_commit_slab(author_date_slab, unsigned long);
 static void record_author_date(struct author_date_slab *author_date,
                               struct commit *commit)
 {
-       const char *buf, *line_end;
+       const char *buf, *line_end, *ident_line;
        char *buffer = NULL;
        struct ident_split ident;
        char *date_end;
@@ -560,14 +556,14 @@ static void record_author_date(struct author_date_slab *author_date,
             buf;
             buf = line_end + 1) {
                line_end = strchrnul(buf, '\n');
-               if (!starts_with(buf, "author ")) {
+               ident_line = skip_prefix(buf, "author ");
+               if (!ident_line) {
                        if (!line_end[0] || line_end[1] == '\n')
                                return; /* end of header */
                        continue;
                }
                if (split_ident_line(&ident,
-                                    buf + strlen("author "),
-                                    line_end - (buf + strlen("author "))) ||
+                                    ident_line, line_end - ident_line) ||
                    !ident.date_begin || !ident.date_end)
                        goto fail_exit; /* malformed "author" line */
                break;
@@ -1187,10 +1183,8 @@ static void parse_gpg_output(struct signature_check *sigc)
        for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
                const char *found, *next;
 
-               if (starts_with(buf, sigcheck_gpg_status[i].check + 1)) {
-                       /* At the very beginning of the buffer */
-                       found = buf + strlen(sigcheck_gpg_status[i].check + 1);
-               } else {
+               found = skip_prefix(buf, sigcheck_gpg_status[i].check + 1);
+               if (!found) {
                        found = strstr(buf, sigcheck_gpg_status[i].check);
                        if (!found)
                                continue;