Skip to content

Commit 2f6c767

Browse files
stefanbellergitster
authored andcommitted
commit: allow prepare_commit_graft to handle arbitrary repositories
Move the global variable 'commit_graft_prepared' into the object pool and convert the function prepare_commit_graft to work an arbitrary repositories. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eee4502 commit 2f6c767

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

commit.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,17 @@ static int read_graft_file(struct repository *r, const char *graft_file)
196196
return 0;
197197
}
198198

199-
#define prepare_commit_graft(r) prepare_commit_graft_##r()
200-
static void prepare_commit_graft_the_repository(void)
199+
static void prepare_commit_graft(struct repository *r)
201200
{
202-
static int commit_graft_prepared;
203201
char *graft_file;
204202

205-
if (commit_graft_prepared)
203+
if (r->parsed_objects->commit_graft_prepared)
206204
return;
207-
graft_file = get_graft_file(the_repository);
208-
read_graft_file(the_repository, graft_file);
205+
graft_file = get_graft_file(r);
206+
read_graft_file(r, graft_file);
209207
/* make sure shallows are read */
210-
is_repository_shallow(the_repository);
211-
commit_graft_prepared = 1;
208+
is_repository_shallow(r);
209+
r->parsed_objects->commit_graft_prepared = 1;
212210
}
213211

214212
struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)

object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct parsed_object_pool {
2020
int is_shallow;
2121
struct stat_validity *shallow_stat;
2222
char *alternate_shallow_file;
23+
24+
int commit_graft_prepared;
2325
};
2426

2527
struct parsed_object_pool *parsed_object_pool_new(void);

0 commit comments

Comments
 (0)