Skip to content

Commit 4339259

Browse files
committed
Merge branch 'en/eol-attrs-gotchas'
All "mergy" operations that internally use the merge-recursive machinery should honor the merge.renormalize configuration, but many of them didn't. * en/eol-attrs-gotchas: checkout: support renormalization with checkout -m <paths> merge: make merge.renormalize work for all uses of merge machinery t6038: remove problematic test t6038: make tests fail for the right reason
2 parents 1aa3dff + 00906d6 commit 4339259

File tree

4 files changed

+15
-36
lines changed

4 files changed

+15
-36
lines changed

builtin/checkout.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ static int checkout_merged(int pos, const struct checkout *state, int *nr_checko
239239
mmbuffer_t result_buf;
240240
struct object_id threeway[3];
241241
unsigned mode = 0;
242+
struct ll_merge_options ll_opts;
243+
int renormalize = 0;
242244

243245
memset(threeway, 0, sizeof(threeway));
244246
while (pos < active_nr) {
@@ -259,13 +261,12 @@ static int checkout_merged(int pos, const struct checkout *state, int *nr_checko
259261
read_mmblob(&ours, &threeway[1]);
260262
read_mmblob(&theirs, &threeway[2]);
261263

262-
/*
263-
* NEEDSWORK: re-create conflicts from merges with
264-
* merge.renormalize set, too
265-
*/
264+
memset(&ll_opts, 0, sizeof(ll_opts));
265+
git_config_get_bool("merge.renormalize", &renormalize);
266+
ll_opts.renormalize = renormalize;
266267
status = ll_merge(&result_buf, path, &ancestor, "base",
267268
&ours, "ours", &theirs, "theirs",
268-
state->istate, NULL);
269+
state->istate, &ll_opts);
269270
free(ancestor.ptr);
270271
free(ours.ptr);
271272
free(theirs.ptr);
@@ -771,13 +772,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
771772
*/
772773

773774
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-
*/
781775
init_merge_options(&o, the_repository);
782776
o.verbosity = 0;
783777
work = write_in_core_index_as_tree(the_repository);

builtin/merge.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ static const char **xopts;
7272
static size_t xopts_nr, xopts_alloc;
7373
static const char *branch;
7474
static char *branch_mergeoptions;
75-
static int option_renormalize;
7675
static int verbosity;
7776
static int allow_rerere_auto;
7877
static int abort_current_merge;
@@ -621,8 +620,6 @@ static int git_merge_config(const char *k, const char *v, void *cb)
621620
return git_config_string(&pull_octopus, k, v);
622621
else if (!strcmp(k, "commit.cleanup"))
623622
return git_config_string(&cleanup_arg, k, v);
624-
else if (!strcmp(k, "merge.renormalize"))
625-
option_renormalize = git_config_bool(k, v);
626623
else if (!strcmp(k, "merge.ff")) {
627624
int boolval = git_parse_maybe_bool(v);
628625
if (0 <= boolval) {
@@ -721,7 +718,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
721718
if (!strcmp(strategy, "subtree"))
722719
o.subtree_shift = "";
723720

724-
o.renormalize = option_renormalize;
725721
o.show_rename_progress =
726722
show_progress == -1 ? isatty(2) : show_progress;
727723

merge-recursive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,9 +3792,12 @@ int merge_recursive_generic(struct merge_options *opt,
37923792
static void merge_recursive_config(struct merge_options *opt)
37933793
{
37943794
char *value = NULL;
3795+
int renormalize = 0;
37953796
git_config_get_int("merge.verbosity", &opt->verbosity);
37963797
git_config_get_int("diff.renamelimit", &opt->rename_limit);
37973798
git_config_get_int("merge.renamelimit", &opt->rename_limit);
3799+
git_config_get_bool("merge.renormalize", &renormalize);
3800+
opt->renormalize = renormalize;
37983801
if (!git_config_get_string("diff.renames", &value)) {
37993802
opt->detect_renames = git_config_rename("diff.renames", value);
38003803
free(value);

t/t6038-merge-text-auto.sh

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
158158
compare_files expected file.fuzzy
159159
'
160160

161-
test_expect_failure 'checkout -m after setting text=auto' '
161+
test_expect_success 'checkout -m after setting text=auto' '
162162
cat <<-\EOF >expected &&
163163
first line
164164
same line
@@ -168,12 +168,12 @@ test_expect_failure 'checkout -m after setting text=auto' '
168168
git rm -fr . &&
169169
rm -f .gitattributes &&
170170
git reset --hard initial &&
171-
git checkout a -- . &&
171+
git restore --source=a -- . &&
172172
git checkout -m b &&
173-
compare_files expected file
173+
git diff --no-index --ignore-cr-at-eol expected file
174174
'
175175

176-
test_expect_failure 'checkout -m addition of text=auto' '
176+
test_expect_success 'checkout -m addition of text=auto' '
177177
cat <<-\EOF >expected &&
178178
first line
179179
same line
@@ -183,23 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' '
183183
git rm -fr . &&
184184
rm -f .gitattributes file &&
185185
git reset --hard initial &&
186-
git checkout b -- . &&
186+
git restore --source=b -- . &&
187187
git checkout -m a &&
188-
compare_files expected file
189-
'
190-
191-
test_expect_failure 'cherry-pick patch from after text=auto was added' '
192-
append_cr <<-\EOF >expected &&
193-
first line
194-
same line
195-
EOF
196-
197-
git config merge.renormalize true &&
198-
git rm -fr . &&
199-
git reset --hard b &&
200-
test_must_fail git cherry-pick a >err 2>&1 &&
201-
grep "[Nn]othing added" err &&
202-
compare_files expected file
188+
git diff --no-index --ignore-cr-at-eol expected file
203189
'
204190

205191
test_expect_success 'Test delete/normalize conflict' '

0 commit comments

Comments
 (0)