git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] Git merge produces inconsistent indentation in merged result

From
GTGuo Tingsheng <coricraft16@outlook.com>
Date
Sep 12, 2025, 13:13 UTC
Message-ID
<SN6PR03MB428572C742338251D0399FDFAE08A@SN6PR03MB4285.namprd03.prod.outlook.com>
Hello Git developers,
I would like to report a potential formatting issue I encountered when testing Git merges.
Environment:
- git version: 2.43.0
- OS: Ubuntu 24.04 LTS 
Steps to reproduce:
1. Start from a commit containing the following method:
   public void process() {
       if (flag) {
           execute();
       }
   }
2. On branch A, modify the code by adding a new conditional block with indentation consistent with the surrounding style:
   public void process() {
       if (flag) {
           execute();
       }
       if (shouldLog) {
           logger.log("Action executed.");
       }
   }
3. On branch B, make no changes to this function.
4. Merge branch A and branch B using:
   git merge A
Expected result:
- The merged file should retain the indentation style introduced by branch A:
   public void process() {
       if (flag) {
           execute();
       }
       if (shouldLog) {
           logger.log("Action executed.");
       }
   }
Actual result:
- Git reduces the indentation of the newly added lines, producing inconsistent formatting:
   public void process() {
       if (flag) {
           execute();
       }
   if (shouldLog) {
       logger.log("Action executed.");
   }
   }
Additional information:
- This issue appears to occur non-deterministically across different test cases.
- It does not seem related to core.whitespace or space-change options, but instead to how Git decides indentation for newly introduced blocks.
- The problem was reproduced using multiple merge strategies (ort, recursive).

Thanks, Cori

Next: Elijah Newren
Message 1 of 2 in “[BUG] Git merge produces inconsistent indentation in merged result”
  1. Guo TingshengSep 12, 2025
  2. Elijah NewrenSep 12, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.