From: Kacper Kornet Date: Thu, 23 Aug 2012 13:12:43 +0000 (+0100) Subject: builder: rewrite code to checkout refs X-Git-Tag: auto/th/rpm-build-tools-4.5-7~30 X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm-build-tools.git;a=commitdiff_plain;h=6217f40703a29f733a546091358749d912b639c4 builder: rewrite code to checkout refs git-checkout $CVSTAG can fail due to other reasons then non existing tag, i.e. when the merge is in progress. In previous version in such a remote tracking branch was tried to be check out, which resulted in error. It prevented user from checking if his merge commits builds correctly before commiting it. --- diff --git a/builder.sh b/builder.sh index e61f014..3284d47 100755 --- a/builder.sh +++ b/builder.sh @@ -785,6 +785,9 @@ Exit_error() { remove_build_requires echo >&2 "Error: problem with remote (${2})" exit 13 ;; + "err_no_checkut" ) + echo >&2 "Error: cannot checkout $2" + exit 14 ;; "err_not_implemented" ) remove_build_requires echo >&2 "Error: functionality not yet imlemented" @@ -947,7 +950,14 @@ get_spec() { fi if [ -n "$CVSTAG" ]; then - git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit + if git rev-parse --verify -q "$CVSTAG"; then + git checkout "$CVSTAG" -- + elif git rev-parse --verify -q "refs/remotes/${REMOTE_PLD}/$CVSTAG"; then + git checkout -t "refs/remotes/${REMOTE_PLD}/$CVSTAG" > /dev/null + fi + if [ $(git rev-parse "$CVSTAG") != $(git rev-parse HEAD) ]; then + Exit_error "err_no_checkut" "$CVSTAG" + fi git symbolic-ref -q HEAD > /dev/null && git merge '@{u}' if [ -n "$CVSDATE" ]; then