scripts/refresh-git-hooks | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
New commits:
commit 9a04c32bddd7bffbf0d6be5eed8ead0dae41f849
Author: Andras Timar <
andras...@collabora.com>
AuthorDate: Tue Apr 28 11:51:57 2026 +0200
Commit: Andras Timar <
andras...@collabora.com>
CommitDate: Tue Apr 28 11:51:57 2026 +0200
refresh-git-hooks: don't abort the build when there is no .git
Building from a release tarball (e.g. RPM packaging) extracts the
sources without a .git directory. The script's `if [ ! -d "${gitdir}" ];
then exit 0; fi` guard is meant to handle exactly that case, but with
`set -e` in effect, `git -C ${srcdir} rev-parse --git-common-dir` fails
first with status 128 ("fatal: not a git repository") and the script
aborts before the guard runs — failing make's all-local target and the
whole RPM build.
Restructure into an if/elif/else so the git invocation's failure
becomes a falsy condition instead of an aborted script, redirect its
stderr so the "fatal:" message no longer pollutes the build log, and
fall through to a clean `exit 0` when there is no git checkout.
Also quote ${srcdir} (paths with spaces) and use `shopt -s nullglob` so
the hook loop is skipped cleanly if .git-hooks/ is empty rather than
trying to symlink the literal glob pattern.
Signed-off-by: Andras Timar <
andras...@collabora.com>
Change-Id: I2cb34ae86cdab7949c79e6f28ec4af97c4213696
diff --git a/scripts/refresh-git-hooks b/scripts/refresh-git-hooks
index 19e553e4a20f..c8bfb48dddb0 100755
--- a/scripts/refresh-git-hooks
+++ b/scripts/refresh-git-hooks
@@ -2,23 +2,21 @@
set -e
-srcdir="$PWD"
-if [ -n "${abs_srcdir}" ]; then
- srcdir="${abs_srcdir}"
-fi
+srcdir="${abs_srcdir:-$PWD}"
-if [ ! -d "${srcdir}/.git" ]; then
- gitdir=$(git -C ${srcdir} rev-parse --git-common-dir)
- if [ ! -d "${gitdir}" ]; then
- exit 0
- fi
-else
+if [ -d "${srcdir}/.git" ]; then
gitdir="${srcdir}/.git"
+elif gitdir=$(git -C "${srcdir}" rev-parse --git-common-dir 2>/dev/null) && [ -d "${gitdir}" ]; then
+ :
+else
+ # Not a git checkout (e.g. tarball build) — nothing to do.
+ exit 0
fi
mkdir -p "${gitdir}"/hooks
-for hook_name in ${srcdir}/.git-hooks/*
+shopt -s nullglob
+for hook_name in "${srcdir}"/.git-hooks/*
do