struct commit *c = lookup_commit_reference(sha1);
if (!c)
die(_("could not parse %s"), ref_name);
- if (hashcmp(sha1, get_object_hash(c->object))) {
+ if (hashcmp(sha1, c->object.oid.hash)) {
warning(_("%s %s is not a commit!"),
ref_name, sha1_to_hex(sha1));
}
if ((len + 1) % entry_size)
goto bad_graft_data;
i = (len + 1) / entry_size - 1;
- graft = xmalloc(sizeof(*graft) + GIT_SHA1_RAWSZ * i);
+ graft = xmalloc(st_add(sizeof(*graft), st_mult(GIT_SHA1_RAWSZ, i)));
graft->nr_parent = i;
if (get_oid_hex(buf, &graft->oid))
goto bad_graft_data;
if (!ret) {
enum object_type type;
unsigned long size;
- ret = read_sha1_file(get_object_hash(commit->object), &type, &size);
+ ret = read_sha1_file(commit->object.oid.hash, &type, &size);
if (!ret)
die("cannot read commit object %s",
oid_to_hex(&commit->object.oid));
bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
pptr = &item->parents;
- graft = lookup_commit_graft(get_object_hash(item->object));
+ graft = lookup_commit_graft(item->object.oid.hash);
while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
struct commit *new_parent;
return -1;
if (item->object.parsed)
return 0;
- buffer = read_sha1_file(get_object_hash(item->object), &type, &size);
+ buffer = read_sha1_file(item->object.oid.hash, &type, &size);
if (!buffer)
return quiet_on_missing ? -1 :
error("Could not read %s",
while (*p && (*p != '\n' || p[1] != '\n'))
p++;
if (*p) {
- p += 2;
+ p = skip_blank_lines(p + 2);
for (eol = p; *eol && *eol != '\n'; eol++)
; /* do nothing */
} else
for (i = 0; i < a->nr; i++) {
object = a->objects[i].item;
- commit = lookup_commit_reference_gently(get_object_hash(*object), 1);
+ commit = lookup_commit_reference_gently(object->oid.hash, 1);
if (commit)
clear_commit_marks(commit, mark);
}
work = xcalloc(cnt, sizeof(*work));
redundant = xcalloc(cnt, 1);
- filled_index = xmalloc(sizeof(*filled_index) * (cnt - 1));
+ ALLOC_ARRAY(filled_index, cnt - 1);
for (i = 0; i < cnt; i++)
parse_commit(array[i]);
{
struct strbuf sig = STRBUF_INIT;
int inspos, copypos;
+ const char *eoh;
/* find the end of the header */
- inspos = strstr(buf->buf, "\n\n") - buf->buf + 1;
+ eoh = strstr(buf->buf, "\n\n");
+ if (!eoh)
+ inspos = buf->len;
+ else
+ inspos = eoh - buf->buf + 1;
if (!keyid || !*keyid)
keyid = get_signing_key();
desc = merge_remote_util(parent);
if (!desc || !desc->obj)
return;
- buf = read_sha1_file(get_object_hash(*desc->obj), &type, &size);
+ buf = read_sha1_file(desc->obj->oid.hash, &type, &size);
if (!buf || type != OBJ_TAG)
goto free_return;
len = parse_signature(buf, size);
return &new->next;
}
-void print_commit_list(struct commit_list *list,
- const char *format_cur,
- const char *format_last)
-{
- for ( ; list; list = list->next) {
- const char *format = list->next ? format_cur : format_last;
- printf(format, oid_to_hex(&list->item->object.oid));
- }
-}
-
const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
{
int key_len = strlen(key);