patch-ids: convert to struct object_id
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
May 30, 2017 at 10:30 UTC
34f3c0ebfbe3c8075587e5b06d0fd280ea57f053
3 files changed
+13
-13
builtin/log.c
+1
-1
@@ -1354,7 +1354,7 @@ static void prepare_bases(struct base_tree_info *bases,
1354
struct object_id *patch_id;
1355
if (commit->util)
1356
continue;
1357
- if (commit_patch_id(commit, &diffopt, oid.hash, 0))
1357
+ if (commit_patch_id(commit, &diffopt, &oid, 0))
1358
die(_("cannot get patch id"));
1359
ALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);
1360
patch_id = bases->patch_id + bases->nr_patch_id;
patch-ids.c
+10
-10
@@ -11,7 +11,7 @@ static int patch_id_defined(struct commit *commit)
11
}
12
13
int commit_patch_id(struct commit *commit, struct diff_options *options,
14
- unsigned char *sha1, int diff_header_only)
14
+ struct object_id *oid, int diff_header_only)
15
{
16
if (!patch_id_defined(commit))
17
return -1;
@@ -22,7 +22,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
22
else
23
diff_root_tree_sha1(commit->object.oid.hash, "", options);
24
diffcore_std(options);
25
- return diff_flush_patch_id(options, sha1, diff_header_only);
25
+ return diff_flush_patch_id(options, oid->hash, diff_header_only);
26
}
27
28
/*
@@ -39,15 +39,15 @@ static int patch_id_cmp(struct patch_id *a,
39
struct patch_id *b,
40
struct diff_options *opt)
41
{
42
- if (is_null_sha1(a->patch_id) &&
43
- commit_patch_id(a->commit, opt, a->patch_id, 0))
42
+ if (is_null_oid(&a->patch_id) &&
43
+ commit_patch_id(a->commit, opt, &a->patch_id, 0))
44
return error("Could not get patch ID for %s",
45
oid_to_hex(&a->commit->object.oid));
46
- if (is_null_sha1(b->patch_id) &&
47
- commit_patch_id(b->commit, opt, b->patch_id, 0))
46
+ if (is_null_oid(&b->patch_id) &&
47
+ commit_patch_id(b->commit, opt, &b->patch_id, 0))
48
return error("Could not get patch ID for %s",
49
oid_to_hex(&b->commit->object.oid));
50
- return hashcmp(a->patch_id, b->patch_id);
50
+ return oidcmp(&a->patch_id, &b->patch_id);
51
}
52
53
int init_patch_ids(struct patch_ids *ids)
@@ -71,13 +71,13 @@ static int init_patch_id_entry(struct patch_id *patch,
71
struct commit *commit,
72
struct patch_ids *ids)
73
{
74
- unsigned char header_only_patch_id[GIT_MAX_RAWSZ];
74
+ struct object_id header_only_patch_id;
75
76
patch->commit = commit;
77
- if (commit_patch_id(commit, &ids->diffopts, header_only_patch_id, 1))
77
+ if (commit_patch_id(commit, &ids->diffopts, &header_only_patch_id, 1))
78
return -1;
79
80
- hashmap_entry_init(patch, sha1hash(header_only_patch_id));
80
+ hashmap_entry_init(patch, sha1hash(header_only_patch_id.hash));
81
return 0;
82
}
83
patch-ids.h
+2
-2
@@ -3,7 +3,7 @@
3
4
struct patch_id {
5
struct hashmap_entry ent;
6
- unsigned char patch_id[GIT_MAX_RAWSZ];
6
+ struct object_id patch_id;
7
struct commit *commit;
8
};
9
@@ -13,7 +13,7 @@ struct patch_ids {
13
};
14
15
int commit_patch_id(struct commit *commit, struct diff_options *options,
16
- unsigned char *sha1, int);
16
+ struct object_id *oid, int);
17
int init_patch_ids(struct patch_ids *);
18
int free_patch_ids(struct patch_ids *);
19
struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *);