* [PATCH RFC] add: Do not open editor if patch is empty
@ 2015-04-26 17:03 Alexander Kuleshov
2015-04-26 18:39 ` Eric Sunshine
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kuleshov @ 2015-04-26 17:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git@vger.kernel.org, Alexander Kuleshov
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 <kuleshovmail@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RFC] add: Do not open editor if patch is empty
2015-04-26 17:03 [PATCH RFC] add: Do not open editor if patch is empty Alexander Kuleshov
@ 2015-04-26 18:39 ` Eric Sunshine
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sunshine @ 2015-04-26 18:39 UTC (permalink / raw)
To: Alexander Kuleshov; +Cc: Junio C Hamano, git@vger.kernel.org
On Sun, Apr 26, 2015 at 1:03 PM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:
> 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 <kuleshovmail@gmail.com>
> ---
> 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);
But this breaks intended behavior[1] in which "git add -e" aborts with
message "Empty patch" if the user deletes everything from the patch
file in the editor.
[1]: c59cb03 (git-add: introduce --edit (to edit the diff vs. the
index), 2009-04-08)
> child.git_cmd = 1;
> child.argv = apply_argv;
> if (run_command(&child))
> --
> 2.3.3.611.g09038fc.dirty
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-26 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-26 17:03 [PATCH RFC] add: Do not open editor if patch is empty Alexander Kuleshov
2015-04-26 18:39 ` Eric Sunshine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).