diff options
| author | Maxim Cournoyer <maxim@guixotic.coop> | 2026-02-13 14:03:42 +0900 |
|---|---|---|
| committer | Maxim Cournoyer <maxim@guixotic.coop> | 2026-02-13 15:01:42 +0900 |
| commit | 427b8f960ec5a3f4c9de4de6917514074bdb371f (patch) | |
| tree | caf4c39f6a0da7b48d4dd7302fa64a509a7eea18 /Makefile.am | |
| parent | 3a2c82c09a8cec3347b97807105e3caf9bfc016b (diff) | |
Makefile.am: Update hooks even when working from a git worktree.
Also simplify recipes by enclosing in the 'in_git_p' Automake conditional.
* Makefile.am (GIT_HOOKS_DIR, GIT_CONFIG_FILE): New variables.
(.git/hooks/, .git/hooks/%, .git/config, .git/hooks/commit-msg): Rewrite in
terms of the above.
(nodist_no_inst_DATA): Likewise.
Change-Id: I8fba6a1923bae5f54253ef6aa529bf68e01678ef
Diffstat (limited to 'Makefile.am')
| -rw-r--r-- | Makefile.am | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/Makefile.am b/Makefile.am index 2ee1be6a83b..4388c75e5b5 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -1269,42 +1269,36 @@ cuirass-jobs: $(GOBJECTS) | |||
| 1269 | .PHONY: clean-go make-go as-derivation | 1269 | .PHONY: clean-go make-go as-derivation |
| 1270 | .PHONY: update-guix-package update-NEWS cuirass-jobs release | 1270 | .PHONY: update-guix-package update-NEWS cuirass-jobs release |
| 1271 | 1271 | ||
| 1272 | if in_git_p | ||
| 1272 | # Git auto-configuration. | 1273 | # Git auto-configuration. |
| 1273 | .git/hooks/: | 1274 | GIT_HOOKS_DIR := $(shell git rev-parse --git-path hooks) |
| 1274 | $(AM_V_at)if test -d .git; then \ | 1275 | GIT_CONFIG_FILE := $(shell git rev-parse --git-path config) |
| 1275 | mkdir "$@"; \ | 1276 | $(GIT_HOOKS_DIR): |
| 1276 | fi | 1277 | mkdir -p "$@" |
| 1277 | 1278 | ||
| 1278 | .git/hooks/%: etc/git/% | .git/hooks/ | 1279 | $(GIT_HOOKS_DIR)/%: etc/git/% | $(GIT_HOOKS_DIR)/ |
| 1279 | $(AM_V_at)if test -d .git; then \ | 1280 | cp "$<" "$@" |
| 1280 | cp "$<" "$@"; \ | ||
| 1281 | fi | ||
| 1282 | 1281 | ||
| 1283 | .git/config: etc/git/gitconfig | 1282 | $(GIT_CONFIG_FILE): etc/git/gitconfig |
| 1284 | $(AM_V_at)if command -v git >/dev/null && test -d .git; then \ | ||
| 1285 | git config --fixed-value --replace-all include.path \ | 1283 | git config --fixed-value --replace-all include.path \ |
| 1286 | ../etc/git/gitconfig ../etc/git/gitconfig; \ | 1284 | ../etc/git/gitconfig ../etc/git/gitconfig |
| 1287 | fi | ||
| 1288 | 1285 | ||
| 1289 | COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= | 1286 | COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= |
| 1290 | .git/hooks/commit-msg: etc/git/commit-msg | .git/hooks/ | 1287 | $(GIT_HOOKS_DIR)/commit-msg: etc/git/commit-msg | $(GIT_HOOKS_DIR) |
| 1291 | $(AM_V_at)if test -d .git; then \ | ||
| 1292 | if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ | 1288 | if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ |
| 1293 | mkdir -p $@.d && mv $@ $@.d && \ | 1289 | mkdir -p $@.d && mv $@ $@.d && \ |
| 1294 | @ echo user commit-msg hook moved to $@.d/commit-msg; \ | 1290 | @ echo user commit-msg hook moved to $@.d/commit-msg; \ |
| 1295 | fi; \ | 1291 | fi; \ |
| 1296 | cp etc/git/commit-msg $@; \ | 1292 | cp etc/git/commit-msg $@ |
| 1297 | fi | ||
| 1298 | 1293 | ||
| 1299 | # The etc/git/ config files are not distributed and have no use when building | 1294 | # The etc/git/ config files are not distributed and have no use when building |
| 1300 | # from a tarball. Do not add dependencies on these to *_DATA when building | 1295 | # from a tarball. Do not add dependencies on these to *_DATA when building |
| 1301 | # from a tarball, as that breaks the build. | 1296 | # from a tarball, as that breaks the build. |
| 1302 | if in_git_p | ||
| 1303 | nodist_noinst_DATA = \ | 1297 | nodist_noinst_DATA = \ |
| 1304 | .git/hooks/pre-push \ | 1298 | $(GIT_HOOKS_DIR)/pre-push \ |
| 1305 | .git/hooks/post-merge \ | 1299 | $(GIT_HOOKS_DIR)/post-merge \ |
| 1306 | .git/config \ | 1300 | $(GIT_CONFIG_FILE) \ |
| 1307 | .git/hooks/commit-msg | 1301 | $(GIT_HOOKS_DIR)/commit-msg |
| 1308 | endif | 1302 | endif |
| 1309 | 1303 | ||
| 1310 | # Downloading up-to-date PO files. | 1304 | # Downloading up-to-date PO files. |
