Prototype pre-commit and commit-msg hook scripts

These hooks perform some basic commit-time checks to keep history clean.
Teach Git to ignore sample hooks
pre-commit: Validate user.name and user.email
commit-msg: Preserve bad message for user to fix

Store a backup copy of the input message.  Remove the backup only on
success.  On failure, tell the user how to use and edit the message
without having to enter it from scratch.
pre-commit: Reject leading TABs

Our style guidelines do not permit indentation by TABs.
pre-commit: Workaround shell syntax limitations

Commit "Reject leading TABs" added use of shell syntax of the form

  $(case "..." in
     a) ... ;;
    esac)

Some shell implementations fail to recognize that the ')' in the case
label is not the end of the '$(' expression.  Work around the problem
by moving the case block into a separate function outside the '$()'
expression.
commit-msg: Exclude diff during "git commit -v"

Stop processing the commit message text at a "diff --git" line.  Such
lines occur when the user commits with the "-v" option.  We should not
check the patch content; it will be stripped by Git anyway.
pre-commit: Check file modes

Check new files and files whose mode changes to verify that each file
mode matches the content of the file.  The mode of a file must be
executable if and only if the file looks executable (name ends in a
Windows executable extension or content starts with a shebang line).
pre-commit: Rename looks_executable -> mode_looks_exe

Keep all mode-related check helpers in the "mode_" namespace.
pre-commit: Check file sizes

Check blob and tree object sizes to prevent large objects from entering
the repository.  The default limit is 1024 KiB, but it can be set with

  git config hooks.MaxObjectKiB $KiB

locally, or disabled by using 0 KiB.
pre-commit: Check file size always

Fix logic to call check_size for all updated index entries, not just
those whose mode changed.
commit-msg: Reject leading or trailing space on first line
Reference bash explicitly in shebang lines

On Solaris, where /bin/sh is actually sh, not bash, some expressions
like $() are not supported.  Git's own scripts on this machine are
configured to use "#!/bin/bash".  Change our shebang line to

  #!/usr/bin/env bash

which should work almost everywhere.
pre-commit: Check submodules staged with other changes

Since Git does not automatically update submodule checkouts when
checking out a new version in the work tree, it is common to have
locally modified submodule references.  Therefore it is easy to stage
such modifications with other changes by accident, especially with
commands like "git add -u" or "git commit -a".  The result is almost
always wrong if the submodule change is not intended.

Prevent such mistakes by requiring an extra step to commit submodule
link updates with other changes.  When this case is detected, print a
message describing the situation and provide cut-and-paste instructions
to proceed.
pre-commit: Allow .gitattributes to limit file size

Check for a 'hooks.MaxObjectKiB' attribute to set the limit of specific
files or patterns.
Remove out-dated instructions
Add Apache 2.0 LICENSE and copyright NOTICE
pre-commit: Approximate Git 1.7.2 tab-in-indent check

Check for leading TABs in files marked with the whitespace=tab-in-indent
attribute instead of hard-coding a list of file extensions.
Add commit-msg hook from Gerrit Code Review

Currently the hook is unused but later we will invoke it from the main
commit-msg hook.
gerrit/commit-msg: Reference bash in shebang line

This script uses bashisms like $() so we need a real bash.