6 usage: $0 <original_branch> [commit_range]
8 Check that cherry pick commits are properly formatted/documented.
9 Differing patches are put in patches-new/ and patches-orig/
11 original_branch: the branch where the cherry-picked commits come from
12 commit_range : the commits to check (origin/master..HEAD if not specified)
15 (cherry picked from commit <hash>) (edited)
18 - rebases (unmodified code) are marked as
19 (cherry picked from commit <hash>) (rebased)
25 echo "Missing original branch"
34 COMMIT_RANGE
="origin/master..HEAD"
37 CHERY_PICK_DETECT
="cherry picked from commit "
39 NOT_CHERRY_PICKED
=`git log --invert-grep --grep "$CHERY_PICK_DETECT" --pretty=%h $COMMIT_RANGE`
40 if test -n "$NOT_CHERRY_PICKED"; then
41 echo "ERROR: some commits are not cherry-picked:"
42 git log
--invert-grep --grep "$CHERY_PICK_DETECT" --pretty=oneline
$COMMIT_RANGE
46 CHERRY_PICKED
=`git log --grep "$CHERY_PICK_DETECT" --pretty=%H $COMMIT_RANGE`
51 for l
in $CHERRY_PICKED; do
52 GIT_LOG
=`git log -n 1 $l~1..$l`
54 h
=`echo "$GIT_LOG" | grep "$CHERY_PICK_DETECT" | sed -e "s/cherry picked from commit//" -e "s/Edited and //" -e "s/(//" | cut -c6-45`
56 # Check that the cherry picked hash exist in the original branch
57 HASH_EXISTS
=`git merge-base --is-ancestor $h $ORIGINAL_BRANCH 2> /dev/null || echo FAIL`
58 if test -n "$HASH_EXISTS"; then
59 echo "Invalid Hash for:"
64 # Check the cherry picked commit has a Signed Off mark
65 SIGNED_OFF
=`echo "$GIT_LOG" | grep "Signed-off-by: "`
66 if test -z "$SIGNED_OFF"; then
67 echo "Missing signed off for:"
71 IS_MARKED_REBASED
=`echo "$GIT_LOG" | grep "(cherry picked from commit $h) (rebased)"`
72 IS_MARKED_EDITED
=`echo "$GIT_LOG" | grep "(cherry picked from commit $h) (edited)"`
74 git
diff --no-color --minimal --ignore-all-space $l~
1..
$l |
sed -e "/index /d" -e "s/@@ .*/@@/" > patches-new
/$h.
diff
75 git
diff --no-color --minimal --ignore-all-space $h~
1..
$h |
sed -e "/index /d" -e "s/@@ .*/@@/" > patches-orig
/$h.
diff
76 PATCH_DIFF
=`diff -t -w patches-new/$h.diff patches-orig/$h.diff | sed -e '/^> --- /d' -e '/^> +++ /d' -e '/^---/d' -e '/^> @@/d' -e '/^< @@/d' -e '/^[0-9]\+/d'`
77 if test -z "$PATCH_DIFF"; then
78 if test -n "$IS_MARKED_EDITED"; then
79 echo "Incorrectly marked edited: $(git log $l~1..$l --oneline)"
82 if test -n "$IS_MARKED_REBASED"; then
83 echo "Incorrectly marked rebased: $(git log $l~1..$l --oneline)"
86 rm -rf patches-new
/$h.
diff patches-orig
/$h.
diff
90 PATCH_DIFF2
=`echo "$PATCH_DIFF" | sed -e "/\(> -\|> +\| diff \)/!d" | sed -e "/> +$/d" -e "/> -$/d"`
92 if test -n "$IS_MARKED_REBASED"; then
93 if test -n "$PATCH_DIFF2"; then
94 echo "Edit marked as rebase: $(git log $l~1..$l)"
99 IS_EXPLAINED
=`echo "$GIT_LOG" | grep "rebased:"`
100 if test -z "$IS_EXPLAINED"; then
101 echo "Unexplained rebase: $(git log $l~1..$l)"
104 rm -rf patches-new
/$h.
diff patches-orig
/$h.
diff
107 if test -z "$PATCH_DIFF2"; then
108 echo "Rebase marked as edit: $(git log $l~1..$l)"
113 if test -z "$IS_MARKED_EDITED"; then
114 echo "Unmarked edit: $(git log $l~1..$l)"
117 IS_EXPLAINED
=`echo "$GIT_LOG" | grep "edited:"`
118 if test -z "$IS_EXPLAINED"; then
119 echo "Unexplained edit: $(git log $l~1..$l)"
122 rm -rf patches-new
/$h.
diff patches-orig
/$h.
diff