-
Notifications
You must be signed in to change notification settings - Fork 59
Enhance sync script with cherry-pick functionality and improve merge conflict handling Co-authored-by: Copilot <copilot@github.com> #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0bd45a
2f7ea0c
1811618
abc1eea
aa03d81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,9 @@ NO_TEMPORARY_WORKTREE=0 | |||||
| TEMP_WORKTREE_PATH="" | ||||||
| TEMP_WORKTREE_BRANCH="" | ||||||
| PREPARE_MERGE_COMMIT_MESSAGE="Rewrite vendored CuTe namespace to flash_attn.cute before subtree merge" | ||||||
| MERGE_COMMIT_MESSAGE="Merge upstream CuTe subtree updates" | ||||||
| REWRITE_COMMIT_MESSAGE="Rewrite vendored CuTe namespace to flash_sparse_attn.ops.cute" | ||||||
| MERGE_CONFLICT_OPTION="ours" | ||||||
| UPSTREAM_SPLIT_REF="HEAD" | ||||||
|
|
||||||
| usage() { | ||||||
|
|
@@ -263,6 +265,34 @@ commit_prefix_if_changed() { | |||||
| invoke_git -C "$repo" commit -m "$message" | ||||||
| } | ||||||
|
|
||||||
| cherry_pick_commit_back() { | ||||||
| local repo="$1" | ||||||
| local commit="$2" | ||||||
| local parent_count | ||||||
|
|
||||||
| parent_count="$(get_commit_parent_count "$repo" "$commit")" | ||||||
| if [[ "$parent_count" -gt 1 ]]; then | ||||||
| if invoke_git -C "$REPO_ROOT" cherry-pick -m 1 "$commit"; then | ||||||
| return 0 | ||||||
| fi | ||||||
| else | ||||||
| if invoke_git -C "$REPO_ROOT" cherry-pick "$commit"; then | ||||||
| return 0 | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| if git -C "$REPO_ROOT" rev-parse -q --verify CHERRY_PICK_HEAD >/dev/null 2>&1 \ | ||||||
| && git -C "$REPO_ROOT" diff --cached --quiet \ | ||||||
| && git -C "$REPO_ROOT" diff --quiet; then | ||||||
| echo "Cherry-pick $commit became empty after conflict resolution. Skipping ..." | ||||||
| invoke_git -C "$REPO_ROOT" cherry-pick --skip | ||||||
| return 0 | ||||||
| fi | ||||||
|
|
||||||
| echo "Cherry-pick $commit failed with conflicts. Resolve manually and continue." >&2 | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| invoke_core_sync() { | ||||||
| local work_repo_root="$1" | ||||||
| local cutlass_repo="$work_repo_root/csrc/cutlass" | ||||||
|
|
@@ -322,7 +352,7 @@ invoke_core_sync() { | |||||
|
|
||||||
| 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 | ||||||
|
||||||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure message says "failed with conflicts", but
git cherry-pickcan 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 suggestinggit statusto confirm the state.