Merge branch 'sg/object-as-type-commit-graph-fix'
The commit-graph facility did not work when in-core objects that are promoted from unknown type to commit (e.g. a commit that is accessed via a tag that refers to it) were involved, which has been corrected. * sg/object-as-type-commit-graph-fix: object_as_type: initialize commit-graph-related fields of 'struct commit'
This commit is contained in:
commit
2ed3de439e
15
alloc.c
15
alloc.c
@ -99,18 +99,23 @@ void *alloc_object_node(struct repository *r)
|
||||
return obj;
|
||||
}
|
||||
|
||||
unsigned int alloc_commit_index(struct repository *r)
|
||||
static unsigned int alloc_commit_index(struct repository *r)
|
||||
{
|
||||
return r->parsed_objects->commit_count++;
|
||||
}
|
||||
|
||||
void init_commit_node(struct repository *r, struct commit *c)
|
||||
{
|
||||
c->object.type = OBJ_COMMIT;
|
||||
c->index = alloc_commit_index(r);
|
||||
c->graph_pos = COMMIT_NOT_FROM_GRAPH;
|
||||
c->generation = GENERATION_NUMBER_INFINITY;
|
||||
}
|
||||
|
||||
void *alloc_commit_node(struct repository *r)
|
||||
{
|
||||
struct commit *c = alloc_node(r->parsed_objects->commit_state, sizeof(struct commit));
|
||||
c->object.type = OBJ_COMMIT;
|
||||
c->index = alloc_commit_index(r);
|
||||
c->graph_pos = COMMIT_NOT_FROM_GRAPH;
|
||||
c->generation = GENERATION_NUMBER_INFINITY;
|
||||
init_commit_node(r, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
2
alloc.h
2
alloc.h
@ -9,11 +9,11 @@ struct repository;
|
||||
|
||||
void *alloc_blob_node(struct repository *r);
|
||||
void *alloc_tree_node(struct repository *r);
|
||||
void init_commit_node(struct repository *r, struct commit *c);
|
||||
void *alloc_commit_node(struct repository *r);
|
||||
void *alloc_tag_node(struct repository *r);
|
||||
void *alloc_object_node(struct repository *r);
|
||||
void alloc_report(struct repository *r);
|
||||
unsigned int alloc_commit_index(struct repository *r);
|
||||
|
||||
struct alloc_state *allocate_alloc_state(void);
|
||||
void clear_alloc_state(struct alloc_state *s);
|
||||
|
3
object.c
3
object.c
@ -164,7 +164,8 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type
|
||||
return obj;
|
||||
else if (obj->type == OBJ_NONE) {
|
||||
if (type == OBJ_COMMIT)
|
||||
((struct commit *)obj)->index = alloc_commit_index(r);
|
||||
init_commit_node(r, (struct commit *) obj);
|
||||
else
|
||||
obj->type = type;
|
||||
return obj;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user