After many trials, I got this simple test case scenario:
a --> b --> c -- (master)
\ \
--> d --> b' --> e (branch)
Where:
b'
is a cherry pick ofb
e
is a merge frommaster
.
b'
was done after c
and c
has modifications to same files as b
(d
probably doesn't matter).
e
can easily look very unexpected.
Let's say all of 'em are dealing with same file "foobar.txt
". This is how the file looks in each commit:
// ----------- a
foo
delme
bar
// ----------- b
foo
delme
new
bar
// ----------- c
foo
new
bar
// ----------- b'
foo
delme
new
bar
// ------------ e
foo
new
new
bar
Now, this was from my brief test just now, with this exact setup.
If you remove all spaces there, there is no such problem. Merge will just accuse a conflict, as I'd expect. But I don't think using any -X setting for spaces is what we're looking for here... Or is it?
Meanwhile, on my production code, which was the reason I began researching about all this, and which has not nearly as many blank spaces, I got to see e
looking something like this instead:
// ----------- e
foo
delme
new
bar
All that happens with merge never accusing any conflict!
If git was to do any of its voodoo magical auto merge here, this is what I'd expect it to look like:
// ----------- e
foo
new
bar
But this also does not happen.
As a bit of a disclaimer...
I also tried reading the f manual, but I can't really understand too many points under merge strategies. Plus it doesn't really say what the resolve
strategy is doing under the hood, for instance:
It tries to carefully detect criss-cross merge ambiguities and is considered generally safe and fast.
That says nothing.
The text about the default recursive
is bigger, but I also couldn't extract enough info from it:
This has been reported to result in fewer merge conflicts without causing mis-merges by tests done on actual merge commits taken from Linux 2.6 kernel development history.
Reported? So we got 1 very heavy unit test and assumed by a few reports it's all right?
Well, it's all too vague to me.
I think I must be doing something wrong! So, how can I do it right?
What need I do to get back on merging with no worries?