Thread (12 messages) flat view 12 messages, 6 authors, 2016-06-15
DORMANTno replies REVIEWED: 1 (0M)

1 review trailer.

[PATCH v2] rebase -i: more graceful handling of invalid commands

From: Jan Krüger <hidden>
Date: 2016-06-15 22:47:37
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Acked-by: Johannes Schindelin <redacted>
---

Thomas Rast wrote:
I think you need s/sha/sha1/ here?
Of course. For some reason I forgot testing the code path where the
SHA1 is actually valid. Sorry about that.

Dscho's ACK lifted off
<http://article.gmane.org/gmane.comp.version-control.git/131341>.

 git-rebase--interactive.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a1879e3..fdd8eb6 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -416,7 +416,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
-- 
1.6.5.rc1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help