Re: Do not raise conflict when a code in a patch was already added
- From
- Igor Djordjevic <igor.d.djordjevic@gmail.com>
- Date
- Aug 21, 2018, 12:10 UTC
- Message-ID
- <32354ab0-1d17-0be3-679a-75f6287a6bab@gmail.com>
- In-Reply-To
- <e5f65c19-0f49-d48e-c600-7dfcd95f3218@yandex.ru>
Hi Konstantin,
On 21/08/2018 11:37, Konstantin Kharlamov wrote:
Show 14 quoted lines
> > > There's another possibility (and I think it is what happens > > actually in Konstantin's case): When one side added lines 1 2 and the > > other side added 1 2 3, then the actual conflict is > > << 1 2 == 1 2 3 >>, but our merge code is able to move the identical > > part out of the conflicted section: 1 2 << == 3 >>. But this is just > > a courtesy for the user; the real conflict is the original one. > > Without this optimization, the work to resolve the conflict would be > > slightly more arduous. > > Yeah, thanks, that's what happens. And I'm wondering, is it really > needed to raise a conflict there? Would it be worth to just apply the > line "3", possibly with a warning or an interactive question to user > (apply/raise) that identical parts were ignored?
I see how this might make sense in the given example of "A added 1 and 2, B added 1 and 2 and 3", but I'm afraid that might be a too narrow view.
What we actually don't know is if A deliberately chose not to include 3, or even worse, if A started from having "1 and 2 and 3" in there, and then decided to remove 3.
In both these situation just applying 3 would be wrong, and raising a conflict seems as the most (and only?) sensible solution.
Applying _and_ asking for confirmation might be interesting, but I'm afraid it would favor specific use case only, being an annoyance in all the others (where it should really be a conflict, and you now have additional prompt to deal with).
That said, it would indeed be nice to have a way to communicate to `git rebase` that we are just splitting later commit into smaller parts preceding it, so situations like this could be resolved automatically and without conflicts, as you'd expected - but only within that narrow, user-provided/communicated context, not in general case.
Regards, Buga