Skip to content

Commit 87fe578

Browse files
committed
references: use full name in type names
Update the reference type names from an abbreviation (`git_ref`) to use the fullname (`git_reference`). This ensures that we are consistent with our naming for reference types and functions throughout the library. The previous names are now marked as deprecated.
1 parent 628ebc5 commit 87fe578

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

include/git2/refs.h

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
*/
2222
GIT_BEGIN_DECL
2323

24+
/** @name Reference Functions
25+
*
26+
* These functions read, write and analyze references.
27+
*/
28+
/**@{*/
29+
2430
/**
2531
* Lookup a reference by name in a repository.
2632
*
@@ -263,12 +269,12 @@ GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref)
263269
/**
264270
* Get the type of a reference.
265271
*
266-
* Either direct (GIT_REF_OID) or symbolic (GIT_REF_SYMBOLIC)
272+
* Either direct (GIT_REFERENCE_DIRECT) or symbolic (GIT_REFERENCE_SYMBOLIC)
267273
*
268274
* @param ref The reference
269275
* @return the type
270276
*/
271-
GIT_EXTERN(git_ref_t) git_reference_type(const git_reference *ref);
277+
GIT_EXTERN(git_reference_t) git_reference_type(const git_reference *ref);
272278

273279
/**
274280
* Get the full name of a reference.
@@ -640,15 +646,15 @@ typedef enum {
640646
/**
641647
* No particular normalization.
642648
*/
643-
GIT_REF_FORMAT_NORMAL = 0u,
649+
GIT_REFERENCE_FORMAT_NORMAL = 0u,
644650

645651
/**
646652
* Control whether one-level refnames are accepted
647653
* (i.e., refnames that do not contain multiple /-separated
648654
* components). Those are expected to be written only using
649655
* uppercase letters and underscore (FETCH_HEAD, ...)
650656
*/
651-
GIT_REF_FORMAT_ALLOW_ONELEVEL = (1u << 0),
657+
GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL = (1u << 0),
652658

653659
/**
654660
* Interpret the provided name as a reference pattern for a
@@ -657,15 +663,15 @@ typedef enum {
657663
* in place of a one full pathname component
658664
* (e.g., foo/<star>/bar but not foo/bar<star>).
659665
*/
660-
GIT_REF_FORMAT_REFSPEC_PATTERN = (1u << 1),
666+
GIT_REFERENCE_FORMAT_REFSPEC_PATTERN = (1u << 1),
661667

662668
/**
663669
* Interpret the name as part of a refspec in shorthand form
664670
* so the `ONELEVEL` naming rules aren't enforced and 'master'
665671
* becomes a valid name.
666672
*/
667-
GIT_REF_FORMAT_REFSPEC_SHORTHAND = (1u << 2),
668-
} git_reference_normalize_t;
673+
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND = (1u << 2),
674+
} git_reference_format_t;
669675

670676
/**
671677
* Normalize reference name and check validity.
@@ -683,7 +689,7 @@ typedef enum {
683689
* @param buffer_size Size of buffer_out
684690
* @param name Reference name to be checked.
685691
* @param flags Flags to constrain name validation rules - see the
686-
* GIT_REF_FORMAT constants above.
692+
* GIT_REFERENCE_FORMAT constants above.
687693
* @return 0 on success, GIT_EBUFS if buffer is too small, GIT_EINVALIDSPEC
688694
* or an error code.
689695
*/
@@ -743,6 +749,34 @@ GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
743749
*/
744750
GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref);
745751

752+
/**@}*/
753+
754+
/** @name Deprecated Reference Constants
755+
*
756+
* These enumeration values are retained for backward compatibility. The
757+
* newer versions of these functions should be preferred in all new code.
758+
*/
759+
/**@{*/
760+
761+
/** Basic type of any Git reference. */
762+
#define git_ref_t git_reference_t
763+
#define git_reference_normalize_t git_reference_format_t
764+
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;
769+
770+
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_NORMAL =
771+
GIT_REFERENCE_FORMAT_NORMAL;
772+
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_ALLOW_ONELEVEL =
773+
GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL;
774+
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_PATTERN =
775+
GIT_REFERENCE_FORMAT_REFSPEC_PATTERN;
776+
GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_SHORTHAND =
777+
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND;
778+
779+
/**@}*/
746780

747781
/** @} */
748782
GIT_END_DECL

include/git2/types.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ typedef struct git_rebase git_rebase;
193193

194194
/** Basic type of any Git reference. */
195195
typedef enum {
196-
GIT_REF_INVALID = 0, /**< Invalid reference */
197-
GIT_REF_OID = 1, /**< A reference which points at an object id */
198-
GIT_REF_SYMBOLIC = 2, /**< A reference which points at another reference */
199-
GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC,
200-
} git_ref_t;
196+
GIT_REFERENCE_INVALID = 0, /**< Invalid reference */
197+
GIT_REFERENCE_DIRECT = 1, /**< A reference that points at an object id */
198+
GIT_REFERENCE_SYMBOLIC = 2, /**< A reference that points at another reference */
199+
GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC,
200+
} git_reference_t;
201201

202202
/** Basic type of any Git branch. */
203203
typedef enum {

0 commit comments

Comments
 (0)