From: Andreas Dilger Date: Wed, 17 Feb 2016 00:02:28 +0000 (-0700) Subject: LU-3434 misc: style check whole patch when rebasing X-Git-Tag: 2.8.55~53 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=af437d84a3be785f25aaf4ccad6e1313ffa3cde1;hp=b1c8f737c8bbe862930cc0f174bd478ba42f7ffe LU-3434 misc: style check whole patch when rebasing When rebasing a patch, style check the whole patch instead of just the part that has changed. Otherwise, if the patch was previously developed on a system without the prepare-commit-msg hook it will not be properly checked before submission, possibly incurring the ire of HPDD Checkpatch. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I603577450d3524ab7bb3d4a4d0bdf8ce463ebbe5 Reviewed-on: http://review.whamcloud.com/8644 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Oleg Drokin --- diff --git a/contrib/git-hooks/prepare-commit-msg b/contrib/git-hooks/prepare-commit-msg index c0cc1a5..e4a94c9 100755 --- a/contrib/git-hooks/prepare-commit-msg +++ b/contrib/git-hooks/prepare-commit-msg @@ -31,7 +31,10 @@ grep -qs "^$SIGNOFF" "$1" || echo "# $SIGNOFF" >> "$1" if [ -x "$CHECKPATCH" ]; then echo "" >> "$1" echo "#" >> "$1" - git diff --cached | $CHECKPATCH $CHECKPATCH_OPTS - | sed -e 's/^/# /' >> "$1" + [ -d ".git/rebase-apply" -o -d ".git/rebase-merge" ] && + DIFFOPT="HEAD" || DIFFOPT="--cached" + git diff $DIFFOPT | $CHECKPATCH $CHECKPATCH_OPTS - | + sed -e 's/^/# /' >> "$1" fi # Cause Vim to wrap text at 70 columns to match commit message style.