Commit 0acaf3a8eb7c3276b7864df8f5588c7007b38f35

Edward Thomson 2022-01-17T13:40:37

oid: define GIT_OID_SHA1_ZERO Callers should not assume the layout of the oid structure; provide them a macro that defines the null / zero sha1 object id.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
diff --git a/examples/general.c b/examples/general.c
index 9e678f8..6b25dd0 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -679,7 +679,7 @@ static void reference_listing(git_repository *repo)
 
 	for (i = 0; i < ref_list.count; ++i) {
 		git_reference *ref;
-		char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = GIT_OID_HEX_ZERO;
+		char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = GIT_OID_SHA1_HEXZERO;
 		const char *refname;
 
 		refname = ref_list.strings[i];
diff --git a/include/git2/common.h b/include/git2/common.h
index c3e3e7b..ccf6633 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -106,11 +106,6 @@ GIT_BEGIN_DECL
 #define GIT_PATH_MAX 4096
 
 /**
- * The string representation of the null object ID.
- */
-#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
-
-/**
  * Return the version of the libgit2 library
  * being currently used.
  *
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 0d0f054..3dedae8 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -36,6 +36,16 @@ typedef struct git_oid {
 } git_oid;
 
 /**
+ * The binary representation of the null object ID.
+ */
+#define GIT_OID_SHA1_ZERO { { 0 } }
+
+/**
+ * The string representation of the null object ID.
+ */
+#define GIT_OID_SHA1_HEXZERO "0000000000000000000000000000000000000000"
+
+/**
  * Parse a hex formatted object id into a git_oid.
  *
  * @param out oid structure the result is written into.
diff --git a/src/libgit2/merge.c b/src/libgit2/merge.c
index 01f60ab..e4db262 100644
--- a/src/libgit2/merge.c
+++ b/src/libgit2/merge.c
@@ -1061,7 +1061,7 @@ static int index_entry_similarity_calc(
 	const git_merge_options *opts)
 {
 	git_blob *blob;
-	git_diff_file diff_file = {{{0}}};
+	git_diff_file diff_file = { GIT_OID_SHA1_ZERO };
 	git_object_size_t blobsize;
 	int error;
 
diff --git a/src/libgit2/object.c b/src/libgit2/object.c
index c280939..d43f3f0 100644
--- a/src/libgit2/object.c
+++ b/src/libgit2/object.c
@@ -230,7 +230,7 @@ int git_object_lookup_prefix(
 			error = git_odb_read(&odb_obj, odb, id);
 		}
 	} else {
-		git_oid short_oid = {{ 0 }};
+		git_oid short_oid = GIT_OID_SHA1_ZERO;
 
 		git_oid__cpy_prefix(&short_oid, id, len);
 
@@ -502,7 +502,7 @@ static int git_object__short_id(git_str *out, const git_object *obj)
 {
 	git_repository *repo;
 	int len = GIT_ABBREV_DEFAULT, error;
-	git_oid id = {{0}};
+	git_oid id = GIT_OID_SHA1_ZERO;
 	git_odb *odb;
 
 	GIT_ASSERT_ARG(out);
diff --git a/src/libgit2/odb.c b/src/libgit2/odb.c
index 43a64fc..fed103e 100644
--- a/src/libgit2/odb.c
+++ b/src/libgit2/odb.c
@@ -914,7 +914,7 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
 {
 	size_t i;
 	int error = GIT_ENOTFOUND, num_found = 0;
-	git_oid last_found = {{0}}, found;
+	git_oid last_found = GIT_OID_SHA1_ZERO, found;
 
 	if ((error = git_mutex_lock(&db->lock)) < 0) {
 		git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
@@ -965,7 +965,7 @@ int git_odb_exists_prefix(
 	git_oid *out, git_odb *db, const git_oid *short_id, size_t len)
 {
 	int error;
-	git_oid key = {{0}};
+	git_oid key = GIT_OID_SHA1_ZERO;
 
 	GIT_ASSERT_ARG(db);
 	GIT_ASSERT_ARG(short_id);
@@ -1305,7 +1305,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
 {
 	size_t i;
 	int error = 0;
-	git_oid found_full_oid = {{0}};
+	git_oid found_full_oid = GIT_OID_SHA1_ZERO;
 	git_rawobj raw = {0};
 	void *data = NULL;
 	bool found = false;
@@ -1391,7 +1391,7 @@ out:
 int git_odb_read_prefix(
 	git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len)
 {
-	git_oid key = {{0}};
+	git_oid key = GIT_OID_SHA1_ZERO;
 	int error;
 
 	GIT_ASSERT_ARG(out);
diff --git a/src/libgit2/odb_pack.c b/src/libgit2/odb_pack.c
index 2401e95..49a655b 100644
--- a/src/libgit2/odb_pack.c
+++ b/src/libgit2/odb_pack.c
@@ -307,7 +307,7 @@ static int pack_entry_find_prefix(
 {
 	int error;
 	size_t i;
-	git_oid found_full_oid = {{0}};
+	git_oid found_full_oid = GIT_OID_SHA1_ZERO;
 	bool found = false;
 	struct git_pack_file *last_found = backend->last_found, *p;
 	git_midx_entry midx_entry;
diff --git a/src/libgit2/refdb_fs.c b/src/libgit2/refdb_fs.c
index d7b0da1..0d0656a 100644
--- a/src/libgit2/refdb_fs.c
+++ b/src/libgit2/refdb_fs.c
@@ -2192,7 +2192,7 @@ success:
 static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *who, const char *message)
 {
 	int error, is_symbolic, open_flags;
-	git_oid old_id = {{0}}, new_id = {{0}};
+	git_oid old_id = GIT_OID_SHA1_ZERO, new_id = GIT_OID_SHA1_ZERO;
 	git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
 	git_repository *repo = backend->repo;
 
diff --git a/src/libgit2/reflog.c b/src/libgit2/reflog.c
index 1e9c0d4..ca6d538 100644
--- a/src/libgit2/reflog.c
+++ b/src/libgit2/reflog.c
@@ -104,7 +104,7 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign
 	previous = git_reflog_entry_byindex(reflog, 0);
 
 	if (previous == NULL)
-		git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO);
+		git_oid_fromstr(&entry->oid_old, GIT_OID_SHA1_HEXZERO);
 	else
 		git_oid_cpy(&entry->oid_old, &previous->oid_cur);
 
@@ -219,7 +219,7 @@ int git_reflog_drop(git_reflog *reflog, size_t idx, int rewrite_previous_entry)
 	/* If the oldest entry has just been removed... */
 	if (idx == entrycount - 1) {
 		/* ...clear the oid_old member of the "new" oldest entry */
-		if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0)
+		if (git_oid_fromstr(&entry->oid_old, GIT_OID_SHA1_HEXZERO) < 0)
 			return -1;
 
 		return 0;
diff --git a/src/libgit2/remote.c b/src/libgit2/remote.c
index 3d05937..6180559 100644
--- a/src/libgit2/remote.c
+++ b/src/libgit2/remote.c
@@ -1622,7 +1622,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
 	const git_refspec *spec;
 	const char *refname;
 	int error;
-	git_oid zero_id = {{ 0 }};
+	git_oid zero_id = GIT_OID_SHA1_ZERO;
 
 	if (callbacks)
 		GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
diff --git a/tests/libgit2/blame/getters.c b/tests/libgit2/blame/getters.c
index 66eaeec..c160cd3 100644
--- a/tests/libgit2/blame/getters.c
+++ b/tests/libgit2/blame/getters.c
@@ -10,11 +10,11 @@ void test_blame_getters__initialize(void)
 	git_blame_options opts = GIT_BLAME_OPTIONS_INIT;
 
 	git_blame_hunk hunks[] = {
-		{ 3, {{0}},  1, NULL, {{0}}, "a", 0},
-		{ 3, {{0}},  4, NULL, {{0}}, "b", 0},
-		{ 3, {{0}},  7, NULL, {{0}}, "c", 0},
-		{ 3, {{0}}, 10, NULL, {{0}}, "d", 0},
-		{ 3, {{0}}, 13, NULL, {{0}}, "e", 0},
+		{ 3, GIT_OID_SHA1_ZERO,  1, NULL, GIT_OID_SHA1_ZERO, "a", 0},
+		{ 3, GIT_OID_SHA1_ZERO,  4, NULL, GIT_OID_SHA1_ZERO, "b", 0},
+		{ 3, GIT_OID_SHA1_ZERO,  7, NULL, GIT_OID_SHA1_ZERO, "c", 0},
+		{ 3, GIT_OID_SHA1_ZERO, 10, NULL, GIT_OID_SHA1_ZERO, "d", 0},
+		{ 3, GIT_OID_SHA1_ZERO, 13, NULL, GIT_OID_SHA1_ZERO, "e", 0},
 	};
 
 	g_blame = git_blame__alloc(NULL, opts, "");
diff --git a/tests/libgit2/core/oidmap.c b/tests/libgit2/core/oidmap.c
index 6854e34..7f549fc 100644
--- a/tests/libgit2/core/oidmap.c
+++ b/tests/libgit2/core/oidmap.c
@@ -93,9 +93,9 @@ void test_core_oidmap__get_fails_with_nonexisting_key(void)
 void test_core_oidmap__setting_oid_persists(void)
 {
 	git_oid oids[] = {
-	    {{ 0x01 }},
-	    {{ 0x02 }},
-	    {{ 0x03 }}
+	    { { 0x01 }},
+	    { { 0x02 }},
+	    { { 0x03 }}
 	};
 
 	cl_git_pass(git_oidmap_set(g_map, &oids[0], "one"));
@@ -110,9 +110,9 @@ void test_core_oidmap__setting_oid_persists(void)
 void test_core_oidmap__setting_existing_key_updates(void)
 {
 	git_oid oids[] = {
-	    {{ 0x01 }},
-	    {{ 0x02 }},
-	    {{ 0x03 }}
+	    { { 0x01 }},
+	    { { 0x02 }},
+	    { { 0x03 }}
 	};
 
 	cl_git_pass(git_oidmap_set(g_map, &oids[0], "one"));
diff --git a/tests/libgit2/iterator/workdir.c b/tests/libgit2/iterator/workdir.c
index 86b847c..112cd9a 100644
--- a/tests/libgit2/iterator/workdir.c
+++ b/tests/libgit2/iterator/workdir.c
@@ -1481,7 +1481,7 @@ void test_iterator_workdir__hash_when_requested(void)
 	git_iterator *iter;
 	const git_index_entry *entry;
 	git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
-	git_oid expected_id = {{0}};
+	git_oid expected_id = GIT_OID_SHA1_ZERO;
 	size_t i;
 
 	struct merge_index_entry expected[] = {
diff --git a/tests/libgit2/object/tree/update.c b/tests/libgit2/object/tree/update.c
index 41b50f3..4e1191d 100644
--- a/tests/libgit2/object/tree/update.c
+++ b/tests/libgit2/object/tree/update.c
@@ -21,7 +21,7 @@ void test_object_tree_update__remove_blob(void)
 	const char *path = "README";
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path},
+		{ GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB /* ignored */, path},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -50,7 +50,7 @@ void test_object_tree_update__remove_blob_deeper(void)
 	const char *path = "subdir/README";
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path},
+		{ GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB /* ignored */, path},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -80,8 +80,8 @@ void test_object_tree_update__remove_all_entries(void)
 	const char *path2 = "subdir/subdir2/new.txt";
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path1},
-		{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path2},
+		{ GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB /* ignored */, path1},
+		{ GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB /* ignored */, path2},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -112,7 +112,7 @@ void test_object_tree_update__replace_blob(void)
 	git_index_entry entry = { {0} };
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, path},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, path},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -153,9 +153,9 @@ void test_object_tree_update__add_blobs(void)
 	};
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[0]},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[1]},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[2]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[0]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[1]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[2]},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -210,9 +210,9 @@ void test_object_tree_update__add_blobs_unsorted(void)
 	};
 
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[0]},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[1]},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[2]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[0]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[1]},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[2]},
 	};
 
 	cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
