mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-06 07:00:27 +00:00
merge: set default rename threshold
When `GIT_MERGE_FIND_RENAMES` is set, provide a default for `rename_threshold` when it is unset.
This commit is contained in:
parent
805b90aac4
commit
19ed4d0ca3
@ -290,7 +290,8 @@ typedef struct {
|
|||||||
} git_merge_options;
|
} git_merge_options;
|
||||||
|
|
||||||
#define GIT_MERGE_OPTIONS_VERSION 1
|
#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
|
* Initializes a `git_merge_options` with default values. Equivalent to
|
||||||
|
10
src/merge.c
10
src/merge.c
@ -1713,16 +1713,16 @@ static int merge_normalize_opts(
|
|||||||
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
|
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (given != NULL)
|
if (given != NULL) {
|
||||||
memcpy(opts, given, sizeof(git_merge_options));
|
memcpy(opts, given, sizeof(git_merge_options));
|
||||||
else {
|
} else {
|
||||||
git_merge_options init = GIT_MERGE_OPTIONS_INIT;
|
git_merge_options init = GIT_MERGE_OPTIONS_INIT;
|
||||||
memcpy(opts, &init, sizeof(init));
|
memcpy(opts, &init, sizeof(init));
|
||||||
|
|
||||||
opts->flags = GIT_MERGE_FIND_RENAMES;
|
|
||||||
opts->rename_threshold = GIT_MERGE_DEFAULT_RENAME_THRESHOLD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((opts->flags & GIT_MERGE_FIND_RENAMES) && !opts->rename_threshold)
|
||||||
|
opts->rename_threshold = GIT_MERGE_DEFAULT_RENAME_THRESHOLD;
|
||||||
|
|
||||||
if (given && given->default_driver) {
|
if (given && given->default_driver) {
|
||||||
opts->default_driver = git__strdup(given->default_driver);
|
opts->default_driver = git__strdup(given->default_driver);
|
||||||
GITERR_CHECK_ALLOC(opts->default_driver);
|
GITERR_CHECK_ALLOC(opts->default_driver);
|
||||||
|
@ -242,6 +242,8 @@ void test_merge_trees_renames__no_rename_index(void)
|
|||||||
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
|
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
opts.flags &= ~GIT_MERGE_FIND_RENAMES;
|
||||||
|
|
||||||
cl_git_pass(merge_trees_from_branches(&index, repo,
|
cl_git_pass(merge_trees_from_branches(&index, repo,
|
||||||
BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
|
BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
|
||||||
&opts));
|
&opts));
|
||||||
|
Loading…
Reference in New Issue
Block a user