# This should be a git tree that contains *only* Linus' tree
Linus_tree="${HOME}/kernels/linus.git"
-split_re='^([[:xdigit:]]+)[[:space:]]+(.*)$'
+
+split_re='^([Cc][Oo][Mm][Mm][Ii][Tt])?[[:space:]]*([[:xdigit:]]{5,})([[:space:]]*)(.*)$'
nl=$'\n'
+tab=$'\t'
# Strip the leading and training spaces from a string
strip_spaces()
grep -i '^[[:space:]]*Fixes:')
while read -r fline; do
- f=$(echo "$fline" | sed 's/^[[:space:]]*Fixes:[[:space:]]*//i')
+ [[ "$fline" =~ ^[[:space:]]*[Ff][Ii][Xx][Ee][Ss]:[[:space:]]*(.*)$ ]]
+ f="${BASH_REMATCH[1]}"
fixes_msg="Fixes tag
$fline
sha=
subject=
msg=
- [[ "$f" =~ $split_re ]]
- sha="${BASH_REMATCH[1]}"
- subject="${BASH_REMATCH[2]}"
-
- if [ -z "$sha" ]; then
+ 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="${msg:+${msg}${nl}} - missing subject"
+ elif [ -z "$spaces" ]; then
+ msg="${msg:+${msg}${nl}} - missing space between the SHA1 and the subject"
+ fi
+ else
printf '%s%s - %s\n' "$commit_msg" "$fixes_msg" 'No SHA1 recognised'
commit_msg=''
continue
fi
if [ "${#sha}" -lt 12 ]; then
- msg="${msg:+${msg}${nl}} - SHA1 should be at least 12 digits long"
+ msg="${msg:+${msg}${nl}} - SHA1 should be at least 12 digits long${nl} Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11${nl} or later) just making sure it is not set (or set to \"auto\")."
fi
# reduce the subject to the part between () if there
if [[ "$subject" =~ ^\((.*)\) ]]; then
target_subject=$(strip_spaces "$target_subject")
if [ "$subject" != "${target_subject:0:${#subject}}" ]; then
- msg="${msg:+${msg}${nl}} - Subject does not match target commit subject"
+ msg="${msg:+${msg}${nl}} - Subject does not match target commit subject${nl} Just use${nl}${tab}git log -1 --format='Fixes: %h (\"%s\")'"
fi
lsha=$(cd "$Linus_tree" && git rev-parse -q --verify "$sha")
if [ -z "$lsha" ]; then