Commit 7c7fcdae0e112f56188f13971acae26470287dd3

Jakob Pfender 2011-04-04T16:20:09

index.h: Add IDXENTRY flags needed for index operations Add several IDXENTRY flags that need to be checked in order to properly implement update-index --refresh.

diff --git a/include/git2/index.h b/include/git2/index.h
index 599512f..8a84f50 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -44,6 +44,46 @@ GIT_BEGIN_DECL
 #define GIT_IDXENTRY_VALID     (0x8000)
 #define GIT_IDXENTRY_STAGESHIFT 12
 
+/*
+ * Flags are divided into two parts: in-memory flags and
+ * on-disk ones. Flags in GIT_IDXENTRY_EXTENDED_FLAGS
+ * will get saved on-disk.
+ *
+ * In-memory only flags:
+ */
+#define GIT_IDXENTRY_UPDATE            (1 << 16)
+#define GIT_IDXENTRY_REMOVE            (1 << 17)
+#define GIT_IDXENTRY_UPTODATE          (1 << 18)
+#define GIT_IDXENTRY_ADDED             (1 << 19)
+
+#define GIT_IDXENTRY_HASHED            (1 << 20)
+#define GIT_IDXENTRY_UNHASHED          (1 << 21)
+#define GIT_IDXENTRY_WT_REMOVE         (1 << 22) /* remove in work directory */
+#define GIT_IDXENTRY_CONFLICTED        (1 << 23)
+
+#define GIT_IDXENTRY_UNPACKED          (1 << 24)
+#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 25)
+
+/*
+ * Extended on-disk flags:
+ */
+#define GIT_IDXENTRY_INTENT_TO_ADD     (1 << 29)
+#define GIT_IDXENTRY_SKIP_WORKTREE     (1 << 30)
+/* GIT_IDXENTRY_EXTENDED2 is for future extension */
+#define GIT_IDXENTRY_EXTENDED2         (1 << 31)
+
+#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
+
+/*
+ * Safeguard to avoid saving wrong flags:
+ *  - GIT_IDXENTRY_EXTENDED2 won't get saved until its semantic is known
+ *  - Bits in 0x0000FFFF have been saved in flags already
+ *  - Bits in 0x003F0000 are currently in-memory flags
+ */
+#if GIT_IDXENTRY_EXTENDED_FLAGS & 0x803FFFFF
+#error "GIT_IDXENTRY_EXTENDED_FLAGS out of range"
+#endif
+
 /** Time used in a git index entry */
 typedef struct {
 	git_time_t seconds;