Skip to content

Commit

Permalink
rebase -i: more graceful handling of invalid commands
Browse files Browse the repository at this point in the history
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 <jk@jk.gs>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
jast authored and gitster committed Oct 28, 2009
1 parent a29aa47 commit f1be316
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-rebase--interactive.sh
Expand Up @@ -408,7 +408,12 @@ do_next () {
;;
*)
warn "Unknown command: $command $sha1 $rest"
die_with_patch $sha1 "Please fix this in the file $TODO."
if git rev-parse --verify -q "$sha1" >/dev/null
then
die_with_patch $sha1 "Please fix this in the file $TODO."
else
die "Please fix this in the file $TODO."
fi
;;
esac
test -s "$TODO" && return
Expand Down

0 comments on commit f1be316

Please sign in to comment.