From d362093f9e858cf48d3c09bbcacf01f057b58db1 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 8 May 2014 15:41:36 -0700 Subject: [PATCH 1/5] Introduce GIT_MERGE_CONFIG_* for merge.ff settings git_merge_analysis will now return GIT_MERGE_CONFIG_NO_FASTFORWARD when merge.ff=false and GIT_MERGE_CONFIG_FASTFORWARD_ONLY when merge.ff=true --- include/git2/merge.h | 12 ++++++++ src/merge.c | 54 +++++++++++++++++++++++++++------- tests/merge/workdir/analysis.c | 26 ++++++++++++++++ 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/include/git2/merge.h b/include/git2/merge.h index 7915050b0..dc63ed588 100644 --- a/include/git2/merge.h +++ b/include/git2/merge.h @@ -266,6 +266,18 @@ typedef enum { * to simply set HEAD to the target commit(s). */ GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), + + /** + * There is a `merge.ff=false` configuration setting, suggesting that + * the user does not want to allow a fast-forward merge. + */ + GIT_MERGE_CONFIG_NO_FASTFORWARD = (1 << 4), + + /** + * There is a `merge.ff=only` configuration setting, suggesting that + * the user only wants fast-forward merges. + */ + GIT_MERGE_CONFIG_FASTFORWARD_ONLY = (1 << 5), } git_merge_analysis_t; /** diff --git a/src/merge.c b/src/merge.c index 6a8e5874f..85b74483b 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2564,6 +2564,37 @@ done: return error; } +int analysis_config(git_merge_analysis_t *out, git_repository *repo) +{ + git_config *config; + const char *value; + int bool_value, error = 0; + + if ((error = git_repository_config(&config, repo)) < 0) + goto done; + + if ((error = git_config_get_string(&value, config, "merge.ff")) < 0) { + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + goto done; + } + + if (git_config_parse_bool(&bool_value, value) == 0) { + if (!bool_value) + *out |= GIT_MERGE_CONFIG_NO_FASTFORWARD; + } else { + if (strcasecmp(value, "only") == 0) + *out |= GIT_MERGE_CONFIG_FASTFORWARD_ONLY; + } + +done: + git_config_free(config); + return error; +} + int git_merge_analysis( git_merge_analysis_t *out, git_repository *repo, @@ -2575,33 +2606,36 @@ int git_merge_analysis( assert(out && repo && their_heads); - *out = GIT_MERGE_ANALYSIS_NONE; - - if (git_repository_head_unborn(repo)) { - *out = GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; - goto done; - } - if (their_heads_len != 1) { giterr_set(GITERR_MERGE, "Can only merge a single branch"); error = -1; goto done; } + *out = GIT_MERGE_ANALYSIS_NONE; + + if ((error = analysis_config(out, repo)) < 0) + goto done; + + if (git_repository_head_unborn(repo)) { + *out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; + goto done; + } + if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0) goto done; /* We're up-to-date if we're trying to merge our own common ancestor. */ if (ancestor_head && git_oid_equal(&ancestor_head->oid, &their_heads[0]->oid)) - *out = GIT_MERGE_ANALYSIS_UP_TO_DATE; + *out |= GIT_MERGE_ANALYSIS_UP_TO_DATE; /* We're fastforwardable if we're our own common ancestor. */ else if (ancestor_head && git_oid_equal(&ancestor_head->oid, &our_head->oid)) - *out = GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; + *out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; /* Otherwise, just a normal merge is possible. */ else - *out = GIT_MERGE_ANALYSIS_NORMAL; + *out |= GIT_MERGE_ANALYSIS_NORMAL; done: git_merge_head_free(ancestor_head); diff --git a/tests/merge/workdir/analysis.c b/tests/merge/workdir/analysis.c index 0e937857f..daa4e9dd8 100644 --- a/tests/merge/workdir/analysis.c +++ b/tests/merge/workdir/analysis.c @@ -105,3 +105,29 @@ void test_merge_workdir_analysis__unborn(void) git_buf_free(&master); } +void test_merge_workdir_analysis__fastforward_with_config_noff(void) +{ + git_config *config; + git_merge_analysis_t analysis; + + git_repository_config(&config, repo); + git_config_set_string(config, "merge.ff", "false"); + + analysis = analysis_from_branch(FASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (analysis & GIT_MERGE_ANALYSIS_NORMAL)); + cl_assert_equal_i(GIT_MERGE_CONFIG_NO_FASTFORWARD, (analysis & GIT_MERGE_CONFIG_NO_FASTFORWARD)); +} + +void test_merge_workdir_analysis__no_fastforward_with_config_ffonly(void) +{ + git_config *config; + git_merge_analysis_t analysis; + + git_repository_config(&config, repo); + git_config_set_string(config, "merge.ff", "only"); + + analysis = analysis_from_branch(NOFASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (analysis & GIT_MERGE_ANALYSIS_NORMAL)); + cl_assert_equal_i(GIT_MERGE_CONFIG_FASTFORWARD_ONLY, (analysis & GIT_MERGE_CONFIG_FASTFORWARD_ONLY)); +} From a3622ba6cc0970abe485baa98ab53e32df28cfdc Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Fri, 16 May 2014 13:54:40 -0500 Subject: [PATCH 2/5] Move GIT_MERGE_CONFIG_* to its own enum --- include/git2/merge.h | 14 +++++-- src/merge.c | 21 ++++++----- tests/merge/workdir/analysis.c | 69 +++++++++++++++++++--------------- 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/include/git2/merge.h b/include/git2/merge.h index dc63ed588..d0092e45e 100644 --- a/include/git2/merge.h +++ b/include/git2/merge.h @@ -266,19 +266,26 @@ typedef enum { * to simply set HEAD to the target commit(s). */ GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), +} git_merge_analysis_t; + +typedef enum { + /* + * No configuration was found that suggests a behavior for merge. + */ + GIT_MERGE_CONFIG_NONE = 0, /** * There is a `merge.ff=false` configuration setting, suggesting that * the user does not want to allow a fast-forward merge. */ - GIT_MERGE_CONFIG_NO_FASTFORWARD = (1 << 4), + GIT_MERGE_CONFIG_NO_FASTFORWARD = (1 << 0), /** * There is a `merge.ff=only` configuration setting, suggesting that * the user only wants fast-forward merges. */ - GIT_MERGE_CONFIG_FASTFORWARD_ONLY = (1 << 5), -} git_merge_analysis_t; + GIT_MERGE_CONFIG_FASTFORWARD_ONLY = (1 << 1), +} git_merge_config_t; /** * Analyzes the given branch(es) and determines the opportunities for @@ -292,6 +299,7 @@ typedef enum { */ GIT_EXTERN(int) git_merge_analysis( git_merge_analysis_t *analysis_out, + git_merge_config_t *config_out, git_repository *repo, const git_merge_head **their_heads, size_t their_heads_len); diff --git a/src/merge.c b/src/merge.c index 85b74483b..02851e526 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2564,12 +2564,14 @@ done: return error; } -int analysis_config(git_merge_analysis_t *out, git_repository *repo) +int merge_config(git_merge_config_t *out, git_repository *repo) { git_config *config; const char *value; int bool_value, error = 0; + *out = GIT_MERGE_CONFIG_NONE; + if ((error = git_repository_config(&config, repo)) < 0) goto done; @@ -2596,7 +2598,8 @@ done: } int git_merge_analysis( - git_merge_analysis_t *out, + git_merge_analysis_t *analysis_out, + git_merge_config_t *config_out, git_repository *repo, const git_merge_head **their_heads, size_t their_heads_len) @@ -2604,7 +2607,7 @@ int git_merge_analysis( git_merge_head *ancestor_head = NULL, *our_head = NULL; int error = 0; - assert(out && repo && their_heads); + assert(analysis_out && config_out && repo && their_heads); if (their_heads_len != 1) { giterr_set(GITERR_MERGE, "Can only merge a single branch"); @@ -2612,13 +2615,13 @@ int git_merge_analysis( goto done; } - *out = GIT_MERGE_ANALYSIS_NONE; + *analysis_out = GIT_MERGE_ANALYSIS_NONE; - if ((error = analysis_config(out, repo)) < 0) + if ((error = merge_config(config_out, repo)) < 0) goto done; if (git_repository_head_unborn(repo)) { - *out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; + *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; goto done; } @@ -2627,15 +2630,15 @@ int git_merge_analysis( /* We're up-to-date if we're trying to merge our own common ancestor. */ if (ancestor_head && git_oid_equal(&ancestor_head->oid, &their_heads[0]->oid)) - *out |= GIT_MERGE_ANALYSIS_UP_TO_DATE; + *analysis_out |= GIT_MERGE_ANALYSIS_UP_TO_DATE; /* We're fastforwardable if we're our own common ancestor. */ else if (ancestor_head && git_oid_equal(&ancestor_head->oid, &our_head->oid)) - *out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; + *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; /* Otherwise, just a normal merge is possible. */ else - *out |= GIT_MERGE_ANALYSIS_NORMAL; + *analysis_out |= GIT_MERGE_ANALYSIS_NORMAL; done: git_merge_head_free(ancestor_head); diff --git a/tests/merge/workdir/analysis.c b/tests/merge/workdir/analysis.c index daa4e9dd8..d4cf587c4 100644 --- a/tests/merge/workdir/analysis.c +++ b/tests/merge/workdir/analysis.c @@ -36,71 +36,76 @@ void test_merge_workdir_analysis__cleanup(void) cl_git_sandbox_cleanup(); } -static git_merge_analysis_t analysis_from_branch(const char *branchname) +static void analysis_from_branch( + git_merge_analysis_t *merge_analysis, + git_merge_config_t *merge_config, + const char *branchname) { git_buf refname = GIT_BUF_INIT; git_reference *their_ref; git_merge_head *their_head; - git_merge_analysis_t analysis; git_buf_printf(&refname, "%s%s", GIT_REFS_HEADS_DIR, branchname); cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&refname))); cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref)); - cl_git_pass(git_merge_analysis(&analysis, repo, (const git_merge_head **)&their_head, 1)); + cl_git_pass(git_merge_analysis(merge_analysis, merge_config, repo, (const git_merge_head **)&their_head, 1)); git_buf_free(&refname); git_merge_head_free(their_head); git_reference_free(their_ref); - - return analysis; } void test_merge_workdir_analysis__fastforward(void) { - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; - analysis = analysis_from_branch(FASTFORWARD_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (analysis & GIT_MERGE_ANALYSIS_NORMAL)); + analysis_from_branch(&merge_analysis, &merge_config, FASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); } void test_merge_workdir_analysis__no_fastforward(void) { - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; - analysis = analysis_from_branch(NOFASTFORWARD_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, analysis); + analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, merge_analysis); } void test_merge_workdir_analysis__uptodate(void) { - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; - analysis = analysis_from_branch(UPTODATE_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, analysis); + analysis_from_branch(&merge_analysis, &merge_config, UPTODATE_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__uptodate_merging_prev_commit(void) { - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; - analysis = analysis_from_branch(PREVIOUS_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, analysis); + analysis_from_branch(&merge_analysis, &merge_config, PREVIOUS_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__unborn(void) { - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; git_buf master = GIT_BUF_INIT; git_buf_joinpath(&master, git_repository_path(repo), "refs/heads/master"); p_unlink(git_buf_cstr(&master)); - analysis = analysis_from_branch(NOFASTFORWARD_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_UNBORN, (analysis & GIT_MERGE_ANALYSIS_UNBORN)); + analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_UNBORN, (merge_analysis & GIT_MERGE_ANALYSIS_UNBORN)); git_buf_free(&master); } @@ -108,26 +113,28 @@ void test_merge_workdir_analysis__unborn(void) void test_merge_workdir_analysis__fastforward_with_config_noff(void) { git_config *config; - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "false"); - analysis = analysis_from_branch(FASTFORWARD_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (analysis & GIT_MERGE_ANALYSIS_NORMAL)); - cl_assert_equal_i(GIT_MERGE_CONFIG_NO_FASTFORWARD, (analysis & GIT_MERGE_CONFIG_NO_FASTFORWARD)); + analysis_from_branch(&merge_analysis, &merge_config, FASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); + cl_assert_equal_i(GIT_MERGE_CONFIG_NO_FASTFORWARD, (merge_config & GIT_MERGE_CONFIG_NO_FASTFORWARD)); } void test_merge_workdir_analysis__no_fastforward_with_config_ffonly(void) { git_config *config; - git_merge_analysis_t analysis; + git_merge_analysis_t merge_analysis; + git_merge_config_t merge_config; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "only"); - analysis = analysis_from_branch(NOFASTFORWARD_BRANCH); - cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (analysis & GIT_MERGE_ANALYSIS_NORMAL)); - cl_assert_equal_i(GIT_MERGE_CONFIG_FASTFORWARD_ONLY, (analysis & GIT_MERGE_CONFIG_FASTFORWARD_ONLY)); + analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); + cl_assert_equal_i(GIT_MERGE_CONFIG_FASTFORWARD_ONLY, (merge_config & GIT_MERGE_CONFIG_FASTFORWARD_ONLY)); } From 22ab8881787f00eec479e1f148a3846a67c9bcfe Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 20 May 2014 22:07:15 -0700 Subject: [PATCH 3/5] Use a config snapshot --- src/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/merge.c b/src/merge.c index 02851e526..54c7660db 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2572,7 +2572,7 @@ int merge_config(git_merge_config_t *out, git_repository *repo) *out = GIT_MERGE_CONFIG_NONE; - if ((error = git_repository_config(&config, repo)) < 0) + if ((error = git_repository_config_snapshot(&config, repo)) < 0) goto done; if ((error = git_config_get_string(&value, config, "merge.ff")) < 0) { From de3f851ec49deba7b152c01c53aa329439d1f3f5 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 21 May 2014 09:44:05 -0700 Subject: [PATCH 4/5] Staticify `merge_config` --- src/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/merge.c b/src/merge.c index 54c7660db..e2f1e388d 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2564,7 +2564,7 @@ done: return error; } -int merge_config(git_merge_config_t *out, git_repository *repo) +static int merge_config(git_merge_config_t *out, git_repository *repo) { git_config *config; const char *value; From eff531e1034401b144b02ff2913a361669d04129 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 27 May 2014 20:58:20 -0500 Subject: [PATCH 5/5] Modify GIT_MERGE_CONFIG -> GIT_MERGE_PREFERENCE --- include/git2/merge.h | 13 ++++++------ src/merge.c | 14 ++++++------- tests/merge/workdir/analysis.c | 36 +++++++++++++++++----------------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/git2/merge.h b/include/git2/merge.h index d0092e45e..9eb14ccb1 100644 --- a/include/git2/merge.h +++ b/include/git2/merge.h @@ -270,22 +270,23 @@ typedef enum { typedef enum { /* - * No configuration was found that suggests a behavior for merge. + * No configuration was found that suggests a preferred behavior for + * merge. */ - GIT_MERGE_CONFIG_NONE = 0, + GIT_MERGE_PREFERENCE_NONE = 0, /** * There is a `merge.ff=false` configuration setting, suggesting that * the user does not want to allow a fast-forward merge. */ - GIT_MERGE_CONFIG_NO_FASTFORWARD = (1 << 0), + GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0), /** * There is a `merge.ff=only` configuration setting, suggesting that * the user only wants fast-forward merges. */ - GIT_MERGE_CONFIG_FASTFORWARD_ONLY = (1 << 1), -} git_merge_config_t; + GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1), +} git_merge_preference_t; /** * Analyzes the given branch(es) and determines the opportunities for @@ -299,7 +300,7 @@ typedef enum { */ GIT_EXTERN(int) git_merge_analysis( git_merge_analysis_t *analysis_out, - git_merge_config_t *config_out, + git_merge_preference_t *preference_out, git_repository *repo, const git_merge_head **their_heads, size_t their_heads_len); diff --git a/src/merge.c b/src/merge.c index e2f1e388d..a279d31d4 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2564,13 +2564,13 @@ done: return error; } -static int merge_config(git_merge_config_t *out, git_repository *repo) +static int merge_preference(git_merge_preference_t *out, git_repository *repo) { git_config *config; const char *value; int bool_value, error = 0; - *out = GIT_MERGE_CONFIG_NONE; + *out = GIT_MERGE_PREFERENCE_NONE; if ((error = git_repository_config_snapshot(&config, repo)) < 0) goto done; @@ -2586,10 +2586,10 @@ static int merge_config(git_merge_config_t *out, git_repository *repo) if (git_config_parse_bool(&bool_value, value) == 0) { if (!bool_value) - *out |= GIT_MERGE_CONFIG_NO_FASTFORWARD; + *out |= GIT_MERGE_PREFERENCE_NO_FASTFORWARD; } else { if (strcasecmp(value, "only") == 0) - *out |= GIT_MERGE_CONFIG_FASTFORWARD_ONLY; + *out |= GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY; } done: @@ -2599,7 +2599,7 @@ done: int git_merge_analysis( git_merge_analysis_t *analysis_out, - git_merge_config_t *config_out, + git_merge_preference_t *preference_out, git_repository *repo, const git_merge_head **their_heads, size_t their_heads_len) @@ -2607,7 +2607,7 @@ int git_merge_analysis( git_merge_head *ancestor_head = NULL, *our_head = NULL; int error = 0; - assert(analysis_out && config_out && repo && their_heads); + assert(analysis_out && preference_out && repo && their_heads); if (their_heads_len != 1) { giterr_set(GITERR_MERGE, "Can only merge a single branch"); @@ -2617,7 +2617,7 @@ int git_merge_analysis( *analysis_out = GIT_MERGE_ANALYSIS_NONE; - if ((error = merge_config(config_out, repo)) < 0) + if ((error = merge_preference(preference_out, repo)) < 0) goto done; if (git_repository_head_unborn(repo)) { diff --git a/tests/merge/workdir/analysis.c b/tests/merge/workdir/analysis.c index d4cf587c4..85918abe4 100644 --- a/tests/merge/workdir/analysis.c +++ b/tests/merge/workdir/analysis.c @@ -38,7 +38,7 @@ void test_merge_workdir_analysis__cleanup(void) static void analysis_from_branch( git_merge_analysis_t *merge_analysis, - git_merge_config_t *merge_config, + git_merge_preference_t *merge_pref, const char *branchname) { git_buf refname = GIT_BUF_INIT; @@ -50,7 +50,7 @@ static void analysis_from_branch( cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&refname))); cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref)); - cl_git_pass(git_merge_analysis(merge_analysis, merge_config, repo, (const git_merge_head **)&their_head, 1)); + cl_git_pass(git_merge_analysis(merge_analysis, merge_pref, repo, (const git_merge_head **)&their_head, 1)); git_buf_free(&refname); git_merge_head_free(their_head); @@ -60,9 +60,9 @@ static void analysis_from_branch( void test_merge_workdir_analysis__fastforward(void) { git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; - analysis_from_branch(&merge_analysis, &merge_config, FASTFORWARD_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, FASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); } @@ -70,40 +70,40 @@ void test_merge_workdir_analysis__fastforward(void) void test_merge_workdir_analysis__no_fastforward(void) { git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; - analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, merge_analysis); } void test_merge_workdir_analysis__uptodate(void) { git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; - analysis_from_branch(&merge_analysis, &merge_config, UPTODATE_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, UPTODATE_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__uptodate_merging_prev_commit(void) { git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; - analysis_from_branch(&merge_analysis, &merge_config, PREVIOUS_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, PREVIOUS_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__unborn(void) { git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; git_buf master = GIT_BUF_INIT; git_buf_joinpath(&master, git_repository_path(repo), "refs/heads/master"); p_unlink(git_buf_cstr(&master)); - analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UNBORN, (merge_analysis & GIT_MERGE_ANALYSIS_UNBORN)); @@ -114,27 +114,27 @@ void test_merge_workdir_analysis__fastforward_with_config_noff(void) { git_config *config; git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "false"); - analysis_from_branch(&merge_analysis, &merge_config, FASTFORWARD_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, FASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD, (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); - cl_assert_equal_i(GIT_MERGE_CONFIG_NO_FASTFORWARD, (merge_config & GIT_MERGE_CONFIG_NO_FASTFORWARD)); + cl_assert_equal_i(GIT_MERGE_PREFERENCE_NO_FASTFORWARD, (merge_pref & GIT_MERGE_PREFERENCE_NO_FASTFORWARD)); } void test_merge_workdir_analysis__no_fastforward_with_config_ffonly(void) { git_config *config; git_merge_analysis_t merge_analysis; - git_merge_config_t merge_config; + git_merge_preference_t merge_pref; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "only"); - analysis_from_branch(&merge_analysis, &merge_config, NOFASTFORWARD_BRANCH); + analysis_from_branch(&merge_analysis, &merge_pref, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)); - cl_assert_equal_i(GIT_MERGE_CONFIG_FASTFORWARD_ONLY, (merge_config & GIT_MERGE_CONFIG_FASTFORWARD_ONLY)); + cl_assert_equal_i(GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY, (merge_pref & GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY)); }