# This should be a git tree that contains *only* Linus' tree
Linus_tree="${HOME}/kernels/linus.git"
-split_re1='^([[:xdigit:]]{5,})[[:space:]]+(.*)$'
-split_re2='^([[:xdigit:]]{5,})[[:space:]]*(.*)$'
-split_re3='^([Cc][Oo][Mm][Mm][Ii][Tt])[[:space:]]*([[:xdigit:]]{5,})[[:space:]]*(.*)$'
+
+split_re='^([Cc][Oo][Mm][Mm][Ii][Tt])?[[:space:]]*([[:xdigit:]]{5,})([[:space:]]*)(.*)$'
nl=$'\n'
# Strip the leading and training spaces from a string
sha=
subject=
msg=
- if [[ "$f" =~ $split_re1 ]]; then
- sha="${BASH_REMATCH[1]}"
- subject="${BASH_REMATCH[2]}"
- elif [[ "$f" =~ $split_re2 ]]; then
- sha="${BASH_REMATCH[1]}"
- subject="${BASH_REMATCH[2]}"
- msg="${msg:+${msg}${nl}} - "
+ if [[ "$f" =~ $split_re ]]; then
+ first="${BASH_REMATCH[1]}"
+ sha="${BASH_REMATCH[2]}"
+ spaces="${BASH_REMATCH[3]}"
+ subject="${BASH_REMATCH[4]}"
+ if [ "$first" ]; then
+ msg="${msg:+${msg}${nl}} - leading word '$first' unexpected"
+ fi
if [ -z "$subject" ]; then
- msg+="missing subject"
- else
- msg+="missing space between the SHA1 and the subject"
+ msg="${msg:+${msg}${nl}} - missing subject"
+ elif [ -z "$spaces" ]; then
+ msg="${msg:+${msg}${nl}} - missing space between the SHA1 and the subject"
fi
- elif [[ "$f" =~ $split_re3 ]]; then
- sha="${BASH_REMATCH[2]}"
- subject="${BASH_REMATCH[3]}"
- msg="${msg:+${msg}${nl}} - leading word '${BASH_REMATCH[1]}' unexpected"
- fi
- if [ -z "$sha" ]; then
+ else
printf '%s%s - %s\n' "$commit_msg" "$fixes_msg" 'No SHA1 recognised'
commit_msg=''
continue