commit: convert lookup_commit_graft to struct object_id
With this patch, commit.h doesn't contain the string 'sha1' any more. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jul 12, 2017 at 17:44 UTC
8b65a34c4a12cdaae7f43f65f760da0f48ad67e3
4 files changed
+7
-7
commit.c
+3
-3
@@ -199,11 +199,11 @@ static void prepare_commit_graft(void)
199
commit_graft_prepared = 1;
200
}
201
202
-struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
202
+struct commit_graft *lookup_commit_graft(const struct object_id *oid)
203
{
204
int pos;
205
prepare_commit_graft();
206
- pos = commit_graft_pos(sha1);
206
+ pos = commit_graft_pos(oid->hash);
207
if (pos < 0)
208
return NULL;
209
return commit_graft[pos];
@@ -335,7 +335,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
335
bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
336
pptr = &item->parents;
337
338
- graft = lookup_commit_graft(item->object.oid.hash);
338
+ graft = lookup_commit_graft(&item->object.oid);
339
while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
340
struct commit *new_parent;
341
commit.h
+1
-1
@@ -249,7 +249,7 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);
249
250
struct commit_graft *read_graft_line(char *buf, int len);
251
int register_commit_graft(struct commit_graft *, int);
252
-struct commit_graft *lookup_commit_graft(const unsigned char *sha1);
252
+struct commit_graft *lookup_commit_graft(const struct object_id *oid);
253
254
extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);
255
extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos);
fsck.c
+1
-1
@@ -736,7 +736,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
736
buffer += 41;
737
parent_line_count++;
738
}
739
- graft = lookup_commit_graft(commit->object.oid.hash);
739
+ graft = lookup_commit_graft(&commit->object.oid);
740
parent_count = commit_list_count(commit->parents);
741
if (graft) {
742
if (graft->nr_parent == -1 && !parent_count)
shallow.c
+2
-2
@@ -107,7 +107,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
107
cur_depth++;
108
if ((depth != INFINITE_DEPTH && cur_depth >= depth) ||
109
(is_repository_shallow() && !commit->parents &&
110
- (graft = lookup_commit_graft(commit->object.oid.hash)) != NULL &&
110
+ (graft = lookup_commit_graft(&commit->object.oid)) != NULL &&
111
graft->nr_parent < 0)) {
112
commit_list_insert(commit, &result);
113
commit->object.flags |= shallow_flag;
@@ -398,7 +398,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
398
for (i = 0; i < sa->nr; i++) {
399
if (has_object_file(sa->oid + i)) {
400
struct commit_graft *graft;
401
- graft = lookup_commit_graft(sa->oid[i].hash);
401
+ graft = lookup_commit_graft(&sa->oid[i]);
402
if (graft && graft->nr_parent < 0)
403
continue;
404
info->ours[info->nr_ours++] = i;