@@ -729,8 +729,8 @@ transform_todo_ids () {
729
729
# that do not have a SHA-1 at the beginning of $rest.
730
730
;;
731
731
* )
732
- sha1=$( git rev-parse --verify --quiet " $@ " ${rest%% * } ) &&
733
- rest=" $sha1 ${rest#* } "
732
+ sha1=$( git rev-parse --verify --quiet " $@ " ${rest%% [ ] * } ) &&
733
+ rest=" $sha1 ${rest#* [ ] } "
734
734
;;
735
735
esac
736
736
printf ' %s\n' " $command ${rest: + } $rest "
@@ -857,7 +857,8 @@ add_exec_commands () {
857
857
# Check if the SHA-1 passed as an argument is a
858
858
# correct one, if not then print $2 in "$todo".badsha
859
859
# $1: the SHA-1 to test
860
- # $2: the line to display if incorrect SHA-1
860
+ # $2: the line number of the input
861
+ # $3: the input filename
861
862
check_commit_sha () {
862
863
badsha=0
863
864
if test -z $1
@@ -873,9 +874,10 @@ check_commit_sha () {
873
874
874
875
if test $badsha -ne 0
875
876
then
877
+ line=" $( sed -n -e " ${2} p" " $3 " ) "
876
878
warn " Warning: the SHA-1 is missing or isn't" \
877
879
" a commit in the following line:"
878
- warn " - $2 "
880
+ warn " - $line "
879
881
warn
880
882
fi
881
883
@@ -886,37 +888,31 @@ check_commit_sha () {
886
888
# from the todolist in stdin
887
889
check_bad_cmd_and_sha () {
888
890
retval=0
889
- git stripspace --strip-comments |
890
- (
891
- while read -r line
892
- do
893
- IFS=' '
894
- set -- $line
895
- command=$1
896
- sha1=$2
897
-
898
- case $command in
899
- ' ' |noop|x|" exec" )
900
- # Doesn't expect a SHA-1
901
- ;;
902
- pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
903
- if ! check_commit_sha $sha1 " $line "
904
- then
905
- retval=1
906
- fi
907
- ;;
908
- * )
909
- warn " Warning: the command isn't recognized" \
910
- " in the following line:"
911
- warn " - $line "
912
- warn
891
+ lineno=0
892
+ while read -r command rest
893
+ do
894
+ lineno=$(( $lineno + 1 ))
895
+ case $command in
896
+ " $comment_char " * |' ' |noop|x|exec)
897
+ # Doesn't expect a SHA-1
898
+ ;;
899
+ pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
900
+ if ! check_commit_sha " ${rest%% [ ]* } " " $lineno " " $1 "
901
+ then
913
902
retval=1
914
- ;;
915
- esac
916
- done
917
-
918
- return $retval
919
- )
903
+ fi
904
+ ;;
905
+ * )
906
+ line=" $( sed -n -e " ${lineno} p" " $1 " ) "
907
+ warn " Warning: the command isn't recognized" \
908
+ " in the following line:"
909
+ warn " - $line "
910
+ warn
911
+ retval=1
912
+ ;;
913
+ esac
914
+ done < " $1 "
915
+ return $retval
920
916
}
921
917
922
918
# Print the list of the SHA-1 of the commits
@@ -1010,7 +1006,7 @@ check_todo_list () {
1010
1006
;;
1011
1007
esac
1012
1008
1013
- if ! check_bad_cmd_and_sha < " $todo "
1009
+ if ! check_bad_cmd_and_sha " $todo "
1014
1010
then
1015
1011
raise_error=t
1016
1012
fi
0 commit comments