Thread (2 messages) 2 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH RFC] add: Do not open editor if patch is empty

From: Alexander Kuleshov <hidden>
Date: 2016-06-15 23:04:33
Subsystem: the rest · Maintainer: Linus Torvalds

If we'll run 'git add -e <path>' on a path which has no
difference with the current index, empty editor will open. This
patch prevents this behaviour and checks that patch is not empty
before an editor with patch will be opened.

Signed-off-by: Alexander Kuleshov <redacted>
---
 builtin/add.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index ee370b0..4fc6b13 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -209,13 +209,13 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	if (run_diff_files(&rev, 0))
 		die(_("Could not write patch"));
 
-	launch_editor(file, NULL, NULL);
-
 	if (stat(file, &st))
 		die_errno(_("Could not stat '%s'"), file);
 	if (!st.st_size)
 		die(_("Empty patch. Aborted."));
 
+	launch_editor(file, NULL, NULL);
+
 	child.git_cmd = 1;
 	child.argv = apply_argv;
 	if (run_command(&child))
-- 
2.3.3.611.g09038fc.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help