@@ -258,8 +258,8 @@ void test_object_tree_update__add_conflict(void)
 	int i;
 	git_oid tree_updater_id;
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, "a/dir/blob"},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, "a/dir"},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, "a/dir/blob"},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, "a/dir"},
 	};
 
 	for (i = 0; i < 2; i++) {
@@ -274,8 +274,8 @@ void test_object_tree_update__add_conflict2(void)
 	int i;
 	git_oid tree_updater_id;
 	git_tree_update updates[] = {
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, "a/dir/blob"},
-		{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_TREE, "a/dir/blob"},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, "a/dir/blob"},
+		{ GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_TREE, "a/dir/blob"},
 	};
 
 	for (i = 0; i < 2; i++) {
@@ -290,7 +290,7 @@ void test_object_tree_update__remove_invalid_submodule(void)
 	git_tree *baseline;
 	git_oid updated_tree_id, baseline_id;
 	git_tree_update updates[] = {
-		{GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB, "submodule"},
+		{GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, "submodule"},
 	};
 
 	/* This tree contains a submodule with an all-zero commit for a submodule named 'submodule' */
diff --git a/tests/libgit2/object/tree/write.c b/tests/libgit2/object/tree/write.c
index a4ceb35..5088a96 100644
--- a/tests/libgit2/object/tree/write.c
+++ b/tests/libgit2/object/tree/write.c
@@ -516,7 +516,7 @@ void test_object_tree_write__object_validity(void)
 void test_object_tree_write__invalid_null_oid(void)
 {
 	git_treebuilder *bld;
-	git_oid null_oid = {{0}};
+	git_oid null_oid = GIT_OID_SHA1_ZERO;
 
 	cl_git_pass(git_treebuilder_new(&bld, g_repo, NULL));
 	cl_git_fail(git_treebuilder_insert(NULL, bld, "null_oid_file", &null_oid, GIT_FILEMODE_BLOB));
diff --git a/tests/libgit2/odb/backend/simple.c b/tests/libgit2/odb/backend/simple.c
index 6c9293a..d2051f8 100644
--- a/tests/libgit2/odb/backend/simple.c
+++ b/tests/libgit2/odb/backend/simple.c
@@ -237,7 +237,7 @@ void test_odb_backend_simple__null_oid_is_ignored(void)
 		{ "0000000000000000000000000000000000000000", "null oid content" },
 		{ NULL, NULL }
 	};
-	git_oid null_oid = {{0}};
+	git_oid null_oid = GIT_OID_SHA1_ZERO;
 	git_odb_object *obj;
 
 	setup_backend(objs);
diff --git a/tests/libgit2/odb/mixed.c b/tests/libgit2/odb/mixed.c
index cbab8e3..70eda82 100644
--- a/tests/libgit2/odb/mixed.c
+++ b/tests/libgit2/odb/mixed.c
@@ -186,7 +186,7 @@ static void assert_found_objects(git_odb_expand_id *ids)
 	num = ARRAY_SIZE(expand_id_test_data);
 
 	for (i = 0; i < num; i++) {
-		git_oid expected_id = {{0}};
+		git_oid expected_id = GIT_OID_SHA1_ZERO;
 		size_t expected_len = 0;
 		git_object_t expected_type = 0;
 
@@ -204,7 +204,7 @@ static void assert_found_objects(git_odb_expand_id *ids)
 
 static void assert_notfound_objects(git_odb_expand_id *ids)
 {
-	git_oid expected_id = {{0}};
+	git_oid expected_id = GIT_OID_SHA1_ZERO;
 	size_t num, i;
 
 	num = ARRAY_SIZE(expand_id_test_data);
diff --git a/tests/libgit2/online/clone.c b/tests/libgit2/online/clone.c
index dfaee0e..a9e98df 100644
--- a/tests/libgit2/online/clone.c
+++ b/tests/libgit2/online/clone.c
@@ -629,7 +629,7 @@ void test_online_clone__ssh_cannot_change_username(void)
 static int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
 {
 	git_cert_hostkey *key;
-	git_oid expected = {{0}}, actual = {{0}};
+	git_oid expected = GIT_OID_SHA1_ZERO, actual = GIT_OID_SHA1_ZERO;
 
 	GIT_UNUSED(valid);
 	GIT_UNUSED(payload);
diff --git a/tests/libgit2/online/push_util.c b/tests/libgit2/online/push_util.c
index cd1831d..94919e9 100644
--- a/tests/libgit2/online/push_util.c
+++ b/tests/libgit2/online/push_util.c
@@ -2,8 +2,6 @@
 #include "vector.h"
 #include "push_util.h"
 
-const git_oid OID_ZERO = {{ 0 }};
-
 void updated_tip_free(updated_tip *t)
 {
 	git__free(t->name);
diff --git a/tests/libgit2/refs/branches/delete.c b/tests/libgit2/refs/branches/delete.c
index 27995f9..2c2eae2 100644
--- a/tests/libgit2/refs/branches/delete.c
+++ b/tests/libgit2/refs/branches/delete.c
@@ -119,7 +119,7 @@ void test_refs_branches_delete__removes_reflog(void)
 {
 	git_reference *branch;
 	git_reflog *log;
-	git_oid oidzero = {{0}};
+	git_oid oidzero = GIT_OID_SHA1_ZERO;
 	git_signature *sig;
 
 	/* Ensure the reflog has at least one entry */
@@ -150,7 +150,7 @@ void test_refs_branches_delete__removes_empty_folders(void)
 	git_reference *branch;
 
 	git_reflog *log;
-	git_oid oidzero = {{0}};
+	git_oid oidzero = GIT_OID_SHA1_ZERO;
 	git_signature *sig;
 
 	git_str ref_folder = GIT_STR_INIT;
diff --git a/tests/libgit2/refs/reflog/drop.c b/tests/libgit2/refs/reflog/drop.c
index 916bd99..2d71933 100644
--- a/tests/libgit2/refs/reflog/drop.c
+++ b/tests/libgit2/refs/reflog/drop.c
@@ -70,7 +70,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
 	cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
 
 	entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
-	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) != 0);
+	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_SHA1_HEXZERO) != 0);
 }
 
 void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_history(void)
@@ -83,7 +83,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
 	cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
 
 	entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
-	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
+	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_SHA1_HEXZERO) == 0);
 }
 
 void test_refs_reflog_drop__can_drop_all_the_entries(void)
