From: Junio C Hamano Date: Thu, 18 Jul 2024 16:04:48 GMT Subject: Re: [PATCH v5 4/6] ci: run style check on GitHub and GitLab Message-ID: In-Reply-To: Junio C Hamano writes: > Karthik Nayak writes: > ... >> + R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA?}} >> + >> + if test -z "$R" >> + then >> + echo "CI_MERGE_REQUEST_DIFF_BASE_SHA should always exist!" >> + exit 1 >> + fi > > If you update the assignment to R to > > R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} > > an unset CI_MERGE_REQUEST_DIFF_BASE_SHA1 or an empty value in it > will be rejected there. Then you can lose the if/then/fi here. Actually, you also need to pay attention to the exit status of the assignment, i.e. R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} || exit