{"thread":{"id":"64132","subject":"[BUG] Git merge produces inconsistent indentation in merged result","startedAt":"2025-09-12T13:13:31Z","lastAt":"2025-09-12T22:57:03Z","messageCount":2,"participants":["Guo Tingsheng","Elijah Newren"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"526183","messageId":"SN6PR03MB428572C742338251D0399FDFAE08A@SN6PR03MB4285.namprd03.prod.outlook.com","threadId":"64132","inReplyTo":null,"subject":"[BUG] Git merge produces inconsistent indentation in merged result","fromName":"Guo Tingsheng","fromEmail":"coricraft16@outlook.com","sentAt":"2025-09-12T13:13:29Z","receivedAt":"2025-09-12T13:13:31Z","isPatch":false,"sender":{"key":"coricraft16@outlook.com","avatar":null},"body":"Hello Git developers,\n\nI would like to report a potential formatting issue I encountered when testing Git merges.\n\nEnvironment:\n- git version: 2.43.0\n- OS: Ubuntu 24.04 LTS \n\nSteps to reproduce:\n1. Start from a commit containing the following method:\n\n   public void process() {\n       if (flag) {\n           execute();\n       }\n   }\n\n2. On branch A, modify the code by adding a new conditional block with indentation consistent with the surrounding style:\n\n   public void process() {\n       if (flag) {\n           execute();\n       }\n       if (shouldLog) {\n           logger.log(\"Action executed.\");\n       }\n   }\n\n3. On branch B, make no changes to this function.\n\n4. Merge branch A and branch B using:\n   git merge A\n\nExpected result:\n- The merged file should retain the indentation style introduced by branch A:\n\n   public void process() {\n       if (flag) {\n           execute();\n       }\n       if (shouldLog) {\n           logger.log(\"Action executed.\");\n       }\n   }\n\nActual result:\n- Git reduces the indentation of the newly added lines, producing inconsistent formatting:\n\n   public void process() {\n       if (flag) {\n           execute();\n       }\n   if (shouldLog) {\n       logger.log(\"Action executed.\");\n   }\n   }\n\nAdditional information:\n- This issue appears to occur non-deterministically across different test cases.\n- It does not seem related to core.whitespace or space-change options, but instead to how Git decides indentation for newly introduced blocks.\n- The problem was reproduced using multiple merge strategies (ort, recursive).\n\nThanks,\nCori"},{"id":"526236","messageId":"CABPp-BHYEYgqo=G8q2XKReNn6PM+FWn1_8qfKq-ONS6pXXeN2A@mail.gmail.com","threadId":"64132","inReplyTo":"SN6PR03MB428572C742338251D0399FDFAE08A@SN6PR03MB4285.namprd03.prod.outlook.com","subject":"Re: [BUG] Git merge produces inconsistent indentation in merged result","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2025-09-12T22:56:50Z","receivedAt":"2025-09-12T22:57:03Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Fri, Sep 12, 2025 at 6:14 AM Guo Tingsheng <CoriCraft16@outlook.com> wrote:\n>\n> Hello Git developers,\n>\n> I would like to report a potential formatting issue I encountered when testing Git merges.\n>\n> Environment:\n> - git version: 2.43.0\n> - OS: Ubuntu 24.04 LTS\n>\n> Steps to reproduce:\n> 1. Start from a commit containing the following method:\n>\n>    public void process() {\n>        if (flag) {\n>            execute();\n>        }\n>    }\n>\n> 2. On branch A, modify the code by adding a new conditional block with indentation consistent with the surrounding style:\n>\n>    public void process() {\n>        if (flag) {\n>            execute();\n>        }\n>        if (shouldLog) {\n>            logger.log(\"Action executed.\");\n>        }\n>    }\n>\n> 3. On branch B, make no changes to this function.\n>\n> 4. Merge branch A and branch B using:\n>    git merge A\n>\n> Expected result:\n> - The merged file should retain the indentation style introduced by branch A:\n>\n>    public void process() {\n>        if (flag) {\n>            execute();\n>        }\n>        if (shouldLog) {\n>            logger.log(\"Action executed.\");\n>        }\n>    }\n>\n> Actual result:\n> - Git reduces the indentation of the newly added lines, producing inconsistent formatting:\n>\n>    public void process() {\n>        if (flag) {\n>            execute();\n>        }\n>    if (shouldLog) {\n>        logger.log(\"Action executed.\");\n>    }\n>    }\n>\n> Additional information:\n> - This issue appears to occur non-deterministically across different test cases.\n> - It does not seem related to core.whitespace or space-change options, but instead to how Git decides indentation for newly introduced blocks.\n> - The problem was reproduced using multiple merge strategies (ort, recursive).\n\nI've never seen or heard of such a thing before; can you create a\ntestcase to reproduce it, either a repository that others can clone\ntogether with the commands to trigger it, or a bunch of commands to\nboth create a simple repository and demonstrate the issue?\n"}]}