commit-msg: Do not insert Change-Id if the message is empty

git commit calls the commit-msg hook when the user creates an empty
message file in order to abort the commit process.  If the hook then
edits the file content and inserts a line, such as our Change-Id,
git takes this as a valid commit and creates it, rather than aborts.
Thus we need to test for the empty file case specially and avoid
creating a Change-Id line during it.

Change-Id: I84a6309ae91d04b489ba48587936bfa80ad04dc1
Signed-off-by: Shawn O. Pearce <sop@google.com>
1 file changed