diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-17 10:40:13 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-17 10:54:03 +0000 |
commit | cd350852206481e984f7847a903de8d350ad7bf1 (patch) | |
tree | 8d175334bc10172bcd2e28052517771a492ad16d | |
parent | 90046899572f7230ceeab5fef3a909f53f817ba1 (diff) | |
download | libgit2-cd350852206481e984f7847a903de8d350ad7bf1.tar.gz |
object_type: GIT_OBJECT_BAD is now GIT_OBJECT_INVALID
We use the term "invalid" to refer to bad or malformed data, eg
`GIT_REF_INVALID` and `GIT_EINVALIDSPEC`. Since we're changing the
names of the `git_object_t`s in this release, update it to be
`GIT_OBJECT_INVALID` instead of `BAD`.
-rw-r--r-- | include/git2/types.h | 4 | ||||
-rw-r--r-- | src/object.c | 6 | ||||
-rw-r--r-- | src/object.h | 2 | ||||
-rw-r--r-- | src/odb.c | 6 | ||||
-rw-r--r-- | src/odb_loose.c | 6 | ||||
-rw-r--r-- | src/pack.c | 4 | ||||
-rw-r--r-- | src/revparse.c | 4 | ||||
-rw-r--r-- | src/tag.c | 4 | ||||
-rw-r--r-- | tests/object/raw/data.h | 2 | ||||
-rw-r--r-- | tests/object/raw/type2string.c | 12 |
10 files changed, 25 insertions, 25 deletions
diff --git a/include/git2/types.h b/include/git2/types.h index f5517b807..f763d80e3 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -69,7 +69,7 @@ typedef int64_t git_time_t; /** Basic type (loose or packed) of any Git object. */ typedef enum { GIT_OBJECT_ANY = -2, /**< Object can be any of the following */ - GIT_OBJECT_BAD = -1, /**< Object is invalid. */ + GIT_OBJECT_INVALID = -1, /**< Object is invalid. */ GIT_OBJECT_COMMIT = 1, /**< A commit object. */ GIT_OBJECT_TREE = 2, /**< A tree (directory listing) object. */ GIT_OBJECT_BLOB = 3, /**< A file revision object. */ @@ -451,7 +451,7 @@ typedef struct git_mailmap git_mailmap; /**@{*/ GIT_DEPRECATED(static const int) GIT_OBJ_ANY = GIT_OBJECT_ANY; -GIT_DEPRECATED(static const int) GIT_OBJ_BAD = GIT_OBJECT_BAD; +GIT_DEPRECATED(static const int) GIT_OBJ_BAD = GIT_OBJECT_INVALID; GIT_DEPRECATED(static const int) GIT_OBJ__EXT1 = 0; GIT_DEPRECATED(static const int) GIT_OBJ_COMMIT = GIT_OBJECT_COMMIT; GIT_DEPRECATED(static const int) GIT_OBJ_TREE = GIT_OBJECT_TREE; diff --git a/src/object.c b/src/object.c index ef7a4dd29..ce432648a 100644 --- a/src/object.c +++ b/src/object.c @@ -288,7 +288,7 @@ const char *git_object_type2string(git_object_t type) git_object_t git_object_string2type(const char *str) { if (!str) - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; return git_object_stringn2type(str, strlen(str)); } @@ -298,14 +298,14 @@ git_object_t git_object_stringn2type(const char *str, size_t len) size_t i; if (!str || !len || !*str) - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; for (i = 0; i < ARRAY_SIZE(git_objects_table); i++) if (*git_objects_table[i].str && !git__prefixncmp(str, len, git_objects_table[i].str)) return (git_object_t)i; - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; } int git_object_typeisloose(git_object_t type) diff --git a/src/object.h b/src/object.h index 95a7e2c12..227a6fdd5 100644 --- a/src/object.h +++ b/src/object.h @@ -62,7 +62,7 @@ GIT_INLINE(git_object_t) git_object__type_from_filemode(git_filemode_t mode) case GIT_FILEMODE_LINK: return GIT_OBJECT_BLOB; default: - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; } } @@ -63,7 +63,7 @@ static git_object_t odb_hardcoded_type(const git_oid *id) if (!git_oid_cmp(id, &empty_tree)) return GIT_OBJECT_TREE; - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; } static int odb_read_hardcoded(bool *found, git_rawobj *raw, const git_oid *id) @@ -72,7 +72,7 @@ static int odb_read_hardcoded(bool *found, git_rawobj *raw, const git_oid *id) *found = false; - if ((type = odb_hardcoded_type(id)) == GIT_OBJECT_BAD) + if ((type = odb_hardcoded_type(id)) == GIT_OBJECT_INVALID) return 0; raw->type = type; @@ -945,7 +945,7 @@ static int odb_read_header_1( bool passthrough = false; int error; - if (!only_refreshed && (ht = odb_hardcoded_type(id)) != GIT_OBJECT_BAD) { + if (!only_refreshed && (ht = odb_hardcoded_type(id)) != GIT_OBJECT_INVALID) { *type_p = ht; *len_p = 0; return 0; diff --git a/src/odb_loose.c b/src/odb_loose.c index 12607dd38..616b8c880 100644 --- a/src/odb_loose.c +++ b/src/odb_loose.c @@ -351,7 +351,7 @@ static int read_loose(git_rawobj *out, git_buf *loc) out->data = NULL; out->len = 0; - out->type = GIT_OBJECT_BAD; + out->type = GIT_OBJECT_INVALID; if ((error = git_futils_readbuffer(&obj, loc->ptr)) < 0) goto done; @@ -583,7 +583,7 @@ static int loose_backend__read_header(size_t *len_p, git_object_t *type_p, git_o assert(backend && oid); raw.len = 0; - raw.type = GIT_OBJECT_BAD; + raw.type = GIT_OBJECT_INVALID; if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) { error = git_odb__error_notfound("no matching loose object", @@ -989,7 +989,7 @@ static int loose_backend__readstream( backend = (loose_backend *)_backend; *stream_out = NULL; *len_out = 0; - *type_out = GIT_OBJECT_BAD; + *type_out = GIT_OBJECT_INVALID; if (locate_object(&object_path, backend, oid) < 0) { error = git_odb__error_notfound("no matching loose object", diff --git a/src/pack.c b/src/pack.c index 4e963ecc8..86c8c7256 100644 --- a/src/pack.c +++ b/src/pack.c @@ -644,7 +644,7 @@ int git_packfile_unpack( obj->data = NULL; obj->len = 0; - obj->type = GIT_OBJECT_BAD; + obj->type = GIT_OBJECT_INVALID; /* let's point to the right stack */ stack = chain.ptr ? chain.ptr : small_stack; @@ -726,7 +726,7 @@ int git_packfile_unpack( base = *obj; obj->data = NULL; obj->len = 0; - obj->type = GIT_OBJECT_BAD; + obj->type = GIT_OBJECT_INVALID; error = git_delta_apply(&obj->data, &obj->len, base.data, base.len, delta.data, delta.len); obj->type = base_type; diff --git a/src/revparse.c b/src/revparse.c index 5d403b216..78d879bba 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -369,7 +369,7 @@ static git_object_t parse_obj_type(const char *str) if (!strcmp(str, "tag")) return GIT_OBJECT_TAG; - return GIT_OBJECT_BAD; + return GIT_OBJECT_INVALID; } static int dereference_to_non_tag(git_object **out, git_object *obj) @@ -515,7 +515,7 @@ static int handle_caret_curly_syntax(git_object **out, git_object *obj, const ch expected_type = parse_obj_type(curly_braces_content); - if (expected_type == GIT_OBJECT_BAD) + if (expected_type == GIT_OBJECT_INVALID) return GIT_EINVALIDSPEC; return git_object_peel(out, obj, expected_type); @@ -84,7 +84,7 @@ static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end) return tag_error("type field not found"); buffer += 5; - tag->type = GIT_OBJECT_BAD; + tag->type = GIT_OBJECT_INVALID; for (i = 1; i < ARRAY_SIZE(tag_types); ++i) { size_t type_length = strlen(tag_types[i]); @@ -99,7 +99,7 @@ static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end) } } - if (tag->type == GIT_OBJECT_BAD) + if (tag->type == GIT_OBJECT_INVALID) return tag_error("invalid object type"); if (buffer + 4 >= buffer_end) diff --git a/tests/object/raw/data.h b/tests/object/raw/data.h index 07ace60fc..57431e70e 100644 --- a/tests/object/raw/data.h +++ b/tests/object/raw/data.h @@ -319,5 +319,5 @@ static git_rawobj some_obj = { static git_rawobj junk_obj = { NULL, 0, - GIT_OBJECT_BAD + GIT_OBJECT_INVALID }; diff --git a/tests/object/raw/type2string.c b/tests/object/raw/type2string.c index 0c2070500..ebd81f552 100644 --- a/tests/object/raw/type2string.c +++ b/tests/object/raw/type2string.c @@ -6,7 +6,7 @@ void test_object_raw_type2string__convert_type_to_string(void) { - cl_assert_equal_s(git_object_type2string(GIT_OBJECT_BAD), ""); + cl_assert_equal_s(git_object_type2string(GIT_OBJECT_INVALID), ""); cl_assert_equal_s(git_object_type2string(0), ""); /* EXT1 */ cl_assert_equal_s(git_object_type2string(GIT_OBJECT_COMMIT), "commit"); cl_assert_equal_s(git_object_type2string(GIT_OBJECT_TREE), "tree"); @@ -23,8 +23,8 @@ void test_object_raw_type2string__convert_type_to_string(void) void test_object_raw_type2string__convert_string_to_type(void) { - cl_assert(git_object_string2type(NULL) == GIT_OBJECT_BAD); - cl_assert(git_object_string2type("") == GIT_OBJECT_BAD); + cl_assert(git_object_string2type(NULL) == GIT_OBJECT_INVALID); + cl_assert(git_object_string2type("") == GIT_OBJECT_INVALID); cl_assert(git_object_string2type("commit") == GIT_OBJECT_COMMIT); cl_assert(git_object_string2type("tree") == GIT_OBJECT_TREE); cl_assert(git_object_string2type("blob") == GIT_OBJECT_BLOB); @@ -32,13 +32,13 @@ void test_object_raw_type2string__convert_string_to_type(void) cl_assert(git_object_string2type("OFS_DELTA") == GIT_OBJECT_OFS_DELTA); cl_assert(git_object_string2type("REF_DELTA") == GIT_OBJECT_REF_DELTA); - cl_assert(git_object_string2type("CoMmIt") == GIT_OBJECT_BAD); - cl_assert(git_object_string2type("hohoho") == GIT_OBJECT_BAD); + cl_assert(git_object_string2type("CoMmIt") == GIT_OBJECT_INVALID); + cl_assert(git_object_string2type("hohoho") == GIT_OBJECT_INVALID); } void test_object_raw_type2string__check_type_is_loose(void) { - cl_assert(git_object_typeisloose(GIT_OBJECT_BAD) == 0); + cl_assert(git_object_typeisloose(GIT_OBJECT_INVALID) == 0); cl_assert(git_object_typeisloose(0) == 0); /* EXT1 */ cl_assert(git_object_typeisloose(GIT_OBJECT_COMMIT) == 1); cl_assert(git_object_typeisloose(GIT_OBJECT_TREE) == 1); |