diff options
author | Brandon Williams <bmwill@google.com> | 2018-05-17 15:51:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-18 08:13:10 +0900 |
commit | a3b78e833b06f4bfdef8c4d70d4d269226bebd09 (patch) | |
tree | d9ecbf4ba0988e1e8a60a3eede531ee5af7e8077 /commit.c | |
parent | e808656c46e9d0e2e446b304a6f4d1f7dd0b25b5 (diff) | |
download | git-a3b78e833b06f4bfdef8c4d70d4d269226bebd09.tar.gz |
commit: convert register_commit_graft to handle arbitrary repositories
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -111,30 +111,31 @@ static int commit_graft_pos(struct repository *r, const unsigned char *sha1) commit_graft_sha1_access); } -int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups) +int register_commit_graft(struct repository *r, struct commit_graft *graft, + int ignore_dups) { - int pos = commit_graft_pos(the_repository, graft->oid.hash); + int pos = commit_graft_pos(r, graft->oid.hash); if (0 <= pos) { if (ignore_dups) free(graft); else { - free(the_repository->parsed_objects->grafts[pos]); - the_repository->parsed_objects->grafts[pos] = graft; + free(r->parsed_objects->grafts[pos]); + r->parsed_objects->grafts[pos] = graft; } return 1; } pos = -pos - 1; - ALLOC_GROW(the_repository->parsed_objects->grafts, - the_repository->parsed_objects->grafts_nr + 1, - the_repository->parsed_objects->grafts_alloc); - the_repository->parsed_objects->grafts_nr++; - if (pos < the_repository->parsed_objects->grafts_nr) - memmove(the_repository->parsed_objects->grafts + pos + 1, - the_repository->parsed_objects->grafts + pos, - (the_repository->parsed_objects->grafts_nr - pos - 1) * - sizeof(*the_repository->parsed_objects->grafts)); - the_repository->parsed_objects->grafts[pos] = graft; + ALLOC_GROW(r->parsed_objects->grafts, + r->parsed_objects->grafts_nr + 1, + r->parsed_objects->grafts_alloc); + r->parsed_objects->grafts_nr++; + if (pos < r->parsed_objects->grafts_nr) + memmove(r->parsed_objects->grafts + pos + 1, + r->parsed_objects->grafts + pos, + (r->parsed_objects->grafts_nr - pos - 1) * + sizeof(*r->parsed_objects->grafts)); + r->parsed_objects->grafts[pos] = graft; return 0; } |