diff options
author | Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> | 2018-01-13 17:05:31 +0000 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2018-01-18 19:29:10 +0000 |
commit | fda071ca7a17614a58c0812c28b14a417471b915 (patch) | |
tree | 39d6f08cba246f75e11d73e4e1ea02b90d9ed747 /util/gitconfig/gitconfig.sh | |
parent | f73914d1aa76e9d99fe8f815a955cf9acb1e8711 (diff) | |
download | coreboot-fda071ca7a17614a58c0812c28b14a417471b915.tar.xz |
util/gitconfig: Make gitconfig.sh support gitfile
The `gitconfig.sh` script installs hooks to the according directories
(for coreboot and its submodules). It has the `hooks` directory
hard-coded to be `.git/hooks`, which makes the installation fail when
coreboot itself is a submodule because then `.git` becomes a gitfile.
Replace hard-coded path handling using the according `git rev-parse`
calls.
Change-Id: I778e20be24bb27d0081c9e1c12883117d6d50347
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com>
Reviewed-on: https://review.coreboot.org/23253
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/gitconfig/gitconfig.sh')
-rwxr-xr-x | util/gitconfig/gitconfig.sh | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/util/gitconfig/gitconfig.sh b/util/gitconfig/gitconfig.sh index 2f96fd41f2..f456069f3f 100755 --- a/util/gitconfig/gitconfig.sh +++ b/util/gitconfig/gitconfig.sh @@ -15,26 +15,33 @@ ## GNU General Public License for more details. ## -if [ ! -d .git ]; then - echo "Error: Not in a git repository" +if ! { cdup="$(git rev-parse --show-cdup 2>/dev/null)" && [ -z "${cdup}" ]; } +then + echo "Error: Not in root of a git repository" exit 1 fi -mkdir -p .git/hooks +coreboot_hooks=$(git rev-parse --git-path hooks) +mkdir -p "${coreboot_hooks}" for hook in commit-msg pre-commit ; do - if [ util/gitconfig/$hook -nt .git/hooks/$hook ] || \ - [ ! -x .git/hooks/$hook ]; then - sed -e "s,%MAKE%,remake,g" util/gitconfig/$hook > .git/hooks/$hook - chmod +x .git/hooks/$hook + if [ util/gitconfig/${hook} -nt "${coreboot_hooks}/${hook}" ] \ + || [ ! -x "${coreboot_hooks}/${hook}" ] + then + sed -e "s,%MAKE%,remake,g" util/gitconfig/$hook \ + > "${coreboot_hooks}/${hook}" + chmod +x "${coreboot_hooks}/${hook}" fi done # Now set up the hooks for 3rdparty/ -for hooks in .git/modules/{3rdparty/blobs,libhwbase,libgfxinit}/hooks; do - if [ -d $hooks ]; then - if [ util/gitconfig/commit-msg -nt $hooks/commit-msg ] || \ - [ ! -x $hooks/commit-msg ]; then - sed -e "s,%MAKE%,remake,g" \ - util/gitconfig/commit-msg > $hooks/commit-msg - chmod +x $hooks/commit-msg +for submodule in 3rdparty/blobs libhwbase libgfxinit; do + hooks=$(git -C "$(git config --file .gitmodules --get \ + submodule.${submodule}.path)" rev-parse --git-path hooks) + if [ -d "${hooks}" ]; then + if [ util/gitconfig/commit-msg -nt "${hooks}/commit-msg" ] \ + || [ ! -x "${hooks}/commit-msg" ] + then + sed -e "s,%MAKE%,remake,g" util/gitconfig/commit-msg \ + > "${hooks}/commit-msg" + chmod +x "${hooks}/commit-msg" fi fi done |