git: Show patch of the changes in commit message
The changes are only shown in the editor and do not land in the final commit message. For that setting the git-commit-last-msg function and the commit-msg hook had to be updated. The function is now a standalone function instead of anonymous and uses every line until the first comment in COMMIT_EDITMSG discarding the new information too. The hook breaks now when checking line lengths when the changes start since for some weird reason they are passed together with the rest of the message instead of being deleted like the comments.
This commit is contained in:
@@ -42,7 +42,13 @@ done
|
||||
BKP_IFS="$IFS"
|
||||
IFS='
|
||||
'
|
||||
# The -v flag or commit.verbose setting add the changes of the commit to the
|
||||
# bottom of the commit message. But when the changes contain lines longer than
|
||||
# 72 characters this hook will fail when not breaking the loop before the end
|
||||
# start of the patch.
|
||||
verbose_start_line="$(git diff --staged -u | head -1)"
|
||||
for line in $body; do
|
||||
[[ "$line" != "$verbose_start_line" ]] || break
|
||||
[[ ${#line} -le 72 ]] || die "Body lines too long. (<= 72)\n"
|
||||
done
|
||||
IFS="$BKP_IFS"
|
||||
|
||||
Reference in New Issue
Block a user