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

Re: [Bug] Git subtree regression

From
Ggeorge@mail.dietrich.pub <george@mail.dietrich.pub>
Date
Dec 30, 2025, 17:07 UTC
Message-ID
<20251230170719.845029-1-george@mail.dietrich.pub>
In-Reply-To
<176677910605.6.2281395015810449820.1087545551@dietrich.pub>

--- I explored this more and think I found the root cause. Commit `83f9dad7d6fb5988b68f80b25bd87c68693195dd` changed `should_ignore_subtree_split_commit()` to examine only a commit's own trailers via `git show --format='%(trailers:...)'`. The old code used `git log -1 --grep=...` which had the important side effect of searching through ancestor commits.

In a multi-subtree monorepo with this topology:
```
  main:    A---B---M---E    (B = subtree add --squash for subA)
                  /
  feature:   C---D          (D = subtree add --squash for subB)
```
When splitting `subA`, commits `C` and `D` from the feature branch should be **ignored** because they belong to a branch that only contains `subB`, not `subA`.
## Old behavior (2.51.1)
`git log -1 --grep="git-subtree-dir:"` on commit `C` would traverse ancestors and find `D`'s subtree markers for `subB`, correctly identifying `C` as belonging to another subtree's branch.
## New behavior (2.52.0)

`git show` on commit `C` finds no trailers (regular commits don't have them), so `C` is **not** ignored. This breaks the split because both parents of the merge `M` are processed, but `C` has no cache entry, leading to disconnected history. Thus, split operations produce fewer commits than expected with broken parent chains, breaking push/pull workflows to upstream subtree repositories.

## Reproduction
This can be reproduced via my monorepo: https://github.com/athena-framework/athena

```bash # 2.51.1 produces correct result (matches the number of commits in the `athena-framework/clock` repo) $ git subtree split --prefix="src/components/clock" 4ee66f8198b2532110b75a36575e363ccccff47e # 20 commits, connected to remote

# 2.52.0 produces broken result $ git subtree split --prefix="src/components/clock" 0efb3d9858e3bfee65165508aeeacc50417c9a99 # 7 commits, disconnected

# The commits have identical trees but different parents: $ git cat-file -p 4ee66f8198b2532110b75a36575e363ccccff47e tree 8333b0cbb2a10528f8c803812af7a8e603e70367 parent d72f22f28ca5ed57ef3c2df74f0abd5569ac5934 # Connected to 19-commit history

$ git cat-file -p 0efb3d9858e3bfee65165508aeeacc50417c9a99 tree 8333b0cbb2a10528f8c803812af7a8e603e70367 parent 81c5dbe70ce26a7758fbe7f87b3ce0704043cfb1 # Only 6 commits, disconnected ```

Previous: dev@dietrich.pubNext: Colin Stagner
Message 2 of 11 in “[Bug] Git subtree regression”
  1. dev@dietrich.pubDec 26, 2025
  2. george@mail.dietrich.pubDec 30, 2025
  3. Colin StagnerJan 4, 2026
  4. george@mail.dietrich.pubJan 4, 2026
  5. Colin StagnerJan 5, 2026
  6. george@mail.dietrich.pubJan 6, 2026
  7. Colin StagnerJan 10, 2026
  8. george@mail.dietrich.pubJan 10, 2026
  9. Colin StagnerFeb 15, 2026
  10. D. Ben KnobleFeb 16, 2026
  11. george@mail.dietrich.pubFeb 18, 2026

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.