Commit 13de93631664cd6eec3afedabb7145d5562a3e01

Jacques Germishuys 2015-03-12T12:36:09

Collapse whitespace flags into git_merge_file_flags_t

diff --git a/include/git2/merge.h b/include/git2/merge.h
index 387197a..e971f2d 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -111,23 +111,6 @@ typedef enum {
 } git_merge_file_favor_t;
 
 /**
- * Whitespace merging flags
- */
-typedef enum {
-	/** Defaults */
-	GIT_MERGE_FILE_IGNORE_DEFAULT = 0,
-
-	/** Ignore all whitespace */
-	GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 0),
-
-	/** Ignore changes in amount of whitespace */
-	GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 1),
-
-	/** Ignore whitespace at end of line */
-	GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 2),
-} git_merge_file_whitespace_t;
-
-/**
  * File merging flags
  */
 typedef enum {
@@ -142,6 +125,15 @@ typedef enum {
 
 	/** Condense non-alphanumeric regions for simplified diff file */
 	GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2),
+
+	/** Ignore all whitespace */
+	GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3),
+
+	/** Ignore changes in amount of whitespace */
+	GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4),
+
+	/** Ignore whitespace at end of line */
+	GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5),
 } git_merge_file_flags_t;
 
 /**
@@ -172,10 +164,7 @@ typedef struct {
 	git_merge_file_favor_t favor;
 
 	/** Merge file flags. */
-	git_merge_file_flags_t flags;
-
-	/** Whitespace merge flags */
-	unsigned int whitespace_flags;
+	unsigned int flags;
 } git_merge_file_options;
 
 #define GIT_MERGE_FILE_OPTIONS_VERSION 1
@@ -251,8 +240,7 @@ typedef struct {
 	/** Flags for handling conflicting content. */
 	git_merge_file_favor_t file_favor;
 
-	/** Flags for handling whitespace */
-	unsigned int whitespace_flags;
+	unsigned int file_flags;
 } git_merge_options;
 
 #define GIT_MERGE_OPTIONS_VERSION 1
diff --git a/src/merge.c b/src/merge.c
index 12e85ff..c0dd2b6 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -654,7 +654,7 @@ static int merge_conflict_resolve_automerge(
 	git_merge_diff_list *diff_list,
 	const git_merge_diff *conflict,
 	unsigned int merge_file_favor,
-	unsigned int whitespace_flags)
+	unsigned int file_flags)
 {
 	const git_index_entry *ancestor = NULL, *ours = NULL, *theirs = NULL;
 	git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT;
@@ -709,7 +709,7 @@ static int merge_conflict_resolve_automerge(
 		&conflict->their_entry : NULL;
 
 	opts.favor = merge_file_favor;
-	opts.whitespace_flags = whitespace_flags;
+	opts.flags = file_flags;
 
 	if ((error = git_repository_odb(&odb, diff_list->repo)) < 0 ||
 		(error = git_merge_file_from_index(&result, diff_list->repo, ancestor, ours, theirs, &opts)) < 0 ||
@@ -744,7 +744,7 @@ static int merge_conflict_resolve(
 	git_merge_diff_list *diff_list,
 	const git_merge_diff *conflict,
 	unsigned int merge_file_favor,
-	unsigned int whitespace_flags)
+	unsigned int file_flags)
 {
 	int resolved = 0;
 	int error = 0;
@@ -761,7 +761,7 @@ static int merge_conflict_resolve(
 		goto done;
 
 	if (!resolved && (error = merge_conflict_resolve_automerge(&resolved, diff_list, conflict,
-		merge_file_favor, whitespace_flags)) < 0)
+		merge_file_favor, file_flags)) < 0)
 		goto done;
 
 	*out = resolved;
@@ -1783,7 +1783,7 @@ int git_merge_trees(
 	git_vector_foreach(&changes, i, conflict) {
 		int resolved = 0;
 
-		if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.file_favor, opts.whitespace_flags)) < 0)
+		if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.file_favor, opts.file_flags)) < 0)
 			goto done;
 
 		if (!resolved)
diff --git a/src/merge_file.c b/src/merge_file.c
index b827ca9..8bb003f 100644
--- a/src/merge_file.c
+++ b/src/merge_file.c
@@ -151,11 +151,11 @@ static int git_merge_file__from_inputs(
 	if (options.flags & GIT_MERGE_FILE_STYLE_DIFF3)
 		xmparam.style = XDL_MERGE_DIFF3;
 
-	if (options.whitespace_flags & GIT_MERGE_FILE_IGNORE_WHITESPACE)
+	if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE)
 		xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE;
-	if (options.whitespace_flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE)
+	if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE)
 		xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_CHANGE;
-	if (options.whitespace_flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL)
+	if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL)
 		xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_AT_EOL;
 
 	if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile,
diff --git a/tests/merge/files.c b/tests/merge/files.c
index cb9e8d1..7f461ab 100644
--- a/tests/merge/files.c
+++ b/tests/merge/files.c
@@ -198,7 +198,7 @@ void test_merge_files__automerge_whitespace_eol(void)
 	theirs.path = "testfile.txt";
 	theirs.mode = 0100755;
 
-	opts.whitespace_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL;
+	opts.flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL;
 	cl_git_pass(git_merge_file(&result, &ancestor, &ours, &theirs, &opts));
 
 	cl_assert_equal_i(1, result.automergeable);
@@ -236,7 +236,7 @@ void test_merge_files__automerge_whitespace_change(void)
 	theirs.path = "testfile.txt";
 	theirs.mode = 0100755;
 
-	opts.whitespace_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE;
+	opts.flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE;
 	cl_git_pass(git_merge_file(&result, &ancestor, &ours, &theirs, &opts));
 
 	cl_assert_equal_i(1, result.automergeable);
diff --git a/tests/merge/trees/whitespace.c b/tests/merge/trees/whitespace.c
index 77e362c..b99583c 100644
--- a/tests/merge/trees/whitespace.c
+++ b/tests/merge/trees/whitespace.c
@@ -54,7 +54,7 @@ void test_merge_trees_whitespace__eol(void)
 		{ 0100644, "ee3c2aac8e03224c323b58ecb1f9eef616745467", 0, "test.txt" },
 	};
 
-	opts.whitespace_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL;
+	opts.file_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL;
 
 	cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_A_EOL, BRANCH_B_EOL, &opts));
 
@@ -72,7 +72,7 @@ void test_merge_trees_whitespace__change(void)
 		{ 0100644, "a827eab4fd66ab37a6ebcfaa7b7e341abfd55947", 0, "test.txt" },
 	};
 
-	opts.whitespace_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE;
+	opts.file_flags |= GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE;
 
 	cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_A_CHANGE, BRANCH_B_CHANGE, &opts));