Gracefully handle committing to empty repo

Previously, when attempting to use `overcommit` with an empty repo (i.e.
you were trying to commit the "Initial commit"), you would get an error
saying that `HEAD` was not defined.

This is caused by the fact that `HEAD` is only set once the branch has
at least one commit.

Solve by explicitly checking for this case and only stashing when we are
not the initial commit (since the initial commit will always only have
staged files, no "modified" files).

This also modifies the implementation of `any_changes?` in the
`PreCommit` hook context to use `git status` instead of `git diff`,
which prevents it from blowing up in the initial commit situation.

Change-Id: Ia5fe7cbe373938f7c4f3fa7c6ae40641b5c40169
Reviewed-on: http://gerrit.causes.com/40324
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Add support for graceful exit from Ctrl-C interrupt

Change-Id: I0e7fe171aab20a745dac9ef2660b99c70077f627
Reviewed-on: http://gerrit.causes.com/40325
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Improve robustness of signal handling

The previous implementation was technically still vulnerable to problems
since the signal could be received in between the call to
`@context.setup_environment` and `run_hooks`, which could leave the
system in a weird state.

Solve the problem by creating a utility class `InterruptHandler` which
provides an interface for enabling/disabling signal handling so the
`HookRunner` can have more control over when/how the signal is handled.

Change-Id: I411433169ea1bf23f6f6426e67996d5daf7ae394
Reviewed-on: http://gerrit.causes.com/40326
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>