Merge branch 'gr/rebase-i-drop-warn' into maint
"git rebase -i" had a minor regression recently, which stopped considering a line that begins with an indented '#' in its insn sheet not a comment, which is now fixed. * gr/rebase-i-drop-warn: rebase-i: loosen over-eager check_bad_cmd check rebase-i: explicitly accept tab as separator in commands
This commit is contained in:
commit
19d11d43fd
@ -729,8 +729,8 @@ transform_todo_ids () {
|
|||||||
# that do not have a SHA-1 at the beginning of $rest.
|
# that do not have a SHA-1 at the beginning of $rest.
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
sha1=$(git rev-parse --verify --quiet "$@" ${rest%% *}) &&
|
sha1=$(git rev-parse --verify --quiet "$@" ${rest%%[ ]*}) &&
|
||||||
rest="$sha1 ${rest#* }"
|
rest="$sha1 ${rest#*[ ]}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf '%s\n' "$command${rest:+ }$rest"
|
printf '%s\n' "$command${rest:+ }$rest"
|
||||||
@ -857,7 +857,8 @@ add_exec_commands () {
|
|||||||
# Check if the SHA-1 passed as an argument is a
|
# Check if the SHA-1 passed as an argument is a
|
||||||
# correct one, if not then print $2 in "$todo".badsha
|
# correct one, if not then print $2 in "$todo".badsha
|
||||||
# $1: the SHA-1 to test
|
# $1: the SHA-1 to test
|
||||||
# $2: the line to display if incorrect SHA-1
|
# $2: the line number of the input
|
||||||
|
# $3: the input filename
|
||||||
check_commit_sha () {
|
check_commit_sha () {
|
||||||
badsha=0
|
badsha=0
|
||||||
if test -z $1
|
if test -z $1
|
||||||
@ -873,9 +874,10 @@ check_commit_sha () {
|
|||||||
|
|
||||||
if test $badsha -ne 0
|
if test $badsha -ne 0
|
||||||
then
|
then
|
||||||
|
line="$(sed -n -e "${2}p" "$3")"
|
||||||
warn "Warning: the SHA-1 is missing or isn't" \
|
warn "Warning: the SHA-1 is missing or isn't" \
|
||||||
"a commit in the following line:"
|
"a commit in the following line:"
|
||||||
warn " - $2"
|
warn " - $line"
|
||||||
warn
|
warn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -886,37 +888,31 @@ check_commit_sha () {
|
|||||||
# from the todolist in stdin
|
# from the todolist in stdin
|
||||||
check_bad_cmd_and_sha () {
|
check_bad_cmd_and_sha () {
|
||||||
retval=0
|
retval=0
|
||||||
git stripspace --strip-comments |
|
lineno=0
|
||||||
(
|
while read -r command rest
|
||||||
while read -r line
|
do
|
||||||
do
|
lineno=$(( $lineno + 1 ))
|
||||||
IFS=' '
|
case $command in
|
||||||
set -- $line
|
"$comment_char"*|''|noop|x|exec)
|
||||||
command=$1
|
# Doesn't expect a SHA-1
|
||||||
sha1=$2
|
;;
|
||||||
|
pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
|
||||||
case $command in
|
if ! check_commit_sha "${rest%%[ ]*}" "$lineno" "$1"
|
||||||
''|noop|x|"exec")
|
then
|
||||||
# Doesn't expect a SHA-1
|
|
||||||
;;
|
|
||||||
pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
|
|
||||||
if ! check_commit_sha $sha1 "$line"
|
|
||||||
then
|
|
||||||
retval=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
warn "Warning: the command isn't recognized" \
|
|
||||||
"in the following line:"
|
|
||||||
warn " - $line"
|
|
||||||
warn
|
|
||||||
retval=1
|
retval=1
|
||||||
;;
|
fi
|
||||||
esac
|
;;
|
||||||
done
|
*)
|
||||||
|
line="$(sed -n -e "${lineno}p" "$1")"
|
||||||
return $retval
|
warn "Warning: the command isn't recognized" \
|
||||||
)
|
"in the following line:"
|
||||||
|
warn " - $line"
|
||||||
|
warn
|
||||||
|
retval=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done <"$1"
|
||||||
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print the list of the SHA-1 of the commits
|
# Print the list of the SHA-1 of the commits
|
||||||
@ -1010,7 +1006,7 @@ check_todo_list () {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if ! check_bad_cmd_and_sha <"$todo"
|
if ! check_bad_cmd_and_sha "$todo"
|
||||||
then
|
then
|
||||||
raise_error=t
|
raise_error=t
|
||||||
fi
|
fi
|
||||||
|
@ -1227,6 +1227,21 @@ test_expect_success 'static check of bad command' '
|
|||||||
test C = $(git cat-file commit HEAD^ | sed -ne \$p)
|
test C = $(git cat-file commit HEAD^ | sed -ne \$p)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'tabs and spaces are accepted in the todolist' '
|
||||||
|
rebase_setup_and_clean indented-comment &&
|
||||||
|
write_script add-indent.sh <<-\EOF &&
|
||||||
|
(
|
||||||
|
# Turn single spaces into space/tab mix
|
||||||
|
sed "1s/ / /g; 2s/ / /g; 3s/ / /g" "$1"
|
||||||
|
printf "\n\t# comment\n #more\n\t # comment\n"
|
||||||
|
) >$1.new
|
||||||
|
mv "$1.new" "$1"
|
||||||
|
EOF
|
||||||
|
test_set_editor "$(pwd)/add-indent.sh" &&
|
||||||
|
git rebase -i HEAD^^^ &&
|
||||||
|
test E = $(git cat-file commit HEAD | sed -ne \$p)
|
||||||
|
'
|
||||||
|
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
Warning: the SHA-1 is missing or isn't a commit in the following line:
|
Warning: the SHA-1 is missing or isn't a commit in the following line:
|
||||||
- edit XXXXXXX False commit
|
- edit XXXXXXX False commit
|
||||||
|
Loading…
Reference in New Issue
Block a user