Skip to content

Commit f1be316

Browse files
jastgitster
authored andcommitted
rebase -i: more graceful handling of invalid commands
Currently, when there is an invalid command, the rest of the line is still treated as if the command had been valid, i.e. rebase -i attempts to produce a patch, using the next argument as a SHA1 name. If there is no next argument or an invalid one, very confusing error messages appear (the line was '.'; path to git-rebase-todo substituted): Unknown command: . fatal: ambiguous argument 'Please fix this in the file $somefile.': unknown revision or path not in the working tree. Use '--' to separate paths from revisions fatal: Not a valid object name Please fix this in the file $somefile. fatal: bad revision 'Please fix this in the file $somefile.' Instead, verify the validity of the remaining line and error out earlier if necessary. Signed-off-by: Jan Krüger <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a29aa47 commit f1be316

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-rebase--interactive.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,12 @@ do_next () {
408408
;;
409409
*)
410410
warn "Unknown command: $command $sha1 $rest"
411-
die_with_patch $sha1 "Please fix this in the file $TODO."
411+
if git rev-parse --verify -q "$sha1" >/dev/null
412+
then
413+
die_with_patch $sha1 "Please fix this in the file $TODO."
414+
else
415+
die "Please fix this in the file $TODO."
416+
fi
412417
;;
413418
esac
414419
test -s "$TODO" && return

0 commit comments

Comments
 (0)