summaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim@guixotic.coop>2026-02-13 14:03:42 +0900
committerMaxim Cournoyer <maxim@guixotic.coop>2026-02-13 15:01:42 +0900
commit427b8f960ec5a3f4c9de4de6917514074bdb371f (patch)
treecaf4c39f6a0da7b48d4dd7302fa64a509a7eea18 /Makefile.am
parent3a2c82c09a8cec3347b97807105e3caf9bfc016b (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.am36
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)
.PHONY: clean-go make-go as-derivation
.PHONY: update-guix-package update-NEWS cuirass-jobs release
+if in_git_p
# Git auto-configuration.
-.git/hooks/:
- $(AM_V_at)if test -d .git; then \
- mkdir "$@"; \
- fi
+GIT_HOOKS_DIR := $(shell git rev-parse --git-path hooks)
+GIT_CONFIG_FILE := $(shell git rev-parse --git-path config)
+$(GIT_HOOKS_DIR):
+ mkdir -p "$@"
-.git/hooks/%: etc/git/% | .git/hooks/
- $(AM_V_at)if test -d .git; then \
- cp "$<" "$@"; \
- fi
+$(GIT_HOOKS_DIR)/%: etc/git/% | $(GIT_HOOKS_DIR)/
+ cp "$<" "$@"
-.git/config: etc/git/gitconfig
- $(AM_V_at)if command -v git >/dev/null && test -d .git; then \
+$(GIT_CONFIG_FILE): etc/git/gitconfig
git config --fixed-value --replace-all include.path \
- ../etc/git/gitconfig ../etc/git/gitconfig; \
- fi
+ ../etc/git/gitconfig ../etc/git/gitconfig
COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg=
-.git/hooks/commit-msg: etc/git/commit-msg | .git/hooks/
- $(AM_V_at)if test -d .git; then \
+$(GIT_HOOKS_DIR)/commit-msg: etc/git/commit-msg | $(GIT_HOOKS_DIR)
if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \
mkdir -p $@.d && mv $@ $@.d && \
@ echo user commit-msg hook moved to $@.d/commit-msg; \
fi; \
- cp etc/git/commit-msg $@; \
- fi
+ cp etc/git/commit-msg $@
# The etc/git/ config files are not distributed and have no use when building
# from a tarball. Do not add dependencies on these to *_DATA when building
# from a tarball, as that breaks the build.
-if in_git_p
nodist_noinst_DATA = \
- .git/hooks/pre-push \
- .git/hooks/post-merge \
- .git/config \
- .git/hooks/commit-msg
+ $(GIT_HOOKS_DIR)/pre-push \
+ $(GIT_HOOKS_DIR)/post-merge \
+ $(GIT_CONFIG_FILE) \
+ $(GIT_HOOKS_DIR)/commit-msg
endif
# Downloading up-to-date PO files.