Enhance sync script with cherry-pick functionality and improve merge conflict handling Co-authored-by: Copilot <copilot@github.com>#267
Conversation
…conflict handling Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Updates the sync_cute_subtree.sh vendoring/sync workflow to better handle upstream merges and to cherry-pick sync commits back into a dirty working tree more robustly.
Changes:
- Add configurable merge commit message and merge conflict strategy option for the subtree merge step.
- Introduce
cherry_pick_commit_back()to handle merge-commit cherry-picks and gracefully skip empty cherry-picks. - Replace inline cherry-pick logic in the temporary worktree flow with the new helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "Pulling upstream updates into $PREFIX ..." | ||
| invoke_git -C "$work_repo_root" fetch "$UPSTREAM_REPO_FOR_SPLIT" "$TEMP_BRANCH" | ||
| invoke_git_no_merge_edit -C "$work_repo_root" merge -X theirs "-Xsubtree=$PREFIX" FETCH_HEAD | ||
| invoke_git_no_merge_edit -C "$work_repo_root" merge -m "$MERGE_COMMIT_MESSAGE" "-X$MERGE_CONFLICT_OPTION" "-Xsubtree=$PREFIX" FETCH_HEAD |
There was a problem hiding this comment.
MERGE_CONFLICT_OPTION defaults to ours, which changes conflict resolution from the previous -X theirs behavior. For a vendored subtree sync, preferring local changes on conflicts can silently drop upstream updates in conflicted hunks. Consider defaulting back to theirs (or making the strategy configurable via a CLI flag/env var) so upstream wins by default during the merge.
| invoke_git_no_merge_edit -C "$work_repo_root" merge -m "$MERGE_COMMIT_MESSAGE" "-X$MERGE_CONFLICT_OPTION" "-Xsubtree=$PREFIX" FETCH_HEAD | |
| invoke_git_no_merge_edit -C "$work_repo_root" merge -m "$MERGE_COMMIT_MESSAGE" "-X${MERGE_CONFLICT_OPTION:-theirs}" "-Xsubtree=$PREFIX" FETCH_HEAD |
| return 0 | ||
| fi | ||
|
|
||
| echo "Cherry-pick $commit failed with conflicts. Resolve manually and continue." >&2 |
There was a problem hiding this comment.
The failure message says "failed with conflicts", but git cherry-pick can also fail for non-conflict reasons (e.g., existing CHERRY_PICK_HEAD / other in-progress operations). Consider making this message more specific/guiding by including the next steps (e.g., git cherry-pick --continue / --abort) and/or suggesting git status to confirm the state.
| echo "Cherry-pick $commit failed with conflicts. Resolve manually and continue." >&2 | |
| echo "Cherry-pick $commit failed. Run 'git -C \"$REPO_ROOT\" status' to inspect the repository state. If a cherry-pick is in progress, resolve it and run 'git -C \"$REPO_ROOT\" cherry-pick --continue', or run 'git -C \"$REPO_ROOT\" cherry-pick --abort' to cancel it." >&2 |
No description provided.