提交 dd5d9deb 编写于 作者: S Stefan Beller 提交者: Junio C Hamano

alloc: add repository argument to alloc_commit_index

This is a small mechanical change; it doesn't change the
implementation to handle repositories other than the_repository yet.
Use a macro to catch callers passing a repository other than
the_repository at compile time.
Signed-off-by: NStefan Beller <sbeller@google.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 17bfe873
...@@ -82,7 +82,7 @@ void *alloc_object_node_the_repository(void) ...@@ -82,7 +82,7 @@ void *alloc_object_node_the_repository(void)
static struct alloc_state commit_state; static struct alloc_state commit_state;
unsigned int alloc_commit_index(void) unsigned int alloc_commit_index_the_repository(void)
{ {
static unsigned int count; static unsigned int count;
return count++; return count++;
...@@ -92,7 +92,7 @@ void *alloc_commit_node_the_repository(void) ...@@ -92,7 +92,7 @@ void *alloc_commit_node_the_repository(void)
{ {
struct commit *c = alloc_node(&commit_state, sizeof(struct commit)); struct commit *c = alloc_node(&commit_state, sizeof(struct commit));
c->object.type = OBJ_COMMIT; c->object.type = OBJ_COMMIT;
c->index = alloc_commit_index(); c->index = alloc_commit_index(the_repository);
return c; return c;
} }
......
...@@ -1776,7 +1776,8 @@ extern void *alloc_tag_node_the_repository(void); ...@@ -1776,7 +1776,8 @@ extern void *alloc_tag_node_the_repository(void);
extern void *alloc_object_node_the_repository(void); extern void *alloc_object_node_the_repository(void);
#define alloc_report(r) alloc_report_##r() #define alloc_report(r) alloc_report_##r()
extern void alloc_report_the_repository(void); extern void alloc_report_the_repository(void);
extern unsigned int alloc_commit_index(void); #define alloc_commit_index(r) alloc_commit_index_##r()
extern unsigned int alloc_commit_index_the_repository(void);
/* pkt-line.c */ /* pkt-line.c */
void packet_trace_identity(const char *prog); void packet_trace_identity(const char *prog);
......
...@@ -162,7 +162,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet) ...@@ -162,7 +162,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
return obj; return obj;
else if (obj->type == OBJ_NONE) { else if (obj->type == OBJ_NONE) {
if (type == OBJ_COMMIT) if (type == OBJ_COMMIT)
((struct commit *)obj)->index = alloc_commit_index(); ((struct commit *)obj)->index = alloc_commit_index(the_repository);
obj->type = type; obj->type = type;
return obj; return obj;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册