You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pgxntool-sync: base the subtree merge on the embedded version, not git-subtree history #138
make pgxntool-sync conflicts on every file pgxntool changed whenever the consuming project squash-merges its sync PRs on GitHub. That's the default (and often only) merge mode for many repos, so it's the common case.
Cause
git subtree pull --squash finds the previous sync by looking for the git-subtree-dir: / git-subtree-split: trailers on the subtree's own "Squashed 'pgxntool/' changes from X..Y" commit, and uses that commit as the merge base. A GitHub squash-merge discards that commit, and with squash_merge_commit_message = PR_BODY its trailers too. Subtree then falls back to the last sync that was preserved, which can be several releases old, and 3-way merges the new release against that stale base. The project's real (unmodified) copy of the previous release looks like local edits, so every file both sides touched conflicts.
Observed in Postgres-Extensions/test_factory: the 2.1.0, 2.2.0 and 2.3.0 syncs were squash-merged, so syncing to 2.4.0 used a pre-2.1.0 commit (bed3604) as the base and conflicted in CLAUDE.md, HISTORY.asc, README.asc, README.html, _.gitignore, base.mk, pgtle.sh and verify-results-pgtap.sh, even though the embedded copy had no local patches against 2.3.0.
(pgxntool's history was also rewritten after bed3604, so it's no longer an ancestor of current releases. In --squash mode that alone doesn't break the pull, but it does rule out any fix that relies on pgxntool ancestry.)
Proposal
Have pgxntool-sync.sh stop depending on git-subtree's history detection. The embedded copy already knows its version (make pgxntool-version / bin/version), so the sync can:
Read the embedded version and fetch that tag as the merge base.
Do the 3-way merge of pgxntool/ with base = old tag, ours = current pgxntool/, theirs = target ref. A simpler variant: if pgxntool/ matches the old tag exactly (ignoring the pruned .github/.claude dirs), replace it outright; otherwise fall back to the 3-way merge or refuse with a clear message.
Continue to pass that same old version to update-setup-files.sh for the setup-file merge.
This works no matter how consumers merge PRs (squash, rebase or merge commit) and is unaffected by history rewrites in pgxntool.
Workarounds today: push sync commits directly to the default branch, or merge sync PRs with a real merge commit. Either way the subtree squash commit reaches the default branch intact.
Workaround until this is fixed, for a consumer whose earlier sync PRs were squash-merged: re-anchor the subtree once with a single git subtree pull resolved to the incoming release, then merge every sync PR with "Create a merge commit".
Result: exactly two commits on top of the base branch: the subtree squash commit (carrying the git-subtree-dir/git-subtree-split stamp) and one merge commit holding the whole update.
Steps (from the base branch, detached or on the sync branch):
old=$(git log -1 --format=%H -- pgxntool/)
git subtree pull -P pgxntool --squash -m "Update pgxntool to <tag>" <pgxntool repo URL> <tag>. If the newest stamp is old, this conflicts on many pgxntool/ files; that is expected.
Resolve every pgxntool/ path to the incoming release: git checkout --theirs -- <conflicted paths> then git add <those paths> (git rm where the release deletes a file).
git rm -r -f pgxntool/.claude pgxntool/.github (pgxntool's dev-only dirs, which this consumer does not vendor).
bash pgxntool/update-setup-files.sh "$old" and resolve whatever it reports, then git add -A.
Commit the merge (same commit as the pull; no separate copy-over or prune commits).
Merge the PR with "Create a merge commit", not squash, and do the same for every later sync PR. A squash drops the stamp commit.
On later pulls: if pgxntool changed a file under a pruned path, you get a modify/delete conflict on it. Resolve with git rm <path>, and do that in the same merge commit. If the pull exits non-zero, run pgxntool/update-setup-files.sh <old commit> by hand, because pgxntool-sync.sh skips it in that case.
Simulation of the next sync (scratch clone of pgxntool at 2.4.0 plus one commit touching base.mk and .github/workflows/ci.yml; #67's head merged into upstream master with --no-ff to mimic GitHub's merge commit; then git subtree pull -P pgxntool --squash <scratch clone> scratch):
CONFLICT (modify/delete): pgxntool/.github/workflows/ci.yml deleted in HEAD and modified in cb4c7a98b70dbca4450b9fbbe7932ede750ecca2. Version cb4c7a98b70dbca4450b9fbbe7932ede750ecca2 of pgxntool/.github/workflows/ci.yml left in tree.
Automatic merge failed; fix conflicts and then commit the result.
The squash commit read "Squashed 'pgxntool/' changes from e80485e..cc0e2d8" (the base was the 2.4.0 split, not an older sync). base.mk merged cleanly and was the only other changed path.
Activity
jnasbyupgrade commentedon Nov 2, 2026
Workaround until this is fixed, for a consumer whose earlier sync PRs were squash-merged: re-anchor the subtree once with a single
git subtree pullresolved to the incoming release, then merge every sync PR with "Create a merge commit".Result: exactly two commits on top of the base branch: the subtree squash commit (carrying the
git-subtree-dir/git-subtree-splitstamp) and one merge commit holding the whole update.Steps (from the base branch, detached or on the sync branch):
old=$(git log -1 --format=%H -- pgxntool/)git subtree pull -P pgxntool --squash -m "Update pgxntool to <tag>" <pgxntool repo URL> <tag>. If the newest stamp is old, this conflicts on manypgxntool/files; that is expected.pgxntool/path to the incoming release:git checkout --theirs -- <conflicted paths>thengit add <those paths>(git rmwhere the release deletes a file).git rm -r -f pgxntool/.claude pgxntool/.github(pgxntool's dev-only dirs, which this consumer does not vendor).bash pgxntool/update-setup-files.sh "$old"and resolve whatever it reports, thengit add -A.On later pulls: if pgxntool changed a file under a pruned path, you get a modify/delete conflict on it. Resolve with
git rm <path>, and do that in the same merge commit. If the pull exits non-zero, runpgxntool/update-setup-files.sh <old commit>by hand, becausepgxntool-sync.shskips it in that case.Worked example: Postgres-Extensions/pg_count_nulls#67 (2.4.0 re-anchor): the final tree is identical to a plain copy-over of 2.4.0, in two commits.
Simulation of the next sync (scratch clone of pgxntool at 2.4.0 plus one commit touching
base.mkand.github/workflows/ci.yml; #67's head merged into upstream master with--no-ffto mimic GitHub's merge commit; thengit subtree pull -P pgxntool --squash <scratch clone> scratch):The squash commit read "Squashed 'pgxntool/' changes from e80485e..cc0e2d8" (the base was the 2.4.0 split, not an older sync).
base.mkmerged cleanly and was the only other changed path.🤖 Generated with Claude Code