When an empty patch (such as a cover letter) was given to apply-and-build, the latter would fail applying the patch and all following patches (saying OK when it could be wrong)
Signed-off-by: Christophe Milard <christophe.mil...@linaro.org> --- apply-and-build.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/apply-and-build.sh b/apply-and-build.sh index e41c297..683a0b6 100755 --- a/apply-and-build.sh +++ b/apply-and-build.sh @@ -152,26 +152,40 @@ apply_patch() { echo " Trying to apply patch" git am ${patch} >> ${logfile_basename}-am.log 2>&1 - egrep "^Patch failed at" ${logfile_basename}-am.log > /dev/null - if [ $? -eq 0 ]; then + if [ $? -ne 0 ]; then + #git am is unsuccessfull, because of a apply failure or empty patch cat ${logfile_basename}-am.log - git am --abort || exit 1 - git checkout . || exit 1 - git clean -xdf || exit 1 - git am --3way ${patch} >> ${logfile_basename}-am-3way.log 2>&1 - egrep "^Patch failed at" ${logfile_basename}-am-3way.log > /dev/null + egrep "^Patch failed at" ${logfile_basename}-am.log > /dev/null if [ $? -eq 0 ]; then - cat ${logfile_basename}-am-3way.log - echo " Error: Patch failed to apply" + #apply failure: clean up and try 3way apply: git am --abort || exit 1 git checkout . || exit 1 git clean -xdf || exit 1 + git am --3way ${patch} >> ${logfile_basename}-am-3way.log 2>&1 + if [ $? -ne 0 ]; then + #even 3way apply failed: clean and give up + cat ${logfile_basename}-am-3way.log + echo " Error: Patch failed to apply" + git am --abort || exit 1 + git checkout . || exit 1 + git clean -xdf || exit 1 + popd > /dev/null + continue + else + #3way apply worked + echo " Warning: git am --3way, applied" + fi + else + #git am unsuccessful but no "Patch failed at" in output: + echo " Warning: Patch could not apply, but did not fail (empty patch? cover-letter?): skipping it..." + git am --abort #to be on the safe side, but probably unsuccessful. + git checkout . || exit 1 + git clean -xdf || exit 1 popd > /dev/null continue - else - echo " Warning: git am --3way, applied" fi else + #patch successfully applied: echo " Patch applied" egrep "^warning:" ${logfile_basename}-am.log > /dev/null if [ $? -eq 0 ]; then -- 1.9.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp