]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge: make merge.renormalize work for all uses of merge machinery
authorElijah Newren <newren@gmail.com>
Mon, 3 Aug 2020 18:41:19 +0000 (18:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Aug 2020 18:48:15 +0000 (11:48 -0700)
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>
builtin/checkout.c
builtin/merge.c
merge-recursive.c
t/t6038-merge-text-auto.sh

index af849c644fec1852845b1dfdb6ce8daa903e0fb5..18c49034c4eabca81836926c3af927905a719cc1 100644 (file)
@@ -771,13 +771,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
                         */
 
                        add_files_to_cache(NULL, NULL, 0);
-                       /*
-                        * NEEDSWORK: carrying over local changes
-                        * when branches have different end-of-line
-                        * normalization (or clean+smudge rules) is
-                        * a pain; plumb in an option to set
-                        * o.renormalize?
-                        */
                        init_merge_options(&o, the_repository);
                        o.verbosity = 0;
                        work = write_in_core_index_as_tree(the_repository);
index 7da707bf55d94f0a151fb03954b3b107e408e551..74829a838e2104868aef6401ba945e7e84952820 100644 (file)
@@ -72,7 +72,6 @@ static const char **xopts;
 static size_t xopts_nr, xopts_alloc;
 static const char *branch;
 static char *branch_mergeoptions;
-static int option_renormalize;
 static int verbosity;
 static int allow_rerere_auto;
 static int abort_current_merge;
@@ -621,8 +620,6 @@ static int git_merge_config(const char *k, const char *v, void *cb)
                return git_config_string(&pull_octopus, k, v);
        else if (!strcmp(k, "commit.cleanup"))
                return git_config_string(&cleanup_arg, k, v);
-       else if (!strcmp(k, "merge.renormalize"))
-               option_renormalize = git_config_bool(k, v);
        else if (!strcmp(k, "merge.ff")) {
                int boolval = git_parse_maybe_bool(v);
                if (0 <= boolval) {
@@ -721,7 +718,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                if (!strcmp(strategy, "subtree"))
                        o.subtree_shift = "";
 
-               o.renormalize = option_renormalize;
                o.show_rename_progress =
                        show_progress == -1 ? isatty(2) : show_progress;
 
index 36948eafb750284551a3748405135a685ddba2ff..a1c8b36ddb4f64d93c8c3f4a248accf48ecc8506 100644 (file)
@@ -3791,9 +3791,12 @@ int merge_recursive_generic(struct merge_options *opt,
 static void merge_recursive_config(struct merge_options *opt)
 {
        char *value = NULL;
+       int renormalize = 0;
        git_config_get_int("merge.verbosity", &opt->verbosity);
        git_config_get_int("diff.renamelimit", &opt->rename_limit);
        git_config_get_int("merge.renamelimit", &opt->rename_limit);
+       git_config_get_bool("merge.renormalize", &renormalize);
+       opt->renormalize = renormalize;
        if (!git_config_get_string("diff.renames", &value)) {
                opt->detect_renames = git_config_rename("diff.renames", value);
                free(value);
index 9337745793b34c6db221ee78830206cc8f017307..89c86d4e56ca6e5133e50dfbc92f069c55b2fb0e 100755 (executable)
@@ -158,7 +158,7 @@ test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
        compare_files expected file.fuzzy
 '
 
-test_expect_failure 'checkout -m after setting text=auto' '
+test_expect_success 'checkout -m after setting text=auto' '
        cat <<-\EOF >expected &&
        first line
        same line
@@ -173,7 +173,7 @@ test_expect_failure 'checkout -m after setting text=auto' '
        git diff --no-index --ignore-cr-at-eol expected file
 '
 
-test_expect_failure 'checkout -m addition of text=auto' '
+test_expect_success 'checkout -m addition of text=auto' '
        cat <<-\EOF >expected &&
        first line
        same line