Whamcloud - gitweb
LU-3434 misc: style check whole patch when rebasing 44/8644/6
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 17 Feb 2016 00:02:28 +0000 (17:02 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 14 Jun 2016 03:49:41 +0000 (03:49 +0000)
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 <andreas.dilger@intel.com>
Change-Id: I603577450d3524ab7bb3d4a4d0bdf8ce463ebbe5
Reviewed-on: http://review.whamcloud.com/8644
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
contrib/git-hooks/prepare-commit-msg

index c0cc1a5..e4a94c9 100755 (executable)
@@ -31,7 +31,10 @@ grep -qs "^$SIGNOFF" "$1" || echo "# $SIGNOFF" >> "$1"
 if [ -x "$CHECKPATCH" ]; then
        echo "" >> "$1"
        echo "#" >> "$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.
 fi
 
 # Cause Vim to wrap text at 70 columns to match commit message style.