-2

I have a MR request. The diff beside the actual code changes, also shows several line break changes, most probably due to difference in my local styling configurations.

        some_var = db.get_name(EMAIL).get('active', {}).get('email', "") << previuos
        some_var = db.get_name(
            EMAIL).get('active', {}).get('email', "") << current

I tried to locally pull latest from main branch and merge those changes to my branch using git merge. But apparently merge doesn't merge line breaks and white space changes. I even tried by disable all local styling configuration but still no success.

Is there a way I can merge those too, so my MR only shows actual code changes and not these styling differences?

Maven
  • 14,587
  • 42
  • 113
  • 174

1 Answers1

2

But apparently merge doesn't merge line breaks and white space changes

Not true.

A merge combines the changes on both sides of the merge since the point where the branches diverged. If, since the point where the branches diverged, one side does nothing, and the other side does something, the something wins. So if we originally have, at the point where the branches diverged,

some_var = db.get_name(EMAIL).get('active', {}).get('email', "")

and one branch still has

some_var = db.get_name(EMAIL).get('active', {}).get('email', "")

but the latest from the other branch has

some_var = db.get_name(
    EMAIL).get('active', {}).get('email', "")

Then merging one into the other will result in

some_var = db.get_name(
    EMAIL).get('active', {}).get('email', "")

because that's what changed.

so my MR only shows actual code changes and not these styling differences?

That's a slightly different matter. Let's talk about what your "MR shows".

A merge request proposes a merge of one branch into some other branch. To help with review of the request, the web site displays a triple-dot diff with the target branch. This is not a description of what will result when the merge is performed; it is a description of what changes this branch will contribute to the merge.

Now, your merge request proposes to merge your branch into main. Merging main into your branch should therefore effectively have no effect on what the merge request displays. The state of main is, trivially, not a difference from the state of main; thus the contribution from main into your branch as a result of the merge commit does not appear in the display of your branch's merge request.

matt
  • 515,959
  • 87
  • 875
  • 1,141