Suppress duplicate submodule entries in commit messages
Suppress duplicate submodule entries in commit messages

Sometimes when rebasing or amending a commit involving a submodule
change duplicate entries would appear in the commit message. This was
because the prepare-commit-msg hook didn't know how to grok submodule
additions and removals; here is an example submodule deletion:

* vendor/plugins/facebooker 79a220c...0000000:

Note how it doesn't have the "(count)" field that normally precedes the
terminating colon, and it obviously doesn't have any commits detailed on
subsequent lines:

* vendor/plugins/facebooker 79a220c...0000000 (743):
 < Replace deprecated Kernel#returning with Object#tap

This commit teaches the hook to identify additions and removals, which
means that those lines get correctly removed before updated lines are
inserted, thus curing the duplicate problem.

Note that the example of this problem that I saw today, involving a
submodule deletion, looked like the line had been hand-edited anyway
(the string "dead" had been appended); this commit won't handle that
kind of case, because once you alter the format of the submodule
summary, all bets are off.

Related story:
  http://www.pivotaltracker.com/story/show/25871679 (fixed)
  ("Stop duplicate submodule entries from appearing in commit messages
    when amending/rebasing")

Change-Id: I1cf7697aeaa6eb2e7c5ca30a4990bcf9e217c7b0
Reviewed-on: https://gerrit.causes.com/3710
Tested-by: Greg Hurrell <79e2475f81a6317276bf7cbb3958b20d289b78df@causes.com>
Reviewed-by: Lann Martin <564fa7a717c51b612962ea128f146981a0e99d90@causes.com>

blech75/overcommit,TheSooth/overcommit,gnagel/overcommit,gnagel/overcommit,blech75/overcommit,oxocode/overcommit,TheSooth/overcommit,oxocode/overcommit