From 2c0e53cb08cddf9fbdda47ddf6917b846a21665d Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Thu, 8 Aug 2019 17:51:26 -0700 Subject: [PATCH] sync: attempt to auto-resolve non-libbpf conflicts If cherry-picked commit contains non-libbpf files, chances are high that this will result in conflict, because we are generally skipping commits that didn't touch libbpf files, which means that our working copy will not be up-to-date for non-libbpf files. This change checks if conflicts are only in non-libbpf files and marks them as resolved. This will work fine as long as we don't cherry-pick some more non-libbpf changes to same set of files that happen to conflict with not-so-resolved version of non-libbpf files. But anyways, this should help in a lot of cases. Signed-off-by: Andrii Nakryiko --- scripts/sync-kernel.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/sync-kernel.sh b/scripts/sync-kernel.sh index 0e94d1c..2415a53 100755 --- a/scripts/sync-kernel.sh +++ b/scripts/sync-kernel.sh @@ -104,6 +104,7 @@ cherry_pick_commits() local should_skip local synced_cnt local manual_check + local libbpf_conflict_cnt local desc new_commits=$(git rev-list --no-merges --topo-order --reverse ${baseline_tag}..${tip_tag} ${LIBBPF_PATHS[@]}) @@ -139,6 +140,21 @@ cherry_pick_commits() # commit hasn't been synced into libbpf yet echo "Picking '${desc}'..." if ! git cherry-pick ${new_commit} &>/dev/null; then + echo "Warning! Cherry-picking '${desc} failed, checking if it's non-libbpf files causing problems..." + libbpf_conflict_cnt=$(git diff --name-only --diff-filter=U -- ${LIBBPF_PATHS[@]} | wc -l) + + if ((${libbpf_conflict_cnt} == 0)); then + echo "Looks like only non-libbpf files have conflicts, ignoring..." + git add . + # GIT_EDITOR=true to avoid editor popping up to edit commit message + if ! GIT_EDITOR=true git cherry-pick --continue; then + echo "Error! That still failed! Please resolve manually." + else + echo "Success! All cherry-pick conflicts were resolved for '${desc}'!" + continue + fi + fi + read -p "Error! Cherry-picking '${desc}' failed, please fix manually and press to proceed..." fi done