diff --git a/tests/libgit2/refs/reflog/messages.c b/tests/libgit2/refs/reflog/messages.c
index ed183d2..9bff664 100644
--- a/tests/libgit2/refs/reflog/messages.c
+++ b/tests/libgit2/refs/reflog/messages.c
@@ -264,7 +264,7 @@ void test_refs_reflog_messages__creating_a_direct_reference(void)
 	cl_assert_equal_sz(1, git_reflog_entrycount(reflog));
 
 	entry = git_reflog_entry_byindex(reflog, 0);
-	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
+	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_SHA1_HEXZERO) == 0);
 	cl_assert_equal_oid(&id, &entry->oid_cur);
 	cl_assert_equal_s(message, entry->msg);
 
@@ -352,7 +352,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
 
 	cl_git_pass(git_str_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target))));
 	cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0,
-		GIT_OID_HEX_ZERO,
+		GIT_OID_SHA1_HEXZERO,
 		git_oid_tostr_s(git_commit_id(target)),
 		g_email, git_str_cstr(&buf));
 
@@ -362,7 +362,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
 	cl_git_pass(git_branch_create_from_annotated(&branch2, g_repo, NEW_BRANCH_NAME, annotated, true));
 
 	cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0,
-		GIT_OID_HEX_ZERO,
+		GIT_OID_SHA1_HEXZERO,
 		git_oid_tostr_s(git_commit_id(target)),
 		g_email, "branch: Created from e90810b8df3");
 
