I'm using Git to track some matlab code. A toy example best illustrates the problem. The project so far looks like this.
C
/
A--
\
B
Contents of A are x=5
We make commit C, where the line is changed to x=6
We then make commit B, where our content becomes as below
if flag==1
x=5
end
If we attempt a merge with the goal of the project looking like
C
/ \
A-- D
\ /
B
with the merge result in D, we'll get a conflict, because the main line has been changed in both (indentation added in B, 5 changed to 6 in C).
Is there a best practice way for integrating indentation changes from one branch, and content changes from another branch, to get a merge result?
I've read about one strategy in https://stackoverflow.com/a/5262473/288545, and while that would avoid the conflict, it would discard the indent in favor of the content change (which is an improvement, but still makes for harder to read code).
I suppose I could just suck it up and not change indentation when writing my code. This makes it less readable, but isn't a huge deal in matlab. However, in python, indentation really matters, so how do python folks deal with it? This gets much uglier if there are large blocks of code that we later change to be inside of control structures, so the diff touches many lines and makes merge conflicts a huge headache.
Is there a merge strategy that will handle spacing changes and content changes separately, and then integrate them? I'd like the result of the merge to be
if flag==1
x=6
end