diff options
| -rw-r--r-- | Makefile.am | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am index 732dd9a2c8c..c55ccb0e248 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | # Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> | 14 | # Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> |
| 15 | # Copyright © 2018 Alex Vong <alexvong1995@gmail.com> | 15 | # Copyright © 2018 Alex Vong <alexvong1995@gmail.com> |
| 16 | # Copyright © 2019, 2023 Efraim Flashner <efraim@flashner.co.il> | 16 | # Copyright © 2019, 2023 Efraim Flashner <efraim@flashner.co.il> |
| 17 | # Copyright © 2020, 2021, 2023, 2025 Maxim Cournoyer <maxim@guixotic.coop> | 17 | # Copyright © 2020, 2021, 2023, 2025, 2026 Maxim Cournoyer <maxim@guixotic.coop> |
| 18 | # Copyright © 2021 Chris Marusich <cmmarusich@gmail.com> | 18 | # Copyright © 2021 Chris Marusich <cmmarusich@gmail.com> |
| 19 | # Copyright © 2021 Andrew Tropin <andrew@trop.in> | 19 | # Copyright © 2021 Andrew Tropin <andrew@trop.in> |
| 20 | # Copyright © 2023 Clément Lassieur <clement@lassieur.org> | 20 | # Copyright © 2023 Clément Lassieur <clement@lassieur.org> |
| @@ -1271,25 +1271,32 @@ cuirass-jobs: $(GOBJECTS) | |||
| 1271 | 1271 | ||
| 1272 | if in_git_p | 1272 | if in_git_p |
| 1273 | # Git auto-configuration. | 1273 | # Git auto-configuration. |
| 1274 | GIT_HOOKS_DIR := $(shell git rev-parse --git-path hooks) | 1274 | |
| 1275 | GIT_CONFIG_FILE := $(shell git rev-parse --git-path config) | 1275 | # Note: the following git commands may fail and produce empty variables, |
| 1276 | # e.g. when working on a work tree in a container. | ||
| 1277 | GIT_HOOKS_DIR := $(shell git rev-parse --git-path hooks 2>/dev/null) | ||
| 1278 | GIT_CONFIG_FILE := $(shell git rev-parse --git-path config 2>/dev/null) | ||
| 1276 | $(GIT_HOOKS_DIR): | 1279 | $(GIT_HOOKS_DIR): |
| 1277 | mkdir -p "$@" | 1280 | if [ -n "$(GIT_HOOKS_DIR)" ]; then mkdir -p "$@"; fi |
| 1278 | 1281 | ||
| 1279 | $(GIT_HOOKS_DIR)/%: etc/git/% | $(GIT_HOOKS_DIR)/ | 1282 | $(GIT_HOOKS_DIR)/%: etc/git/% | $(GIT_HOOKS_DIR)/ |
| 1280 | cp "$<" "$@" | 1283 | if [ -n "$(GIT_HOOKS_DIR)" ]; then cp "$<" "$@"; fi |
| 1281 | 1284 | ||
| 1282 | $(GIT_CONFIG_FILE): etc/git/gitconfig | 1285 | $(GIT_CONFIG_FILE): etc/git/gitconfig |
| 1283 | git config --fixed-value --replace-all include.path \ | 1286 | if [ -n "$(GIT_CONFIG_FILE)" ]; then \ |
| 1284 | ../etc/git/gitconfig ../etc/git/gitconfig | 1287 | git config --fixed-value --replace-all include.path \ |
| 1288 | ../etc/git/gitconfig ../etc/git/gitconfig; \ | ||
| 1289 | fi | ||
| 1285 | 1290 | ||
| 1286 | COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= | 1291 | COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= |
| 1287 | $(GIT_HOOKS_DIR)/commit-msg: etc/git/commit-msg | $(GIT_HOOKS_DIR) | 1292 | $(GIT_HOOKS_DIR)/commit-msg: etc/git/commit-msg | $(GIT_HOOKS_DIR) |
| 1288 | if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ | 1293 | if [ -n "$(GIT_HOOKS_DIR)" ]; then \ |
| 1289 | mkdir -p $@.d && mv $@ $@.d && \ | 1294 | if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ |
| 1290 | @ echo user commit-msg hook moved to $@.d/commit-msg; \ | 1295 | mkdir -p $@.d && mv $@ $@.d && \ |
| 1291 | fi; \ | 1296 | echo user commit-msg hook moved to $@.d/commit-msg; \ |
| 1292 | cp etc/git/commit-msg $@ | 1297 | fi && \ |
| 1298 | cp etc/git/commit-msg $@; \ | ||
| 1299 | fi | ||
| 1293 | 1300 | ||
| 1294 | # Convenience targets. | 1301 | # Convenience targets. |
| 1295 | GIT_HOOKS_SOURCE_FILES := $(shell find etc/git -type f -executable) | 1302 | GIT_HOOKS_SOURCE_FILES := $(shell find etc/git -type f -executable) |