diff --git a/tests/libgit2/refs/reflog/reflog.c b/tests/libgit2/refs/reflog/reflog.c
index 32ce7ff..2674f03 100644
--- a/tests/libgit2/refs/reflog/reflog.c
+++ b/tests/libgit2/refs/reflog/reflog.c
@@ -52,7 +52,7 @@ static void assert_appends(const git_signature *committer, const git_oid *oid)
 
 	/* The first one was the creation of the branch */
 	entry = git_reflog_entry_byindex(reflog, 2);
-	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
+	cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_SHA1_HEXZERO) == 0);
 
 	entry = git_reflog_entry_byindex(reflog, 1);
 	assert_signature(committer, entry->committer);
diff --git a/tests/libgit2/status/worktree.c b/tests/libgit2/status/worktree.c
index 00c6ec2..5bd3987 100644
--- a/tests/libgit2/status/worktree.c
+++ b/tests/libgit2/status/worktree.c
@@ -744,7 +744,7 @@ void test_status_worktree__conflict_has_no_oid(void)
 	git_index_entry entry = {{0}};
 	git_status_list *statuslist;
 	const git_status_entry *status;
-	git_oid zero_id = {{0}};
+	git_oid zero_id = GIT_OID_SHA1_ZERO;
 
 	entry.mode = 0100644;
 	entry.path = "modified_file";