hvsp: add support for compile_branch
[hvutilities.git] / scripts / kernel-send-patches.sh
index e98cd3f..daf7708 100755 (executable)
@@ -156,6 +156,11 @@ if [ x"${base_branch}" = x"" ]; then
     exit 1
 fi
 
+if [ x"${compile_branch}" = x"" ]; then
+    echo "Missing compile_branch shell variable"
+    exit 1
+fi
+
 if [ x"${base_commit}" = x"" ]; then
     base_commit="auto"
 fi
@@ -311,11 +316,29 @@ fi
 sed -i -e "s@COMPILE_CMD@${compile_cmd}@" ${compile_script}
 chmod u+x ${compile_script}
 
-# Compile each commit. Create branch to avoid "detached HEAD" state, and also to
-# keep a record of what was sent:
-git rebase --exec=${compile_script} ${base_branch}
+# Create temporary branch for compilation, based on compile_branch:
+temp_compile_branch="${patches_branch}_compile"
+
+if git branch | grep -q ${temp_compile_branch}; then
+    git branch -D ${temp_compile_branch}
+fi
+
+git checkout -b ${temp_compile_branch} ${compile_branch}
+
+# Make sure temp_compile_branch is rebased on base_branch:
+git rebase ${base_branch}
+
+# Apply all of our commits to temp_compile_branch:
+git cherry-pick ${COMMIT_START_SHA1}..${COMMIT_END_SHA1}
+
+# Compile and test each commit:
+git rebase --exec=${compile_script} ${compile_branch}
+
 git checkout ${orig_branch}
 
+# Remove temporary branch:
+git branch -D ${temp_compile_branch}
+
 # Send email(s)
 git send-email ${DRY_RUN} --annotate --thread --no-chain-reply-to \
     ${TO_OPTS} ${CC_OPTS} \