Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/77085?usp=email )
Change subject: util/scripts/update_submodules: Fix branch name greping ......................................................................
util/scripts/update_submodules: Fix branch name greping
The command "git branch -a | grep -q ${branch}" may not exit with 0 when pipefail is set. "grep -q" exits immediately with exit code 0 as soon as a match is found. However, at that point "git branch -a" may be still writing to the pipe, leading to SIGPIPE. When pipefail is set, PIPESTATUS 141 will be returned. Fix the problem by not using "grep -q".
Also fix the branch name in the generated commit subject.
Change-Id: Ic07efb5e2a4f3b7bbc6e76da9e026771bc685bdb Signed-off-by: Yu-Ping Wu yupingso@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/77085 Reviewed-by: Yidi Lin yidilin@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/scripts/update_submodules 1 file changed, 8 insertions(+), 8 deletions(-)
Approvals: Yidi Lin: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/util/scripts/update_submodules b/util/scripts/update_submodules index 4ca2925..9f6c14f 100755 --- a/util/scripts/update_submodules +++ b/util/scripts/update_submodules @@ -108,13 +108,13 @@ git fetch 2>/dev/null fi
- if git branch -a | grep -q "origin/main"; then - branch_name="origin/main" - elif git branch -a | grep -q "origin/master"; then - branch_name="origin/master" - elif git branch -a | grep -q "origin/trunk"; then - branch_name="origin/trunk" - fi + declare -a branches=("origin/main" "origin/master" "origin/trunk") + for branch in "${branches[@]}"; do + if git branch -a | grep "${branch}" > /dev/null; then + branch_name="${branch}" + break + fi + done
updated_commit_id="$(git log --pretty='%h' -n 1 "${branch_name}" -- )" updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")" @@ -138,7 +138,7 @@ cd "${TOP}" || exit 1 git add "${submodule}" > /dev/null 2>&1 || exit 1 git commit -s -F- > /dev/null 2>&1 <<-EOF - Update ${submodule##*/} submodule to upstream master + Update ${submodule##*/} submodule to upstream ${branch##*/}
Updating from commit id ${initial_commit_id}: $initial_commit_description