git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Deskin Miller <deskinm@umich.edu>
Date
Feb 12, 2009, 05:19 UTC
Message-ID
<1234415981-22789-1-git-send-email-deskinm@umich.edu>

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(-)
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
Message 1 of 1 in “add -i: revisit hunk on editor failure”
  1. add -i: revisit hunk on editor failureDeskin Miller, Feb 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.