]> git.proxmox.com Git - libgit2.git/commitdiff
merge: set default rename threshold
authorEdward Thomson <ethomson@github.com>
Sun, 1 Jan 2017 22:19:23 +0000 (22:19 +0000)
committerEdward Thomson <ethomson@github.com>
Sun, 1 Jan 2017 22:34:43 +0000 (22:34 +0000)
When `GIT_MERGE_FIND_RENAMES` is set, provide a default for
`rename_threshold` when it is unset.

include/git2/merge.h
src/merge.c
tests/merge/trees/renames.c

index c6f6cba6c791a5ddc14c0d9dc2f4c775edb72bdd..94ac8b5c5542042200371456a9590ec04ff51f42 100644 (file)
@@ -290,7 +290,8 @@ typedef struct {
 } git_merge_options;
 
 #define GIT_MERGE_OPTIONS_VERSION 1
-#define GIT_MERGE_OPTIONS_INIT {GIT_MERGE_OPTIONS_VERSION}
+#define GIT_MERGE_OPTIONS_INIT { \
+       GIT_MERGE_OPTIONS_VERSION, GIT_MERGE_FIND_RENAMES }
 
 /**
  * Initializes a `git_merge_options` with default values. Equivalent to
index 1142917bd73f59d17663d0a3d26ccb4885a96f77..c75cab6354889555c36923ed3e8abed972f5efac 100644 (file)
@@ -1713,15 +1713,15 @@ static int merge_normalize_opts(
        if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
                return error;
 
-       if (given != NULL)
+       if (given != NULL) {
                memcpy(opts, given, sizeof(git_merge_options));
-       else {
+       else {
                git_merge_options init = GIT_MERGE_OPTIONS_INIT;
                memcpy(opts, &init, sizeof(init));
+       }
 
-               opts->flags = GIT_MERGE_FIND_RENAMES;
+       if ((opts->flags & GIT_MERGE_FIND_RENAMES) && !opts->rename_threshold)
                opts->rename_threshold = GIT_MERGE_DEFAULT_RENAME_THRESHOLD;
-       }
 
        if (given && given->default_driver) {
                opts->default_driver = git__strdup(given->default_driver);
index d7721c894af97ff48a92257cd60e708212d73dda..6f5c36b0a2548f9d807a440fcb054d98ea9b86d8 100644 (file)
@@ -242,6 +242,8 @@ void test_merge_trees_renames__no_rename_index(void)
                { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
        };
 
+       opts.flags &= ~GIT_MERGE_FIND_RENAMES;
+
        cl_git_pass(merge_trees_from_branches(&index, repo,
                BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
                &opts));