Commit 0acaf3a8 by Edward Thomson

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.
parent dbc4ac1c
...@@ -679,7 +679,7 @@ static void reference_listing(git_repository *repo) ...@@ -679,7 +679,7 @@ static void reference_listing(git_repository *repo)
for (i = 0; i < ref_list.count; ++i) { for (i = 0; i < ref_list.count; ++i) {
git_reference *ref; 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; const char *refname;
refname = ref_list.strings[i]; refname = ref_list.strings[i];
......
...@@ -106,11 +106,6 @@ GIT_BEGIN_DECL ...@@ -106,11 +106,6 @@ GIT_BEGIN_DECL
#define GIT_PATH_MAX 4096 #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 * Return the version of the libgit2 library
* being currently used. * being currently used.
* *
......
...@@ -36,6 +36,16 @@ typedef struct git_oid { ...@@ -36,6 +36,16 @@ typedef struct git_oid {
} 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. * Parse a hex formatted object id into a git_oid.
* *
* @param out oid structure the result is written into. * @param out oid structure the result is written into.
......
...@@ -1061,7 +1061,7 @@ static int index_entry_similarity_calc( ...@@ -1061,7 +1061,7 @@ static int index_entry_similarity_calc(
const git_merge_options *opts) const git_merge_options *opts)
{ {
git_blob *blob; git_blob *blob;
git_diff_file diff_file = {{{0}}}; git_diff_file diff_file = { GIT_OID_SHA1_ZERO };
git_object_size_t blobsize; git_object_size_t blobsize;
int error; int error;
......
...@@ -230,7 +230,7 @@ int git_object_lookup_prefix( ...@@ -230,7 +230,7 @@ int git_object_lookup_prefix(
error = git_odb_read(&odb_obj, odb, id); error = git_odb_read(&odb_obj, odb, id);
} }
} else { } else {
git_oid short_oid = {{ 0 }}; git_oid short_oid = GIT_OID_SHA1_ZERO;
git_oid__cpy_prefix(&short_oid, id, len); 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) ...@@ -502,7 +502,7 @@ static int git_object__short_id(git_str *out, const git_object *obj)
{ {
git_repository *repo; git_repository *repo;
int len = GIT_ABBREV_DEFAULT, error; int len = GIT_ABBREV_DEFAULT, error;
git_oid id = {{0}}; git_oid id = GIT_OID_SHA1_ZERO;
git_odb *odb; git_odb *odb;
GIT_ASSERT_ARG(out); GIT_ASSERT_ARG(out);
......
...@@ -914,7 +914,7 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db, ...@@ -914,7 +914,7 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
{ {
size_t i; size_t i;
int error = GIT_ENOTFOUND, num_found = 0; 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) { if ((error = git_mutex_lock(&db->lock)) < 0) {
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock"); git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
...@@ -965,7 +965,7 @@ int git_odb_exists_prefix( ...@@ -965,7 +965,7 @@ int git_odb_exists_prefix(
git_oid *out, git_odb *db, const git_oid *short_id, size_t len) git_oid *out, git_odb *db, const git_oid *short_id, size_t len)
{ {
int error; int error;
git_oid key = {{0}}; git_oid key = GIT_OID_SHA1_ZERO;
GIT_ASSERT_ARG(db); GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(short_id); GIT_ASSERT_ARG(short_id);
...@@ -1305,7 +1305,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db, ...@@ -1305,7 +1305,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
{ {
size_t i; size_t i;
int error = 0; int error = 0;
git_oid found_full_oid = {{0}}; git_oid found_full_oid = GIT_OID_SHA1_ZERO;
git_rawobj raw = {0}; git_rawobj raw = {0};
void *data = NULL; void *data = NULL;
bool found = false; bool found = false;
...@@ -1391,7 +1391,7 @@ out: ...@@ -1391,7 +1391,7 @@ out:
int git_odb_read_prefix( int git_odb_read_prefix(
git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len) 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; int error;
GIT_ASSERT_ARG(out); GIT_ASSERT_ARG(out);
......
...@@ -307,7 +307,7 @@ static int pack_entry_find_prefix( ...@@ -307,7 +307,7 @@ static int pack_entry_find_prefix(
{ {
int error; int error;
size_t i; size_t i;
git_oid found_full_oid = {{0}}; git_oid found_full_oid = GIT_OID_SHA1_ZERO;
bool found = false; bool found = false;
struct git_pack_file *last_found = backend->last_found, *p; struct git_pack_file *last_found = backend->last_found, *p;
git_midx_entry midx_entry; git_midx_entry midx_entry;
......
...@@ -2192,7 +2192,7 @@ success: ...@@ -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) 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; 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_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
git_repository *repo = backend->repo; git_repository *repo = backend->repo;
......
...@@ -104,7 +104,7 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign ...@@ -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); previous = git_reflog_entry_byindex(reflog, 0);
if (previous == NULL) if (previous == NULL)
git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO); git_oid_fromstr(&entry->oid_old, GIT_OID_SHA1_HEXZERO);
else else
git_oid_cpy(&entry->oid_old, &previous->oid_cur); 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) ...@@ -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 the oldest entry has just been removed... */
if (idx == entrycount - 1) { if (idx == entrycount - 1) {
/* ...clear the oid_old member of the "new" oldest entry */ /* ...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 -1;
return 0; return 0;
......
...@@ -1622,7 +1622,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks) ...@@ -1622,7 +1622,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
const git_refspec *spec; const git_refspec *spec;
const char *refname; const char *refname;
int error; int error;
git_oid zero_id = {{ 0 }}; git_oid zero_id = GIT_OID_SHA1_ZERO;
if (callbacks) if (callbacks)
GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
......
...@@ -10,11 +10,11 @@ void test_blame_getters__initialize(void) ...@@ -10,11 +10,11 @@ void test_blame_getters__initialize(void)
git_blame_options opts = GIT_BLAME_OPTIONS_INIT; git_blame_options opts = GIT_BLAME_OPTIONS_INIT;
git_blame_hunk hunks[] = { git_blame_hunk hunks[] = {
{ 3, {{0}}, 1, NULL, {{0}}, "a", 0}, { 3, GIT_OID_SHA1_ZERO, 1, NULL, GIT_OID_SHA1_ZERO, "a", 0},
{ 3, {{0}}, 4, NULL, {{0}}, "b", 0}, { 3, GIT_OID_SHA1_ZERO, 4, NULL, GIT_OID_SHA1_ZERO, "b", 0},
{ 3, {{0}}, 7, NULL, {{0}}, "c", 0}, { 3, GIT_OID_SHA1_ZERO, 7, NULL, GIT_OID_SHA1_ZERO, "c", 0},
{ 3, {{0}}, 10, NULL, {{0}}, "d", 0}, { 3, GIT_OID_SHA1_ZERO, 10, NULL, GIT_OID_SHA1_ZERO, "d", 0},
{ 3, {{0}}, 13, NULL, {{0}}, "e", 0}, { 3, GIT_OID_SHA1_ZERO, 13, NULL, GIT_OID_SHA1_ZERO, "e", 0},
}; };
g_blame = git_blame__alloc(NULL, opts, ""); g_blame = git_blame__alloc(NULL, opts, "");
......
...@@ -93,9 +93,9 @@ void test_core_oidmap__get_fails_with_nonexisting_key(void) ...@@ -93,9 +93,9 @@ void test_core_oidmap__get_fails_with_nonexisting_key(void)
void test_core_oidmap__setting_oid_persists(void) void test_core_oidmap__setting_oid_persists(void)
{ {
git_oid oids[] = { git_oid oids[] = {
{{ 0x01 }}, { { 0x01 }},
{{ 0x02 }}, { { 0x02 }},
{{ 0x03 }} { { 0x03 }}
}; };
cl_git_pass(git_oidmap_set(g_map, &oids[0], "one")); cl_git_pass(git_oidmap_set(g_map, &oids[0], "one"));
...@@ -110,9 +110,9 @@ void test_core_oidmap__setting_oid_persists(void) ...@@ -110,9 +110,9 @@ void test_core_oidmap__setting_oid_persists(void)
void test_core_oidmap__setting_existing_key_updates(void) void test_core_oidmap__setting_existing_key_updates(void)
{ {
git_oid oids[] = { git_oid oids[] = {
{{ 0x01 }}, { { 0x01 }},
{{ 0x02 }}, { { 0x02 }},
{{ 0x03 }} { { 0x03 }}
}; };
cl_git_pass(git_oidmap_set(g_map, &oids[0], "one")); cl_git_pass(git_oidmap_set(g_map, &oids[0], "one"));
......
...@@ -1481,7 +1481,7 @@ void test_iterator_workdir__hash_when_requested(void) ...@@ -1481,7 +1481,7 @@ void test_iterator_workdir__hash_when_requested(void)
git_iterator *iter; git_iterator *iter;
const git_index_entry *entry; const git_index_entry *entry;
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; 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; size_t i;
struct merge_index_entry expected[] = { struct merge_index_entry expected[] = {
......
...@@ -21,7 +21,7 @@ void test_object_tree_update__remove_blob(void) ...@@ -21,7 +21,7 @@ void test_object_tree_update__remove_blob(void)
const char *path = "README"; const char *path = "README";
git_tree_update updates[] = { 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")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -50,7 +50,7 @@ void test_object_tree_update__remove_blob_deeper(void) ...@@ -50,7 +50,7 @@ void test_object_tree_update__remove_blob_deeper(void)
const char *path = "subdir/README"; const char *path = "subdir/README";
git_tree_update updates[] = { 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")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -80,8 +80,8 @@ void test_object_tree_update__remove_all_entries(void) ...@@ -80,8 +80,8 @@ void test_object_tree_update__remove_all_entries(void)
const char *path2 = "subdir/subdir2/new.txt"; const char *path2 = "subdir/subdir2/new.txt";
git_tree_update updates[] = { git_tree_update updates[] = {
{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path1}, { GIT_TREE_UPDATE_REMOVE, GIT_OID_SHA1_ZERO, 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 */, path2},
}; };
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -112,7 +112,7 @@ void test_object_tree_update__replace_blob(void) ...@@ -112,7 +112,7 @@ void test_object_tree_update__replace_blob(void)
git_index_entry entry = { {0} }; git_index_entry entry = { {0} };
git_tree_update updates[] = { 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")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -153,9 +153,9 @@ void test_object_tree_update__add_blobs(void) ...@@ -153,9 +153,9 @@ void test_object_tree_update__add_blobs(void)
}; };
git_tree_update updates[] = { git_tree_update updates[] = {
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[0]}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[0]},
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[1]}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, 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[2]},
}; };
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -210,9 +210,9 @@ void test_object_tree_update__add_blobs_unsorted(void) ...@@ -210,9 +210,9 @@ void test_object_tree_update__add_blobs_unsorted(void)
}; };
git_tree_update updates[] = { git_tree_update updates[] = {
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[0]}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, GIT_FILEMODE_BLOB, paths[0]},
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[1]}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, 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[2]},
}; };
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")); cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
...@@ -258,8 +258,8 @@ void test_object_tree_update__add_conflict(void) ...@@ -258,8 +258,8 @@ void test_object_tree_update__add_conflict(void)
int i; int i;
git_oid tree_updater_id; git_oid tree_updater_id;
git_tree_update updates[] = { git_tree_update updates[] = {
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, "a/dir/blob"}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, 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"},
}; };
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -274,8 +274,8 @@ void test_object_tree_update__add_conflict2(void) ...@@ -274,8 +274,8 @@ void test_object_tree_update__add_conflict2(void)
int i; int i;
git_oid tree_updater_id; git_oid tree_updater_id;
git_tree_update updates[] = { git_tree_update updates[] = {
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, "a/dir/blob"}, { GIT_TREE_UPDATE_UPSERT, GIT_OID_SHA1_ZERO, 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_TREE, "a/dir/blob"},
}; };
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -290,7 +290,7 @@ void test_object_tree_update__remove_invalid_submodule(void) ...@@ -290,7 +290,7 @@ void test_object_tree_update__remove_invalid_submodule(void)
git_tree *baseline; git_tree *baseline;
git_oid updated_tree_id, baseline_id; git_oid updated_tree_id, baseline_id;
git_tree_update updates[] = { 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' */ /* This tree contains a submodule with an all-zero commit for a submodule named 'submodule' */
......
...@@ -516,7 +516,7 @@ void test_object_tree_write__object_validity(void) ...@@ -516,7 +516,7 @@ void test_object_tree_write__object_validity(void)
void test_object_tree_write__invalid_null_oid(void) void test_object_tree_write__invalid_null_oid(void)
{ {
git_treebuilder *bld; 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_pass(git_treebuilder_new(&bld, g_repo, NULL));
cl_git_fail(git_treebuilder_insert(NULL, bld, "null_oid_file", &null_oid, GIT_FILEMODE_BLOB)); cl_git_fail(git_treebuilder_insert(NULL, bld, "null_oid_file", &null_oid, GIT_FILEMODE_BLOB));
......
...@@ -237,7 +237,7 @@ void test_odb_backend_simple__null_oid_is_ignored(void) ...@@ -237,7 +237,7 @@ void test_odb_backend_simple__null_oid_is_ignored(void)
{ "0000000000000000000000000000000000000000", "null oid content" }, { "0000000000000000000000000000000000000000", "null oid content" },
{ NULL, NULL } { NULL, NULL }
}; };
git_oid null_oid = {{0}}; git_oid null_oid = GIT_OID_SHA1_ZERO;
git_odb_object *obj; git_odb_object *obj;
setup_backend(objs); setup_backend(objs);
......
...@@ -186,7 +186,7 @@ static void assert_found_objects(git_odb_expand_id *ids) ...@@ -186,7 +186,7 @@ static void assert_found_objects(git_odb_expand_id *ids)
num = ARRAY_SIZE(expand_id_test_data); num = ARRAY_SIZE(expand_id_test_data);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
git_oid expected_id = {{0}}; git_oid expected_id = GIT_OID_SHA1_ZERO;
size_t expected_len = 0; size_t expected_len = 0;
git_object_t expected_type = 0; git_object_t expected_type = 0;
...@@ -204,7 +204,7 @@ static void assert_found_objects(git_odb_expand_id *ids) ...@@ -204,7 +204,7 @@ static void assert_found_objects(git_odb_expand_id *ids)
static void assert_notfound_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; size_t num, i;
num = ARRAY_SIZE(expand_id_test_data); num = ARRAY_SIZE(expand_id_test_data);
......
...@@ -629,7 +629,7 @@ void test_online_clone__ssh_cannot_change_username(void) ...@@ -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) static int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
{ {
git_cert_hostkey *key; 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(valid);
GIT_UNUSED(payload); GIT_UNUSED(payload);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#include "vector.h" #include "vector.h"
#include "push_util.h" #include "push_util.h"
const git_oid OID_ZERO = {{ 0 }};
void updated_tip_free(updated_tip *t) void updated_tip_free(updated_tip *t)
{ {
git__free(t->name); git__free(t->name);
......
...@@ -119,7 +119,7 @@ void test_refs_branches_delete__removes_reflog(void) ...@@ -119,7 +119,7 @@ void test_refs_branches_delete__removes_reflog(void)
{ {
git_reference *branch; git_reference *branch;
git_reflog *log; git_reflog *log;
git_oid oidzero = {{0}}; git_oid oidzero = GIT_OID_SHA1_ZERO;
git_signature *sig; git_signature *sig;
/* Ensure the reflog has at least one entry */ /* Ensure the reflog has at least one entry */
...@@ -150,7 +150,7 @@ void test_refs_branches_delete__removes_empty_folders(void) ...@@ -150,7 +150,7 @@ void test_refs_branches_delete__removes_empty_folders(void)
git_reference *branch; git_reference *branch;
git_reflog *log; git_reflog *log;
git_oid oidzero = {{0}}; git_oid oidzero = GIT_OID_SHA1_ZERO;
git_signature *sig; git_signature *sig;
git_str ref_folder = GIT_STR_INIT; git_str ref_folder = GIT_STR_INIT;
......
...@@ -70,7 +70,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void) ...@@ -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)); cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2); 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) 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 ...@@ -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)); cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2); 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) void test_refs_reflog_drop__can_drop_all_the_entries(void)
......
...@@ -264,7 +264,7 @@ void test_refs_reflog_messages__creating_a_direct_reference(void) ...@@ -264,7 +264,7 @@ void test_refs_reflog_messages__creating_a_direct_reference(void)
cl_assert_equal_sz(1, git_reflog_entrycount(reflog)); cl_assert_equal_sz(1, git_reflog_entrycount(reflog));
entry = git_reflog_entry_byindex(reflog, 0); 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_oid(&id, &entry->oid_cur);
cl_assert_equal_s(message, entry->msg); cl_assert_equal_s(message, entry->msg);
...@@ -352,7 +352,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void) ...@@ -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_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, 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)), git_oid_tostr_s(git_commit_id(target)),
g_email, git_str_cstr(&buf)); g_email, git_str_cstr(&buf));
...@@ -362,7 +362,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void) ...@@ -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_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, 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)), git_oid_tostr_s(git_commit_id(target)),
g_email, "branch: Created from e90810b8df3"); g_email, "branch: Created from e90810b8df3");
......
...@@ -52,7 +52,7 @@ static void assert_appends(const git_signature *committer, const git_oid *oid) ...@@ -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 */ /* The first one was the creation of the branch */
entry = git_reflog_entry_byindex(reflog, 2); 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); entry = git_reflog_entry_byindex(reflog, 1);
assert_signature(committer, entry->committer); assert_signature(committer, entry->committer);
......
...@@ -744,7 +744,7 @@ void test_status_worktree__conflict_has_no_oid(void) ...@@ -744,7 +744,7 @@ void test_status_worktree__conflict_has_no_oid(void)
git_index_entry entry = {{0}}; git_index_entry entry = {{0}};
git_status_list *statuslist; git_status_list *statuslist;
const git_status_entry *status; const git_status_entry *status;
git_oid zero_id = {{0}}; git_oid zero_id = GIT_OID_SHA1_ZERO;
entry.mode = 0100644; entry.mode = 0100644;
entry.path = "modified_file"; entry.path = "modified_file";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment