Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dedfc73

Browse files
committed
index: split GIT_IDXENTRY into two flag enums
The documentation has shown this as a single enum for a long time. These should in fact be two enums. One with the bits for the flags and another with the bits for the extended flags.
1 parent 11e2665 commit dedfc73

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

include/git2/index.h

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ typedef struct git_index_entry {
7373
*/
7474
#define GIT_IDXENTRY_NAMEMASK (0x0fff)
7575
#define GIT_IDXENTRY_STAGEMASK (0x3000)
76-
#define GIT_IDXENTRY_EXTENDED (0x4000)
77-
#define GIT_IDXENTRY_VALID (0x8000)
7876
#define GIT_IDXENTRY_STAGESHIFT 12
7977

78+
typedef enum {
79+
GIT_IDXENTRY_EXTENDED = (0x4000),
80+
GIT_IDXENTRY_VALID = (0x8000),
81+
} git_indxentry_flag_t;
82+
8083
#define GIT_IDXENTRY_STAGE(E) \
8184
(((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
8285

@@ -92,36 +95,36 @@ typedef struct git_index_entry {
9295
* in-memory only and used by libgit2. Only the flags in
9396
* `GIT_IDXENTRY_EXTENDED_FLAGS` will get saved on-disk.
9497
*
95-
* These bitmasks match the three fields in the `git_index_entry`
96-
* `flags_extended` value that belong on disk. You can use them to
97-
* interpret the data in the `flags_extended`.
98+
* Thee first three bitmasks match the three fields in the
99+
* `git_index_entry` `flags_extended` value that belong on disk. You
100+
* can use them to interpret the data in the `flags_extended`.
101+
*
102+
* The rest of the bitmasks match the other fields in the `git_index_entry`
103+
* `flags_extended` value that are only used in-memory by libgit2.
104+
* You can use them to interpret the data in the `flags_extended`.
105+
*
98106
*/
99-
#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
100-
#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
101-
/* GIT_IDXENTRY_EXTENDED2 is reserved for future extension */
102-
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
107+
typedef enum {
103108

104-
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
109+
GIT_IDXENTRY_INTENT_TO_ADD = (1 << 13),
110+
GIT_IDXENTRY_SKIP_WORKTREE = (1 << 14),
111+
/** Reserved for future extension */
112+
GIT_IDXENTRY_EXTENDED2 = (1 << 15),
105113

106-
/**
107-
* Bitmasks for in-memory only fields of `git_index_entry`'s `flags_extended`
108-
*
109-
* These bitmasks match the other fields in the `git_index_entry`
110-
* `flags_extended` value that are only used in-memory by libgit2. You
111-
* can use them to interpret the data in the `flags_extended`.
112-
*/
113-
#define GIT_IDXENTRY_UPDATE (1 << 0)
114-
#define GIT_IDXENTRY_REMOVE (1 << 1)
115-
#define GIT_IDXENTRY_UPTODATE (1 << 2)
116-
#define GIT_IDXENTRY_ADDED (1 << 3)
114+
GIT_IDXENTRY_EXTENDED_FLAGS = (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE),
115+
GIT_IDXENTRY_UPDATE = (1 << 0),
116+
GIT_IDXENTRY_REMOVE = (1 << 1),
117+
GIT_IDXENTRY_UPTODATE = (1 << 2),
118+
GIT_IDXENTRY_ADDED = (1 << 3),
117119

118-
#define GIT_IDXENTRY_HASHED (1 << 4)
119-
#define GIT_IDXENTRY_UNHASHED (1 << 5)
120-
#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
121-
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
120+
GIT_IDXENTRY_HASHED = (1 << 4),
121+
GIT_IDXENTRY_UNHASHED = (1 << 5),
122+
GIT_IDXENTRY_WT_REMOVE = (1 << 6), /**< remove in work directory */
123+
GIT_IDXENTRY_CONFLICTED = (1 << 7),
122124

123-
#define GIT_IDXENTRY_UNPACKED (1 << 8)
124-
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
125+
GIT_IDXENTRY_UNPACKED = (1 << 8),
126+
GIT_IDXENTRY_NEW_SKIP_WORKTREE = (1 << 9),
127+
} git_idxentry_extended_flag_t;
125128

126129
/** Capabilities of system that affect index actions. */
127130
typedef enum {
@@ -412,7 +415,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
412415
*
413416
* This entry is calculated from the entry's flag attribute like this:
414417
*
415-
* (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT
418+
* (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT
416419
*
417420
* @param entry The entry
418421
* @return the stage number

0 commit comments

Comments
 (0)