X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=fast-import.c;h=a6bce661963812691503116e8d61d9ef90f96526;hb=4deba8b7798aac52e33aa8e1c49a8cdc0940ac36;hp=3c035a57886329acf4d53a600af0a82ee55d514b;hpb=6dbcb59e8271c16cbec486932bd3069279e09c60;p=git.git diff --git a/fast-import.c b/fast-import.c index 3c035a578..a6bce6619 100644 --- a/fast-import.c +++ b/fast-import.c @@ -43,7 +43,7 @@ Format of STDIN stream: new_tag ::= 'tag' sp tag_str lf 'from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf - 'tagger' sp name '<' email '>' when lf + ('tagger' sp name '<' email '>' when lf)? tag_msg; tag_msg ::= data; @@ -554,6 +554,10 @@ static void *pool_alloc(size_t len) struct mem_pool *p; void *r; + /* round up to a 'uintmax_t' alignment */ + if (len & (sizeof(uintmax_t) - 1)) + len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1)); + for (p = mem_pool; p; p = p->next_pool) if ((p->end - p->next_free >= len)) break; @@ -572,9 +576,6 @@ static void *pool_alloc(size_t len) } r = p->next_free; - /* round out to a 'uintmax_t' alignment */ - if (len & (sizeof(uintmax_t) - 1)) - len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1)); p->next_free += len; return r; } @@ -982,8 +983,10 @@ static void end_packfile(void) pack_id++; } - else + else { + close(old_p->pack_fd); unlink(old_p->pack_name); + } free(old_p); /* We can't carry a delta across packfiles. */ @@ -1745,9 +1748,12 @@ static int validate_raw_date(const char *src, char *result, int maxlen) { const char *orig_src = src; char *endp, sign; + unsigned long date; + + errno = 0; - strtoul(src, &endp, 10); - if (endp == src || *endp != ' ') + date = strtoul(src, &endp, 10); + if (errno || endp == src || *endp != ' ') return -1; src = endp + 1; @@ -1755,8 +1761,8 @@ static int validate_raw_date(const char *src, char *result, int maxlen) return -1; sign = *src; - strtoul(src + 1, &endp, 10); - if (endp == src || *endp || (endp - orig_src) >= maxlen) + date = strtoul(src + 1, &endp, 10); + if (errno || endp == src || *endp || (endp - orig_src) >= maxlen) return -1; strcpy(result, orig_src); @@ -2262,23 +2268,27 @@ static void parse_new_tag(void) read_next_command(); /* tagger ... */ - if (prefixcmp(command_buf.buf, "tagger ")) - die("Expected tagger command, got %s", command_buf.buf); - tagger = parse_ident(command_buf.buf + 7); + if (!prefixcmp(command_buf.buf, "tagger ")) { + tagger = parse_ident(command_buf.buf + 7); + read_next_command(); + } else + tagger = NULL; /* tag payload/message */ - read_next_command(); parse_data(&msg); /* build the tag object */ strbuf_reset(&new_data); + strbuf_addf(&new_data, - "object %s\n" - "type %s\n" - "tag %s\n" - "tagger %s\n" - "\n", - sha1_to_hex(sha1), commit_type, t->name, tagger); + "object %s\n" + "type %s\n" + "tag %s\n", + sha1_to_hex(sha1), commit_type, t->name); + if (tagger) + strbuf_addf(&new_data, + "tagger %s\n", tagger); + strbuf_addch(&new_data, '\n'); strbuf_addbuf(&new_data, &msg); free(tagger);