Skip to content

Commit 1b2af79

Browse files
committed
deprecation: use the enum type in declaration
The C standard does not specify whether an enum is a signed or unsigned type. Obviously, any enum that includes negative values _must_ be signed, but if all values are positive then the compiler is free to choose signed or unsigned. Thus, by changing the type signatures to `git_object_t` and declaring the old `GIT_OBJ_` values as a signed or unsigned int, we risk a mismatch between what the compiler has chosen for a `git_object_t`'s type and our type declaration. Thus, we declare the deprecated values as the enum instead of guessing.
1 parent 44827b6 commit 1b2af79

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

include/git2/refs.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -762,18 +762,18 @@ GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref);
762762
#define git_ref_t git_reference_t
763763
#define git_reference_normalize_t git_reference_format_t
764764

765-
GIT_DEPRECATED(static const unsigned int) GIT_REF_INVALID = GIT_REFERENCE_INVALID;
766-
GIT_DEPRECATED(static const unsigned int) GIT_REF_OID = GIT_REFERENCE_DIRECT;
767-
GIT_DEPRECATED(static const unsigned int) GIT_REF_SYMBOLIC = GIT_REFERENCE_SYMBOLIC;
768-
GIT_DEPRECATED(static const unsigned int) GIT_REF_LISTALL = GIT_REFERENCE_ALL;
765+
GIT_DEPRECATED(static const git_ref_t) GIT_REF_INVALID = GIT_REFERENCE_INVALID;
766+
GIT_DEPRECATED(static const git_ref_t) GIT_REF_OID = GIT_REFERENCE_DIRECT;
767+
GIT_DEPRECATED(static const git_ref_t) GIT_REF_SYMBOLIC = GIT_REFERENCE_SYMBOLIC;
768+
GIT_DEPRECATED(static const git_ref_t) GIT_REF_LISTALL = GIT_REFERENCE_ALL;
769769

770-
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_NORMAL =
770+
GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_NORMAL =
771771
GIT_REFERENCE_FORMAT_NORMAL;
772-
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_ALLOW_ONELEVEL =
772+
GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_ALLOW_ONELEVEL =
773773
GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL;
774-
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_PATTERN =
774+
GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_REFSPEC_PATTERN =
775775
GIT_REFERENCE_FORMAT_REFSPEC_PATTERN;
776-
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_SHORTHAND =
776+
GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_REFSPEC_SHORTHAND =
777777
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND;
778778

779779
/**@}*/

include/git2/types.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,19 @@ typedef struct git_mailmap git_mailmap;
450450

451451
/**@{*/
452452

453-
GIT_DEPRECATED(static const int) GIT_OBJ_ANY = GIT_OBJECT_ANY;
454-
GIT_DEPRECATED(static const int) GIT_OBJ_BAD = GIT_OBJECT_INVALID;
455-
GIT_DEPRECATED(static const int) GIT_OBJ__EXT1 = 0;
456-
GIT_DEPRECATED(static const int) GIT_OBJ_COMMIT = GIT_OBJECT_COMMIT;
457-
GIT_DEPRECATED(static const int) GIT_OBJ_TREE = GIT_OBJECT_TREE;
458-
GIT_DEPRECATED(static const int) GIT_OBJ_BLOB = GIT_OBJECT_BLOB;
459-
GIT_DEPRECATED(static const int) GIT_OBJ_TAG = GIT_OBJECT_TAG;
460-
GIT_DEPRECATED(static const int) GIT_OBJ__EXT2 = 5;
461-
GIT_DEPRECATED(static const int) GIT_OBJ_OFS_DELTA = GIT_OBJECT_OFS_DELTA;
462-
GIT_DEPRECATED(static const int) GIT_OBJ_REF_DELTA = GIT_OBJECT_REF_DELTA;
463-
464453
#define git_otype git_object_t
465454

455+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_ANY = GIT_OBJECT_ANY;
456+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_BAD = GIT_OBJECT_INVALID;
457+
GIT_DEPRECATED(static const git_otype) GIT_OBJ__EXT1 = 0;
458+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_COMMIT = GIT_OBJECT_COMMIT;
459+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_TREE = GIT_OBJECT_TREE;
460+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_BLOB = GIT_OBJECT_BLOB;
461+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_TAG = GIT_OBJECT_TAG;
462+
GIT_DEPRECATED(static const git_otype) GIT_OBJ__EXT2 = 5;
463+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_OFS_DELTA = GIT_OBJECT_OFS_DELTA;
464+
GIT_DEPRECATED(static const git_otype) GIT_OBJ_REF_DELTA = GIT_OBJECT_REF_DELTA;
465+
466466
/**@}*/
467467

468468
/** @} */

0 commit comments

Comments
 (0)