threads / patch / 17737

patchadd -i: revisit hunk on editor failure

Subject: [PATCH] add -i: revisit hunk on editor failure

## tl;dr

One message between Feb 12, 2009 and Feb 12, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Deskin Miller· Feb 12, 2009, 05:19 UTC · lore

Similar to the behaviour for editing a commit message, let terminating the editor with a failure abort the current hunk edit and revisit the option selection for the hunk.

Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
I find it much easier to type :cq in vi than to read the helpful
message that's in the comments and then delete all the hunk lines.
Besides, I already learned how to abort a commit message this way.
Deskin Miller
 git-add--interactive.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Show changes to git-add--interactive.perl +4 −0
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 5f129a4..f7b0761 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -753,6 +753,10 @@ EOF
 		|| $ENV{VISUAL} || $ENV{EDITOR} || "vi";
 	system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
 
+	if ($? != 0) {
+		return undef;
+	}
+
 	open $fh, '<', $hunkfile
 		or die "failed to open hunk edit file for reading: " . $!;
 	my @newtext = grep { !/^#/ } <$fh>;
-- 
1.6.1.399.g0d272

← back to recent threads