1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

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
This commit is contained in:
Maxim Cournoyer
2026-02-13 14:03:42 +09:00
parent 3a2c82c09a
commit 427b8f960e

View File

@@ -1269,42 +1269,36 @@ cuirass-jobs: $(GOBJECTS)
.PHONY: clean-go make-go as-derivation .PHONY: clean-go make-go as-derivation
.PHONY: update-guix-package update-NEWS cuirass-jobs release .PHONY: update-guix-package update-NEWS cuirass-jobs release
if in_git_p
# Git auto-configuration. # Git auto-configuration.
.git/hooks/: GIT_HOOKS_DIR := $(shell git rev-parse --git-path hooks)
$(AM_V_at)if test -d .git; then \ GIT_CONFIG_FILE := $(shell git rev-parse --git-path config)
mkdir "$@"; \ $(GIT_HOOKS_DIR):
fi mkdir -p "$@"
.git/hooks/%: etc/git/% | .git/hooks/ $(GIT_HOOKS_DIR)/%: etc/git/% | $(GIT_HOOKS_DIR)/
$(AM_V_at)if test -d .git; then \ cp "$<" "$@"
cp "$<" "$@"; \
fi
.git/config: etc/git/gitconfig $(GIT_CONFIG_FILE): etc/git/gitconfig
$(AM_V_at)if command -v git >/dev/null && test -d .git; then \
git config --fixed-value --replace-all include.path \ git config --fixed-value --replace-all include.path \
../etc/git/gitconfig ../etc/git/gitconfig; \ ../etc/git/gitconfig ../etc/git/gitconfig
fi
COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg=
.git/hooks/commit-msg: etc/git/commit-msg | .git/hooks/ $(GIT_HOOKS_DIR)/commit-msg: etc/git/commit-msg | $(GIT_HOOKS_DIR)
$(AM_V_at)if test -d .git; then \
if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \
mkdir -p $@.d && mv $@ $@.d && \ mkdir -p $@.d && mv $@ $@.d && \
@ echo user commit-msg hook moved to $@.d/commit-msg; \ @ echo user commit-msg hook moved to $@.d/commit-msg; \
fi; \ fi; \
cp etc/git/commit-msg $@; \ cp etc/git/commit-msg $@
fi
# The etc/git/ config files are not distributed and have no use when building # 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. Do not add dependencies on these to *_DATA when building
# from a tarball, as that breaks the build. # from a tarball, as that breaks the build.
if in_git_p
nodist_noinst_DATA = \ nodist_noinst_DATA = \
.git/hooks/pre-push \ $(GIT_HOOKS_DIR)/pre-push \
.git/hooks/post-merge \ $(GIT_HOOKS_DIR)/post-merge \
.git/config \ $(GIT_CONFIG_FILE) \
.git/hooks/commit-msg $(GIT_HOOKS_DIR)/commit-msg
endif endif
# Downloading up-to-date PO files. # Downloading up-to-date PO files.