const unsigned char *sha1,
int quiet)
{
- if (obj->type != TYPE_COMMIT) {
+ if (obj->type != OBJ_COMMIT) {
if (!quiet)
error("Object %s is a %s, not a commit",
sha1_to_hex(sha1), typename(obj->type));
if (!obj) {
struct commit *ret = alloc_commit_node();
created_object(sha1, &ret->object);
- ret->object.type = TYPE_COMMIT;
+ ret->object.type = OBJ_COMMIT;
return ret;
}
if (!obj->type)
- obj->type = TYPE_COMMIT;
+ obj->type = OBJ_COMMIT;
return check_commit(obj, sha1, 0);
}
return 0;
}
+void free_commit_grafts(void)
+{
+ int pos = commit_graft_nr;
+ while (pos >= 0)
+ free(commit_graft[pos--]);
+ commit_graft_nr = 0;
+}
+
struct commit_graft *read_graft_line(char *buf, int len)
{
/* The format is just "Commit Parent1 Parent2 ...\n" */
static void prepare_commit_graft(void)
{
static int commit_graft_prepared;
- char *graft_file;
+ static char *last_graft_file;
+ char *graft_file = get_graft_file();
+
+ if (last_graft_file) {
+ if (!strcmp(graft_file, last_graft_file))
+ return;
+ free_commit_grafts();
+ }
+ if (last_graft_file)
+ free(last_graft_file);
+ last_graft_file = strdup(graft_file);
- if (commit_graft_prepared)
- return;
- graft_file = get_graft_file();
read_graft_file(graft_file);
commit_graft_prepared = 1;
}