From: Willy Tarreau Date: Fri, 9 Jun 2017 13:36:02 +0000 (+0200) Subject: BUILD: scripts: make publish-release support bare repositories X-Git-Tag: v1.8-dev3~298 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=600cb57450e928b62d1a3c3f507de251084b434e;p=thirdparty%2Fhaproxy.git BUILD: scripts: make publish-release support bare repositories First we must not report an error when "git diff HEAD" fails. Second, we don't want to "cd" to the home dir when "git rev-parse --show-toplevel" returns an empty string. Third, we definitely want to check that a master branch really exists in the current directory to avoid mistakes. --- diff --git a/scripts/publish-release b/scripts/publish-release index d8f76614f0..8a1645e464 100755 --- a/scripts/publish-release +++ b/scripts/publish-release @@ -64,13 +64,21 @@ if ! git rev-parse --verify -q HEAD >/dev/null; then fi # we want to go to the git top dir -cd $(git rev-parse --show-toplevel) +toplvl=$(git rev-parse --show-toplevel) +if [ -n "$toplvl" ]; then + cd "$toplvl" +fi + +# ensure that a master branch exists here +if [ -z "$(git rev-parse --verify -q master 2>/dev/null)" ]; then + die "Current directory doesn't seem to be a valid git directory (no master branch)." +fi if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then die "git HEAD doesn't match master branch." fi -if [ "$(git diff HEAD|wc -c)" != 0 ]; then +if [ "$(git diff HEAD 2>/dev/null |wc -c)" != 0 ]; then err "You appear to have uncommitted local changes, please commit them first :" git status -s -uno >&2 die