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

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 26, 2015, 18:39 UTC
Message-ID
<CAPig+cTMWe4gnuMrx-aP1Zu+qr6UqmHFmJj2JoahtuxcDGLTQg@mail.gmail.com>
In-Reply-To
<1430067820-3349-1-git-send-email-kuleshovmail@gmail.com>

On Sun, Apr 26, 2015 at 1:03 PM, Alexander Kuleshov <kuleshovmail@gmail.com> wrote:

Show 23 quoted lines
> 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)

Show 5 quoted lines
>         child.git_cmd = 1;
>         child.argv = apply_argv;
>         if (run_command(&child))
> --
> 2.3.3.611.g09038fc.dirty
Previous: Alexander Kuleshov
Message 2 of 2 in “add: Do not open editor if patch is empty”
  1. add: Do not open editor if patch is emptyAlexander Kuleshov, Apr 26, 2015
  2. Eric SunshineApr 26, 2015

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.