Re: Logical bug during MERGE or REBASE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02-Jul-2021, at 21:55, skottkuk@xxxxx wrote:
> 
> Hello.
> 
> I got a strange result in the process of "merge" and/or "rebase".
> 
> I'm not a git professional, so maybe this is not a bug, but a feature.
> But as for me, it would be logical to consider the construction inside {}
> as something whole, and not just put all the changes into one heap with
> notification what all OK, no conflicts.
> 
> All the details are inside the git-bugreport-2021-07-02-1737.txt.
> I hope this log will be useful. Feel free to write me for extra details.  
> 
> Best regards,
> Skott<git-bugreport-2021-07-02-1737.txt>

Let's look at the diffs (I have annotated this with arrows):

$ # common ancestor, ie, the first commit
$ initial=$(git merge-base master dev)

$ git diff $initial master

diff --git a/program.cs b/program.cs
index 8bc1a4d..93f872f 100644
--- a/program.cs
+++ b/program.cs
@@ -1,4 +1,6 @@
 {
  Console.Writeline("1");
+ Console.Writeline("2");
+ Console.Readline();
  Console.Readline();     <--- X
 }

$ git diff $initial dev

diff --git a/program.cs b/program.cs
index 8bc1a4d..eb91c97 100644
--- a/program.cs
+++ b/program.cs
@@ -1,4 +1,6 @@
 {
  Console.Writeline("1");
  Console.Readline();     <--- X
+ Console.Readline();
+ Console.Readline();
 }

As you can tell, on the master branch, Git sees the changes as
"lines were added above the line labeled X",
and on the dev branch, Git sees the changes as
"lines were added below the line labeled X".

Thus when a 3-way merge is performed, it sees no conflicting changes.
Adding lines above X does not conflict with adding lines below X.

I do agree the result does look surprising at first. If in the dev
branch, git had assumed the "Readline()s" to be added in between,
rather than at the bottom, you would have ended up with a conflict,
but that did not happen.

---
Atharva Raykar
ಅಥರ್ವ ರಾಯ್ಕರ್
अथर्व रायकर





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux