HAS_BODY=false
HAS_SIGNOFF=false
HAS_CHANGEID=false
+ NEEDS_FIRST_LINE=true
IS_WRAPPING_UP=false
error "invalid signoff section line"
return
}
- if (( NUM == 1 )); then
+ if ${NEEDS_FIRST_LINE}; then
HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A")
if (( ${#HAS_JIRA_COMPONENT} == 0 )); then
else
HAS_SUMMARY=true
fi
+ NEEDS_FIRST_LINE=false
elif (( ${#LINE} > WIDTH_REG )); then
error "has line longer than $WIDTH_REG columns."
"")
HAS_LAST_BLANK=true
- $IS_WRAPPING_UP && continue
+
+ # Do not emit blank lines before summary line or after
+ # the tag lines have begun.
+ #
+ ${NEEDS_FIRST_LINE} || ${IS_WRAPPING_UP} && continue
;;
\#*)
*)
if [[ "$LINE" =~ ^($INNOCUOUS): ]]; then
do_innocuous
+
elif [[ "$LINE" =~ ^[A-Za-z0-9_-]+-bug-id: ]]; then
+ # Allow arbitrary external bug identifiers for tracking.
+ #
ck_wrapup
+
else
- # Allow arbitrary external bug identifiers for tracking.
- # I can't seem to find a pattern for the "case" that
- # checks for "*-bug-id", so this is checked here.
do_default_line
fi
;;
--- /dev/null
+# On branch master
+# Your branch is ahead of 'origin/master' by 1 commit.
+#
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# modified: contrib/git-hooks/commit-msg
+# new file: contrib/git-hooks/tests/commit.ok_comment
+# modified: contrib/git-hooks/tests/test-commit-msg.sh
+
+LU-3568 contrib: ignore initial comments
+
+Sometimes, git likes to insert "git status" commentary
+at the top of an auto-generated commit message starter
+file. If the committer carelessly neglects to remove
+the stuff, the script thinks the message has a missing
+commit summary line.
+
+* contrib/tests/test-commit-msg.sh: pass through xtrace setting
+* contrib/tests/commit.ok_commit: This message with cruft
+* contrib/commit-msg: use a flag instead of a line number to see
+ if we still need to process the summary line.
+
+Signed-off-by: Bruce Korb <bruce_korb@xyratex.com>
+Reviewed-by: Cheng Shao <cheng_shao@xyratex.com>
+Xyratex-bug-id: MRP-1160
+Change-Id: I46e2951f2e28cbbf53bf2e96e420ddcea7c0d991
+
progdir=$(\cd $(dirname $0) >/dev/null && pwd)
die() {
- exec 1>&2
- echo "$program fatal error: $*"
- exit 1
-}
+ echo "$program fatal error: $*"
+ exit 1
+} 1>&2
TEMPFILE=$(mktemp ${TMPDIR:-.}/commit-XXXXXX)
test -f "$TEMPFILE" || die "mktemp fails"
trap "rm -f $TEMPFILE COMMIT*" EXIT
+# Pass through xtrace setting to commit-msg script
+#
+SHELL=${SHELL:-sh}
+shopt -qo xtrace && SHELL+=' -x'
+
test $# -eq 0 && set -- ${progdir}/commit.*
export FAIL=""
readonly report_fmt='%-20s %s\n'
for f; do
- case "$f" in
+ case "$f" in
( *.orig | *.rej ) continue ;;
- esac
-
- cp $f $TEMPFILE
- results=$(exec 2>&1 ${SHELL:-sh} $progdir/../commit-msg $TEMPFILE)
- case $'\n'"$results" in
- ( *$'\nerror:'* ) OK=0 ;;
- ( * ) OK=1 ;;
- esac
-
- f=$(basename $f)
- case $OK${f#*commit.} in
- 1ok*) printf "$report_fmt" $f: "PASS (was allowed)" ;;
- 0ok*) printf "$report_fmt" $f: "FAIL (not allowed)"; FAIL="$FAIL $f";;
- 0*) printf "$report_fmt" $f: "PASS (found error)" ;;
- *) printf "$report_fmt" $f: "FAIL (no error)" ; FAIL="$FAIL $f";;
- esac
+ esac
+
+ cp $f $TEMPFILE
+ results=$(exec 2>&1 ${SHELL} $progdir/../commit-msg $TEMPFILE)
+ case $'\n'"$results" in
+ ( *$'\nerror:'* ) OK=0 ;;
+ ( * ) OK=1 ;;
+ esac
+
+ f=$(basename $f)
+ case $OK${f#*commit.} in
+ 1ok*) printf "$report_fmt" $f: "PASS (was allowed)" ;;
+ 0ok*) printf "$report_fmt" $f: "FAIL (not allowed)"; FAIL="$FAIL $f";;
+ 0*) printf "$report_fmt" $f: "PASS (found error)" ;;
+ *) printf "$report_fmt" $f: "FAIL (no error)" ; FAIL="$FAIL $f";;
+ esac
done
if [ -n "$FAIL" ]; then
echo -e "\nerror: commit-msg test(s) failed!" 1>&2
- echo " $FAIL"
+ echo " $FAIL"
fi
rm -f $TEMPFILE $TEMPFILE.*
+
+## Local Variables:
+## Mode: shell-script
+## sh-basic-offset: 8
+## sh-indent-after-do: 8
+## sh-indentation: 8
+## sh-indent-for-case-label: 0
+## sh-indent-for-case-alt: 8
+## indent-tabs-mode: t
+## End: