
When we install Git we also install a set of default templates that both git-init(1) and git-clone(1) populate into our build directories. The way the pristine templates are laid out in our source directory is somewhat weird though: instead of reconstructing the actual directory hierarchy in "templates/", we represent directory separators with "--". The only reason I could come up with for why we have this is the "branches/" directory, which is supposed to be empty when installing it. And as Git famously doesn't store empty directories at all we have to work around this limitation. Now the thing is that the "branches/" directory is a leftover to how branches used to be stored in the dark ages. gitrepository-layout(5) lists this directory as "slightly deprecated", which I would claim is a strong understatement. I have never encountered anybody using it today and would be surprised if it even works as expected. So having the "--" hack in place for an item that is basically unused, unmaintained and deprecated doesn't only feel unreasonable, but installing that entry by default may also cause confusion for users that do not know what this is supposed to be in the first place. Remove this directory from our templates and, now that we do not require the workaround anymore, restructure the templates to form a proper hierarchy. This makes it way easier for build systems to install these templates into place. We should likely think about removing support for "branch/" altogether, but that is outside of the scope of this patch series. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
78 lines
2.3 KiB
Bash
Executable File
78 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# An example hook script to validate a patch (and/or patch series) before
|
|
# sending it via email.
|
|
#
|
|
# The hook should exit with non-zero status after issuing an appropriate
|
|
# message if it wants to prevent the email(s) from being sent.
|
|
#
|
|
# To enable this hook, rename this file to "sendemail-validate".
|
|
#
|
|
# By default, it will only check that the patch(es) can be applied on top of
|
|
# the default upstream branch without conflicts in a secondary worktree. After
|
|
# validation (successful or not) of the last patch of a series, the worktree
|
|
# will be deleted.
|
|
#
|
|
# The following config variables can be set to change the default remote and
|
|
# remote ref that are used to apply the patches against:
|
|
#
|
|
# sendemail.validateRemote (default: origin)
|
|
# sendemail.validateRemoteRef (default: HEAD)
|
|
#
|
|
# Replace the TODO placeholders with appropriate checks according to your
|
|
# needs.
|
|
|
|
validate_cover_letter () {
|
|
file="$1"
|
|
# TODO: Replace with appropriate checks (e.g. spell checking).
|
|
true
|
|
}
|
|
|
|
validate_patch () {
|
|
file="$1"
|
|
# Ensure that the patch applies without conflicts.
|
|
git am -3 "$file" || return
|
|
# TODO: Replace with appropriate checks for this patch
|
|
# (e.g. checkpatch.pl).
|
|
true
|
|
}
|
|
|
|
validate_series () {
|
|
# TODO: Replace with appropriate checks for the whole series
|
|
# (e.g. quick build, coding style checks, etc.).
|
|
true
|
|
}
|
|
|
|
# main -------------------------------------------------------------------------
|
|
|
|
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
|
|
then
|
|
remote=$(git config --default origin --get sendemail.validateRemote) &&
|
|
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
|
|
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
|
|
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
|
|
git config --replace-all sendemail.validateWorktree "$worktree"
|
|
else
|
|
worktree=$(git config --get sendemail.validateWorktree)
|
|
fi || {
|
|
echo "sendemail-validate: error: failed to prepare worktree" >&2
|
|
exit 1
|
|
}
|
|
|
|
unset GIT_DIR GIT_WORK_TREE
|
|
cd "$worktree" &&
|
|
|
|
if grep -q "^diff --git " "$1"
|
|
then
|
|
validate_patch "$1"
|
|
else
|
|
validate_cover_letter "$1"
|
|
fi &&
|
|
|
|
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
|
|
then
|
|
git config --unset-all sendemail.validateWorktree &&
|
|
trap 'git worktree remove -ff "$worktree"' EXIT &&
|
|
validate_series
|
|
fi
|