Commit fed3fef451a45c0b654f996760f403b454f23616

Peter Pettersson 2022-02-07T00:45:44

merge: allocate merge flags for internal use Allocate flags in git_merge_flag_t and git_merge_file_flag_t for internal usage to prevent accidental double allocation.

diff --git a/include/git2/merge.h b/include/git2/merge.h
index edd090c..a308339 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -91,7 +91,10 @@ typedef enum {
 	 * instead simply use the first base.  This flag provides a similar
 	 * merge base to `git-merge-resolve`.
 	 */
-	GIT_MERGE_NO_RECURSIVE = (1 << 3)
+	GIT_MERGE_NO_RECURSIVE = (1 << 3),
+
+	/* This flag is reserved for internal library use */
+	GIT_MERGE__INTERNAL_FLAG = (1 << 30)
 } git_merge_flag_t;
 
 /**
@@ -162,7 +165,10 @@ typedef enum {
 	GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
 
 	/** Create zdiff3 ("zealous diff3")-style files */
-	GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8)
+	GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8),
+
+	/* This flag is reserved for internal library use */
+	GIT_MERGE_FILE__INTERNAL_FLAG = (1 << 30)
 } git_merge_file_flag_t;
 
 #define GIT_MERGE_CONFLICT_MARKER_SIZE	7
diff --git a/src/merge.h b/src/merge.h
index 1b541bf..e033e87 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -27,15 +27,12 @@
 
 
 /** Internal merge flags. */
-enum {
-	/** The merge is for a virtual base in a recursive merge. */
-	GIT_MERGE__VIRTUAL_BASE = (1 << 31)
-};
-
-enum {
-	/** Accept the conflict file, staging it as the merge result. */
-	GIT_MERGE_FILE__CONFLICTED = (1 << 30)
-};
+
+/** The merge is for a virtual base in a recursive merge. */
+#define GIT_MERGE__VIRTUAL_BASE (GIT_MERGE__INTERNAL_FLAG)
+
+/** Accept the conflict file, staging it as the merge result. */
+#define GIT_MERGE_FILE__CONFLICTED (GIT_MERGE_FILE__INTERNAL_FLAG)
 
 
 /** Types of changes when files are merged from branch to branch. */