From ce53d3c1d2632bd96d4e808285d63cc83dde9d7e Mon Sep 17 00:00:00 2001 From: Slim B Date: Sat, 14 Feb 2026 15:11:31 +0300 Subject: [PATCH] Fix reconciliation parent order and add reverse sync tree check - Swap parent order in reconcile_filter_change(): josh-filtered must be first parent so josh can follow first-parent traversal to map history back to the monorepo. Old subrepo history on parent 2. - Add tree comparison in reverse_sync() before commit detection: if subrepo tree matches josh-filtered tree, skip immediately. Prevents false positive PRs after reconciliation. Co-Authored-By: Claude Opus 4.6 --- lib/sync.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/sync.sh b/lib/sync.sh index d24d454..03afe6b 100644 --- a/lib/sync.sh +++ b/lib/sync.sh @@ -185,11 +185,13 @@ reconcile_filter_change() { return fi - # 4. Create merge commit: subrepo HEAD + josh-proxy HEAD, with josh-proxy's tree + # 4. Create merge commit: josh-proxy HEAD (first parent) + subrepo HEAD, with josh-proxy's tree + # Josh follows first-parent traversal — josh-filtered MUST be first so josh can map + # the history back to the monorepo. Old subrepo history hangs off parent 2. local merge_commit merge_commit=$(git commit-tree "$josh_tree" \ - -p "$subrepo_head" \ -p "$josh_head" \ + -p "$subrepo_head" \ -m "Sync: filter configuration updated ${BOT_TRAILER}: filter-change/${mono_branch}/$(date -u +%Y-%m-%dT%H:%M:%SZ)") @@ -242,7 +244,20 @@ reverse_sync() { git remote add mono-filtered "$(josh_auth_url)" git fetch mono-filtered "$mono_branch" || die "Failed to fetch from josh-proxy" - # 3. Find new human commits (excludes bot commits from forward sync) + # 3. Compare trees — skip if subrepo matches josh-filtered view + local subrepo_tree josh_tree + # shellcheck disable=SC1083 # {tree} is git syntax, not shell brace expansion + subrepo_tree=$(git rev-parse "HEAD^{tree}") + # shellcheck disable=SC1083 + josh_tree=$(git rev-parse "mono-filtered/${mono_branch}^{tree}") + + if [ "$subrepo_tree" = "$josh_tree" ]; then + log "INFO" "Subrepo tree matches josh-filtered view — nothing to sync" + echo "skip" + return + fi + + # 4. Find new human commits (excludes bot commits from forward sync) local human_commits human_commits=$(git log --ancestry-path "mono-filtered/${mono_branch}..HEAD" \ --oneline --invert-grep --grep="^${BOT_TRAILER}:" 2>/dev/null || echo "")