[BUG] git merge sometimes loses changes from one branch

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

 



Hello Git developers,

I would like to report a potential issue in Git's merge behavior, where changes from one branch may be lost even when the other branch does not modify the same location.

Environment:
- git version: 2.43.0
- OS: Ubuntu 24.04 LTS

Steps to reproduce:
1. On branch A, modify a file at a certain location:

   @@ -1026,7 +1028,9 @@
   public final class AutoBuilderCompilationTest {
                "  }",
                "}"); 
        Compilation compilation =
   -        javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
   +        javac()
   +            .withProcessors(new AutoBuilderProcessor())
   +            .compile(javaFileObject);
        assertThat(compilation).failed();
        assertThat(compilation)
            .hadErrorContaining(

2. On branch B, make no changes to this location.

3. Merge branch A and branch B.

Expected result:
- The merge should retain the changes made in branch A:

   @@ -1026,7 +1028,9 @@
   public final class AutoBuilderCompilationTest {
                "  }",
                "}"); 
        Compilation compilation =
   -        javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
   +        javac()
   +            .withProcessors(new AutoBuilderProcessor())
   +            .compile(javaFileObject);
        assertThat(compilation).failed();
        assertThat(compilation)
            .hadErrorContaining(

Actual result:
- Git sometimes produces a merged result where the modification from branch A is lost, yielding:

   @@ -1026,7 +1028,9 @@
   public final class AutoBuilderCompilationTest {
                "  }",
                "}"); 
        Compilation compilation =
           javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
        assertThat(compilation).failed();
        assertThat(compilation)
            .hadErrorContaining(

Additional information:
- This issue occurs even when the other branch (B) does not modify the same location.
- It appears to happen non-deterministically and may lead to subtle bugs in real-world merges.

Thanks,
Cori




[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