function git_install_manpages() {
  for FF in man*; do
    install -vm 755 -d "$INSTALL_ROOT/usr/share/man/$FF"
    install -vm 644 $FF/* "$INSTALL_ROOT/usr/share/man/$FF"
  done
}

function git_install_htmldocs() {
  local GIT_HTML &&
  GIT_HTML="$INSTALL_ROOT/usr/share/doc/git/html" &&
  install -vm 755 -d $GIT_HTML &&
  install -vm 644 *.html $GIT_HTML &&
  install -vm 755 -d $GIT_HTML/howto &&
  install -vm 644 howto/* $GIT_HTML/howto
}

default_install &&

case $GIT_DOC in
  manpages)
    git_install_manpages
  ;;
  htmldocs)
    git_install_htmldocs
  ;;
  both)
    git_install_manpages &&
    git_install_htmldocs
  ;;
esac &&

if is_depends_enabled $SPELL bash-completion; then
  install -vm 755 -d "$INSTALL_ROOT/etc/bash_completion.d" &&

  install -vm 755 "$SOURCE_DIRECTORY/contrib/completion/git-completion.bash" \
                  "$INSTALL_ROOT/etc/bash_completion.d/git-completion"
fi &&

if is_depends_enabled $SPELL vim; then
  VIM_VERSION=$(installed_version vim)
  install -vm 644 "$SOURCE_DIRECTORY/contrib/vim/syntax/gitcommit.vim" \
                  "$INSTALL_ROOT/usr/share/vim/vim${VIM_VERSION/./}/syntax"
fi &&

if [[ $GIT_SYMLINKS == y ]]; then
  message "Creating needed symlinks..." &&

  for i in `ls "$INSTALL_ROOT/usr/libexec/git-core"`; do
    ln -vsf "$TRACK_ROOT/usr/libexec/git-core/$i" \
            "$INSTALL_ROOT/usr/bin/$i"
  done
fi
