Skip to content

Commit dbc4ac1

Browse files
committed
oid: GIT_OID_*SZ is now GIT_OID_SHA1_*SIZE
In preparation for SHA256 support, `GIT_OID_RAWSZ` and `GIT_OID_HEXSZ` need to indicate that they're the size of _SHA1_ OIDs.
1 parent f98dd54 commit dbc4ac1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+355
-355
lines changed

examples/cat-file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void show_blob(const git_blob *blob)
4949
static void show_tree(const git_tree *tree)
5050
{
5151
size_t i, max_i = (int)git_tree_entrycount(tree);
52-
char oidstr[GIT_OID_HEXSZ + 1];
52+
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
5353
const git_tree_entry *te;
5454

5555
for (i = 0; i < max_i; ++i) {
@@ -70,7 +70,7 @@ static void show_tree(const git_tree *tree)
7070
static void show_commit(const git_commit *commit)
7171
{
7272
unsigned int i, max_i;
73-
char oidstr[GIT_OID_HEXSZ + 1];
73+
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
7474

7575
git_oid_tostr(oidstr, sizeof(oidstr), git_commit_tree_id(commit));
7676
printf("tree %s\n", oidstr);
@@ -90,7 +90,7 @@ static void show_commit(const git_commit *commit)
9090

9191
static void show_tag(const git_tag *tag)
9292
{
93-
char oidstr[GIT_OID_HEXSZ + 1];
93+
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
9494

9595
git_oid_tostr(oidstr, sizeof(oidstr), git_tag_target_id(tag));;
9696
printf("object %s\n", oidstr);
@@ -125,15 +125,15 @@ int lg2_cat_file(git_repository *repo, int argc, char *argv[])
125125
{
126126
struct catfile_options o = { ".", NULL, 0, 0 };
127127
git_object *obj = NULL;
128-
char oidstr[GIT_OID_HEXSZ + 1];
128+
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
129129

130130
parse_opts(&o, argc, argv);
131131

132132
check_lg2(git_revparse_single(&obj, repo, o.rev),
133133
"Could not resolve", o.rev);
134134

135135
if (o.verbose) {
136-
char oidstr[GIT_OID_HEXSZ + 1];
136+
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
137137
git_oid_tostr(oidstr, sizeof(oidstr), git_object_id(obj));
138138

139139
printf("%s %s\n--\n",

examples/fetch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ static int progress_cb(const char *str, int len, void *data)
1515
*/
1616
static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
1717
{
18-
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
18+
char a_str[GIT_OID_SHA1_HEXSIZE+1], b_str[GIT_OID_SHA1_HEXSIZE+1];
1919
(void)data;
2020

2121
git_oid_fmt(b_str, b);
22-
b_str[GIT_OID_HEXSZ] = '\0';
22+
b_str[GIT_OID_SHA1_HEXSIZE] = '\0';
2323

2424
if (git_oid_is_zero(a)) {
2525
printf("[new] %.20s %s\n", b_str, refname);
2626
} else {
2727
git_oid_fmt(a_str, a);
28-
a_str[GIT_OID_HEXSZ] = '\0';
28+
a_str[GIT_OID_SHA1_HEXSIZE] = '\0';
2929
printf("[updated] %.10s..%.10s %s\n", a_str, b_str, refname);
3030
}
3131

examples/for-each-ref.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static int show_ref(git_reference *ref, void *data)
55
{
66
git_repository *repo = data;
77
git_reference *resolved = NULL;
8-
char hex[GIT_OID_HEXSZ+1];
8+
char hex[GIT_OID_SHA1_HEXSIZE+1];
99
const git_oid *oid;
1010
git_object *obj;
1111

@@ -16,7 +16,7 @@ static int show_ref(git_reference *ref, void *data)
1616

1717
oid = git_reference_target(resolved ? resolved : ref);
1818
git_oid_fmt(hex, oid);
19-
hex[GIT_OID_HEXSZ] = 0;
19+
hex[GIT_OID_SHA1_HEXSIZE] = 0;
2020
check_lg2(git_object_lookup(&obj, repo, oid, GIT_OBJECT_ANY),
2121
"Unable to lookup object", hex);
2222

examples/general.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int lg2_general(git_repository *repo, int argc, char** argv)
129129
*/
130130
static void oid_parsing(git_oid *oid)
131131
{
132-
char out[GIT_OID_HEXSZ+1];
132+
char out[GIT_OID_SHA1_HEXSIZE+1];
133133
char hex[] = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045";
134134

135135
printf("*Hex to Raw*\n");
@@ -152,7 +152,7 @@ static void oid_parsing(git_oid *oid)
152152
* char hex value.
153153
*/
154154
printf("\n*Raw to Hex*\n");
155-
out[GIT_OID_HEXSZ] = '\0';
155+
out[GIT_OID_SHA1_HEXSIZE] = '\0';
156156

157157
/**
158158
* If you have a oid, you can easily get the hex value of the SHA as well.
@@ -173,7 +173,7 @@ static void oid_parsing(git_oid *oid)
173173
*/
174174
static void object_database(git_repository *repo, git_oid *oid)
175175
{
176-
char oid_hex[GIT_OID_HEXSZ+1] = { 0 };
176+
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = { 0 };
177177
const unsigned char *data;
178178
const char *str_type;
179179
int error;
@@ -266,7 +266,7 @@ static void commit_writing(git_repository *repo)
266266
git_tree *tree;
267267
git_commit *parent;
268268
git_signature *author, *committer;
269-
char oid_hex[GIT_OID_HEXSZ+1] = { 0 };
269+
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = { 0 };
270270

271271
printf("\n*Commit Writing*\n");
272272

@@ -345,7 +345,7 @@ static void commit_parsing(git_repository *repo)
345345
const git_signature *author, *cmtter;
346346
git_commit *commit, *parent;
347347
git_oid oid;
348-
char oid_hex[GIT_OID_HEXSZ+1];
348+
char oid_hex[GIT_OID_SHA1_HEXSIZE+1];
349349
const char *message;
350350
unsigned int parents, p;
351351
int error;
@@ -679,7 +679,7 @@ static void reference_listing(git_repository *repo)
679679

680680
for (i = 0; i < ref_list.count; ++i) {
681681
git_reference *ref;
682-
char oid_hex[GIT_OID_HEXSZ+1] = GIT_OID_HEX_ZERO;
682+
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = GIT_OID_HEX_ZERO;
683683
const char *refname;
684684

685685
refname = ref_list.strings[i];

examples/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static void print_time(const git_time *intime, const char *prefix)
329329
/** Helper to print a commit object. */
330330
static void print_commit(git_commit *commit, struct log_options *opts)
331331
{
332-
char buf[GIT_OID_HEXSZ + 1];
332+
char buf[GIT_OID_SHA1_HEXSIZE + 1];
333333
int i, count;
334334
const git_signature *sig;
335335
const char *scan, *eol;

examples/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static int use_remote(git_repository *repo, char *name)
3434
goto cleanup;
3535

3636
for (i = 0; i < refs_len; i++) {
37-
char oid[GIT_OID_HEXSZ + 1] = {0};
37+
char oid[GIT_OID_SHA1_HEXSIZE + 1] = {0};
3838
git_oid_fmt(oid, &refs[i]->oid);
3939
printf("%s\t%s\n", oid, refs[i]->name);
4040
}

examples/rev-list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int lg2_rev_list(git_repository *repo, int argc, char **argv)
2626
git_revwalk *walk;
2727
git_oid oid;
2828
git_sort_t sort;
29-
char buf[GIT_OID_HEXSZ+1];
29+
char buf[GIT_OID_SHA1_HEXSIZE+1];
3030

3131
check_lg2(revwalk_parse_options(&sort, &args), "parsing options", NULL);
3232

@@ -36,7 +36,7 @@ int lg2_rev_list(git_repository *repo, int argc, char **argv)
3636

3737
while (!git_revwalk_next(&oid, walk)) {
3838
git_oid_fmt(buf, &oid);
39-
buf[GIT_OID_HEXSZ] = '\0';
39+
buf[GIT_OID_SHA1_HEXSIZE] = '\0';
4040
printf("%s\n", buf);
4141
}
4242

examples/rev-parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void parse_opts(struct parse_state *ps, int argc, char *argv[])
6565
static int parse_revision(git_repository *repo, struct parse_state *ps)
6666
{
6767
git_revspec rs;
68-
char str[GIT_OID_HEXSZ + 1];
68+
char str[GIT_OID_SHA1_HEXSIZE + 1];
6969

7070
check_lg2(git_revparse(&rs, repo, ps->spec), "Could not parse", ps->spec);
7171

examples/show-index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ int lg2_show_index(git_repository *repo, int argc, char **argv)
2020
size_t i, ecount;
2121
char *dir = ".";
2222
size_t dirlen;
23-
char out[GIT_OID_HEXSZ+1];
24-
out[GIT_OID_HEXSZ] = '\0';
23+
char out[GIT_OID_SHA1_HEXSIZE+1];
24+
out[GIT_OID_SHA1_HEXSIZE] = '\0';
2525

2626
if (argc > 2)
2727
fatal("usage: showindex [<repo-dir>]", NULL);

fuzzers/commit_graph_fuzzer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
6262
memcpy(commit_graph_buf.ptr, data, size);
6363
memcpy(commit_graph_buf.ptr + size, hash, GIT_HASH_SHA1_SIZE);
6464

65-
memcpy(oid.id, hash, GIT_OID_RAWSZ);
65+
memcpy(oid.id, hash, GIT_OID_SHA1_SIZE);
6666
} else {
6767
git_str_attach_notowned(&commit_graph_buf, (char *)data, size);
6868
}
@@ -75,7 +75,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
7575
goto cleanup;
7676

7777
/* Search for any oid, just to exercise that codepath. */
78-
if (git_commit_graph_entry_find(&e, &file, &oid, GIT_OID_HEXSZ) < 0)
78+
if (git_commit_graph_entry_find(&e, &file, &oid, GIT_OID_SHA1_HEXSIZE) < 0)
7979
goto cleanup;
8080

8181
cleanup:

0 commit comments

Comments
 (0)