]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: scripts: make publish-release support bare repositories
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Jun 2017 13:36:02 +0000 (15:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Jun 2017 13:44:42 +0000 (15:44 +0200)
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.

scripts/publish-release

index d8f76614f0d6b71de296a8e60ed8e5cbf62a5aa6..8a1645e46485c522329c6cbd7f528a67972889b5 100755 (executable)
@@ -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