@matheusbsbs / matheus-bagliano / commits / 8d552258f4
Fork 0

merge: make merge.renormalize work for all uses of merge machinery

The 'merge' command is not the only one that does merges; other commands like checkout -m or rebase do as well. Unfortunately, the only area of the code that checked for the "merge.renormalize" config setting was in builtin/merge.c, meaning it could only affect merges performed by the "merge" command. Move the handling of this config setting to merge_recursive_config() so that other commands can benefit from it as well. Fixes a few tests in t6038. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Aug 3, 2020 at 18:41 UTC 8d552258f45ba3886e8d508ece8585b509a04677
4 files changed +5 -13
builtin/checkout.c
-7
@@ -771,13 +771,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
771 */
772
773 add_files_to_cache(NULL, NULL, 0);
774 - /*
775 - * NEEDSWORK: carrying over local changes
776 - * when branches have different end-of-line
777 - * normalization (or clean+smudge rules) is
778 - * a pain; plumb in an option to set
779 - * o.renormalize?
780 - */
774 init_merge_options(&o, the_repository);
775 o.verbosity = 0;
776 work = write_in_core_index_as_tree(the_repository);
builtin/merge.c
-4
@@ -72,7 +72,6 @@ static const char **xopts;
72 static size_t xopts_nr, xopts_alloc;
73 static const char *branch;
74 static char *branch_mergeoptions;
75 -static int option_renormalize;
75 static int verbosity;
76 static int allow_rerere_auto;
77 static int abort_current_merge;
@@ -621,8 +620,6 @@ static int git_merge_config(const char *k, const char *v, void *cb)
620 return git_config_string(&pull_octopus, k, v);
621 else if (!strcmp(k, "commit.cleanup"))
622 return git_config_string(&cleanup_arg, k, v);
624 - else if (!strcmp(k, "merge.renormalize"))
625 - option_renormalize = git_config_bool(k, v);
623 else if (!strcmp(k, "merge.ff")) {
624 int boolval = git_parse_maybe_bool(v);
625 if (0 <= boolval) {
@@ -721,7 +718,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
718 if (!strcmp(strategy, "subtree"))
719 o.subtree_shift = "";
720
724 - o.renormalize = option_renormalize;
721 o.show_rename_progress =
722 show_progress == -1 ? isatty(2) : show_progress;
723
merge-recursive.c
+3
@@ -3791,9 +3791,12 @@ int merge_recursive_generic(struct merge_options *opt,
3791 static void merge_recursive_config(struct merge_options *opt)
3792 {
3793 char *value = NULL;
3794 + int renormalize = 0;
3795 git_config_get_int("merge.verbosity", &opt->verbosity);
3796 git_config_get_int("diff.renamelimit", &opt->rename_limit);
3797 git_config_get_int("merge.renamelimit", &opt->rename_limit);
3798 + git_config_get_bool("merge.renormalize", &renormalize);
3799 + opt->renormalize = renormalize;
3800 if (!git_config_get_string("diff.renames", &value)) {
3801 opt->detect_renames = git_config_rename("diff.renames", value);
3802 free(value);
t/t6038-merge-text-auto.sh
+2 -2
@@ -158,7 +158,7 @@ test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
158 compare_files expected file.fuzzy
159 '
160
161 -test_expect_failure 'checkout -m after setting text=auto' '
161 +test_expect_success 'checkout -m after setting text=auto' '
162 cat <<-\EOF >expected &&
163 first line
164 same line
@@ -173,7 +173,7 @@ test_expect_failure 'checkout -m after setting text=auto' '
173 git diff --no-index --ignore-cr-at-eol expected file
174 '
175
176 -test_expect_failure 'checkout -m addition of text=auto' '
176 +test_expect_success 'checkout -m addition of text=auto' '
177 cat <<-\EOF >expected &&
178 first line
179 same line