Home Home > GIT Browse > scripts
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.com>2018-10-18 11:47:40 +0900
committerBenjamin Poirier <bpoirier@suse.com>2019-09-04 09:19:03 +0900
commitc8faf99017c1937651b91c5171825362d039e956 (patch)
treebdf44fe40cb7d3cb87b6c6fa57dfb89cffdcd37c
parent668a353f3ab6b9434601d7b02c3a73e88bce06ec (diff)
Distribute git configuration in a versioned file
The kernel-source repository uses a script to set certain git config values which are meant to be distributed to all users. This mechanism makes it cumbersome to update these configuration values and eventually track their history. For security reasons, git does not have a way to implicitly include configuration values in a repository's content. However, we can explicitly include extra configuration values from a versioned file using the "include.path" configuration directive. Reuse the old mechanism to add this directive (which should hopefully not need changes in the future) and include the actual configuration values of interest to all users in a separate file. - extra-gitconfig: - scripts/install-git-hooks:
-rw-r--r--extra-gitconfig9
-rwxr-xr-xscripts/install-git-hooks40
2 files changed, 33 insertions, 16 deletions
diff --git a/extra-gitconfig b/extra-gitconfig
new file mode 100644
index 0000000000..823148ec92
--- /dev/null
+++ b/extra-gitconfig
@@ -0,0 +1,9 @@
+# This file is not automatically read by git. It must be included explicitly,
+# for instance via an include directive in the repository-specific
+# configuration file ($GIT_DIR/config). That directive should be added
+# automatically by scripts/install-git-hooks.
+[merge "rpm-changes"]
+ name = *.changes merge driver
+ driver = scripts/rpm-changes-merge.pl %A %O %B
+[diff "symsets"]
+ textconv = scripts/list-symsets
diff --git a/scripts/install-git-hooks b/scripts/install-git-hooks
index 859f49987a..69bebc942f 100755
--- a/scripts/install-git-hooks
+++ b/scripts/install-git-hooks
@@ -89,9 +89,31 @@ clean_attributes()
fi
}
+clean_config()
+{
+ # Previous versions of this file set configuration values meant to be
+ # distributed with the repository into the repository-specific
+ # configuration file (.git/config). Currently, configuration values are set
+ # in a versioned file (extra-gitconfig) which is included from the
+ # repository-specific config. Check if the old scheme is in place and
+ # update it.
+ if ! git config --local --get "include.path" >/dev/null || \
+ ! git config --local --get-all "include.path" | \
+ grep -q "../extra-gitconfig"; then
+ if git config --local --get "merge.rpm-changes.name" >/dev/null; then
+ git config --local --remove_section "merge.rpm-changes"
+ fi
+ if git config --local --get "diff.symsets.textconv" >/dev/null; then
+ git config --local --remove_section "diff.symsets"
+ fi
+ git config --add "include.path" "../extra-gitconfig"
+ fi
+}
+
check_scripts()
{
clean_attributes
+ clean_config
test -x "$GIT_DIR"/hooks/pre-commit && \
is_eq "$GIT_DIR"/hooks/kernel-source-pre-commit scripts/git-pre-commit
@@ -115,18 +137,6 @@ install_scripts()
ln -sf "$dir"/git-pre-commit "$GIT_DIR"/hooks/kernel-source-pre-commit
}
-install_changes_merger()
-{
- git config merge.rpm-changes.name "*.changes merge driver"
- git config merge.rpm-changes.driver "scripts/rpm-changes-merge.pl %A %O %B"
-}
-
-install_symsets_textconv()
-{
- git config diff.symsets.textconv scripts/list-symsets
-}
-
-
case "$1" in
--check)
check_snippet && check_scripts
@@ -136,10 +146,8 @@ case "$1" in
echo "Installing git commit hooks."
install_snippet
install_scripts
- echo "Installing kernel-source.changes merge driver."
- install_changes_merger
- echo "Installing symsets diff viewer."
- install_symsets_textconv
+ echo "Installing git config include directive."
+ clean_config
;;
*)
echo "Usage: $0 [--check]" >&2