All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: "Git List" <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
	"Stefan Beller" <sbeller@google.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
	"Jeff King" <peff@peff.net>,
	"Karsten Blees" <karsten.blees@gmail.com>,
	"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
	"Christian Couder" <chriscool@tuxfamily.org>
Subject: Re: [PATCH v2 52/94] builtin/apply: read_patch_file() return -1 instead of die()ing
Date: Sun, 15 May 2016 21:56:30 -0400	[thread overview]
Message-ID: <CAPig+cQrLZiwZm34+hFZXPmFGVtyPCvCEv4TwsTeL__cfzuORA@mail.gmail.com> (raw)
In-Reply-To: <20160511131745.2914-53-chriscool@tuxfamily.org>

On Wed, May 11, 2016 at 9:17 AM, Christian Couder
<christian.couder@gmail.com> wrote:
> To libify `git apply` functionality we have to signal errors to the
> caller instead of die()ing. Let's do that by using error() instead
> of die()ing in read_patch_file().
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> diff --git a/builtin/apply.c b/builtin/apply.c
> @@ -445,10 +445,10 @@ static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
> -static void read_patch_file(struct strbuf *sb, int fd)
> +static int read_patch_file(struct strbuf *sb, int fd)
>  {
>         if (strbuf_read(sb, fd, 0) < 0)
> -               die_errno("git apply: failed to read");
> +               return error("git apply: failed to read: %s", strerror(errno));

When Duy's nd/error-errno series, which is in 'next', gets promoted to
'master', then this could become:

    return error_errno(...);

>         /*
>          * Make sure that we have some slop in the buffer
> @@ -457,6 +457,7 @@ static void read_patch_file(struct strbuf *sb, int fd)
>          */
>         strbuf_grow(sb, SLOP);
>         memset(sb->buf + sb->len, 0, SLOP);
> +       return 0;
>  }

  reply	other threads:[~2016-05-16  1:58 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 13:16 [PATCH v2 00/94] libify apply and use lib in am Christian Couder
2016-05-11 13:16 ` [PATCH v2 01/94] builtin/apply: make gitdiff_verify_name() return void Christian Couder
2016-05-12 19:06   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 02/94] builtin/apply: avoid parameter shadowing 'p_value' global Christian Couder
2016-05-12 19:09   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 03/94] builtin/apply: avoid parameter shadowing 'linenr' global Christian Couder
2016-05-12 19:11   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 04/94] builtin/apply: avoid local variable shadowing 'len' parameter Christian Couder
2016-05-11 13:16 ` [PATCH v2 05/94] builtin/apply: extract line_by_line_fuzzy_match() from match_fragment() Christian Couder
2016-05-12 19:20   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 06/94] builtin/apply: move 'options' variable into cmd_apply() Christian Couder
2016-05-11 13:16 ` [PATCH v2 07/94] builtin/apply: move 'read_stdin' global " Christian Couder
2016-05-11 13:16 ` [PATCH v2 08/94] builtin/apply: introduce 'struct apply_state' to start libifying Christian Couder
2016-05-11 13:16 ` [PATCH v2 09/94] builtin/apply: move 'state' init into init_apply_state() Christian Couder
2016-05-12 19:25   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 10/94] builtin/apply: move 'unidiff_zero' global into 'struct apply_state' Christian Couder
2016-05-12 19:28   ` Junio C Hamano
2016-05-12 20:18     ` Christian Couder
2016-05-11 13:16 ` [PATCH v2 11/94] builtin/apply: move 'check' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 12/94] builtin/apply: move 'check_index' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 13/94] builtin/apply: move 'apply_in_reverse' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 14/94] builtin/apply: move 'apply_with_reject' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 15/94] builtin/apply: move 'apply_verbosely' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 16/94] builtin/apply: move 'update_index' " Christian Couder
2016-05-12 19:31   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 17/94] builtin/apply: move 'allow_overlap' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 18/94] builtin/apply: move 'cached' " Christian Couder
2016-05-12 19:33   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 19/94] builtin/apply: move 'diffstat' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 20/94] builtin/apply: move 'numstat' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 21/94] builtin/apply: move 'summary' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 22/94] builtin/apply: move 'threeway' " Christian Couder
2016-05-12 19:41   ` Junio C Hamano
2016-05-12 20:26     ` Christian Couder
2016-05-12 21:21       ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 23/94] builtin/apply: move 'no_add' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 24/94] builtin/apply: move 'unsafe_paths' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 25/94] builtin/apply: move 'line_termination' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 26/94] builtin/apply: move 'fake_ancestor' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 27/94] builtin/apply: move 'p_context' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 28/94] builtin/apply: move 'apply' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 29/94] builtin/apply: move 'patch_input_file' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 30/94] builtin/apply: move 'limit_by_name' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 31/94] builtin/apply: move 'has_include' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 32/94] builtin/apply: move 'p_value' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 33/94] builtin/apply: move 'p_value_known' " Christian Couder
2016-05-12 19:43   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 34/94] builtin/apply: move 'root' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 35/94] builtin/apply: move 'whitespace_error' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 36/94] builtin/apply: move 'whitespace_option' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 37/94] builtin/apply: remove whitespace_option arg from set_default_whitespace_mode() Christian Couder
2016-05-11 13:16 ` [PATCH v2 38/94] builtin/apply: move 'squelch_whitespace_errors' into 'struct apply_state' Christian Couder
2016-05-11 13:16 ` [PATCH v2 39/94] builtin/apply: move 'applied_after_fixing_ws' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 40/94] builtin/apply: move 'ws_error_action' " Christian Couder
2016-05-12 19:48   ` Junio C Hamano
2016-05-11 13:16 ` [PATCH v2 41/94] builtin/apply: move 'ws_ignore_action' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 42/94] builtin/apply: move 'max_change' and 'max_len' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 43/94] builtin/apply: move 'state_linenr' global " Christian Couder
2016-05-11 13:16 ` [PATCH v2 44/94] builtin/apply: move 'fn_table' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 45/94] builtin/apply: move 'symlink_changes' " Christian Couder
2016-05-11 13:16 ` [PATCH v2 46/94] builtin/apply: move 'state' check into check_apply_state() Christian Couder
2016-05-11 13:16 ` [PATCH v2 47/94] builtin/apply: move applying patches into apply_all_patches() Christian Couder
2016-05-11 13:16 ` [PATCH v2 48/94] builtin/apply: rename 'prefix_' parameter to 'prefix' Christian Couder
2016-05-12 19:56   ` Junio C Hamano
2016-05-12 20:43     ` Junio C Hamano
2016-05-13 19:45       ` Christian Couder
2016-05-14 18:27         ` Junio C Hamano
2016-05-24  8:24           ` Christian Couder
2016-05-13 19:42     ` Christian Couder
2016-05-24  8:15       ` Christian Couder
2016-05-11 13:17 ` [PATCH v2 49/94] builtin/apply: move 'lock_file' global into 'struct apply_state' Christian Couder
2016-05-11 13:17 ` [PATCH v2 50/94] builtin/apply: move 'newfd' " Christian Couder
2016-05-11 13:17 ` [PATCH v2 51/94] builtin/apply: make apply_patch() return -1 instead of die()ing Christian Couder
2016-05-11 13:17 ` [PATCH v2 52/94] builtin/apply: read_patch_file() " Christian Couder
2016-05-16  1:56   ` Eric Sunshine [this message]
2016-05-16 17:19     ` Christian Couder
2016-05-11 13:17 ` [PATCH v2 53/94] builtin/apply: make find_header() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 54/94] builtin/apply: make parse_chunk() return a negative integer on error Christian Couder
2016-05-16  3:04   ` Eric Sunshine
2016-05-16 18:19     ` Christian Couder
2016-06-08 15:14     ` Christian Couder
2016-05-11 13:17 ` [PATCH v2 55/94] builtin/apply: make parse_single_patch() return -1 " Christian Couder
2016-05-11 13:17 ` [PATCH v2 56/94] apply: move 'struct apply_state' to apply.h Christian Couder
2016-05-16  3:10   ` Eric Sunshine
2016-05-16 16:03     ` Junio C Hamano
2016-06-08 15:25       ` Christian Couder
2016-05-11 13:17 ` [PATCH v2 57/94] builtin/apply: make parse_whitespace_option() return -1 instead of die()ing Christian Couder
2016-05-11 13:17 ` [PATCH v2 58/94] builtin/apply: make parse_ignorewhitespace_option() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 59/94] builtin/apply: move init_apply_state() to apply.c Christian Couder
2016-05-16  3:16   ` Eric Sunshine
2016-05-11 13:17 ` [PATCH v2 60/94] apply: make init_apply_state() return -1 instead of exit()ing Christian Couder
2016-05-16  3:37   ` Eric Sunshine
2016-05-11 13:17 ` [PATCH v2 61/94] builtin/apply: make check_apply_state() return -1 instead of die()ing Christian Couder
2016-05-11 13:17 ` [PATCH v2 62/94] builtin/apply: move check_apply_state() to apply.c Christian Couder
2016-05-11 13:17 ` [PATCH v2 63/94] builtin/apply: make apply_all_patches() return -1 on error Christian Couder
2016-05-16  3:44   ` Eric Sunshine
2016-06-08 16:37     ` Christian Couder
2016-06-08 17:44       ` Eric Sunshine
2016-06-09 22:01         ` Christian Couder
2016-05-11 13:17 ` [PATCH v2 64/94] builtin/apply: make parse_traditional_patch() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 65/94] builtin/apply: make gitdiff_*() return 1 at end of header Christian Couder
2016-05-11 13:17 ` [PATCH v2 66/94] builtin/apply: make gitdiff_*() return -1 on error Christian Couder
2016-05-11 13:17 ` [PATCH v2 67/94] builtin/apply: change die_on_unsafe_path() to check_unsafe_path() Christian Couder
2016-05-11 13:17 ` [PATCH v2 68/94] builtin/apply: make build_fake_ancestor() return -1 on error Christian Couder
2016-05-11 13:17 ` [PATCH v2 69/94] builtin/apply: make remove_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 70/94] builtin/apply: make add_conflicted_stages_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 71/94] builtin/apply: make add_index_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 72/94] builtin/apply: make create_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 73/94] builtin/apply: make write_out_one_result() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 74/94] builtin/apply: make write_out_results() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 75/94] builtin/apply: make try_create_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 76/94] builtin/apply: make create_one_file() " Christian Couder
2016-05-11 13:17 ` [PATCH v2 77/94] builtin/apply: rename option parsing functions Christian Couder
2016-05-11 13:17 ` [PATCH v2 78/94] apply: rename and move opt constants to apply.h Christian Couder
2016-05-11 13:17 ` [PATCH v2 80/94] apply: make some parsing functions static again Christian Couder
2016-05-11 13:17 ` [PATCH v2 81/94] run-command: make dup_devnull() non static Christian Couder
2016-05-11 13:17 ` [PATCH v2 82/94] apply: roll back index lock file in case of error Christian Couder
2016-05-11 13:17 ` [PATCH v2 83/94] environment: add set_index_file() Christian Couder
2016-05-11 13:17 ` [PATCH v2 84/94] builtin/am: use apply api in run_apply() Christian Couder
2016-05-11 13:17 ` [PATCH v2 85/94] write_or_die: use warning() instead of fprintf(stderr, ...) Christian Couder
2016-05-11 13:17 ` [PATCH v2 86/94] apply: add 'be_silent' variable to 'struct apply_state' Christian Couder
2016-05-11 13:17 ` [PATCH v2 87/94] apply: make 'be_silent' incomatible with 'apply_verbosely' Christian Couder
2016-05-11 13:17 ` [PATCH v2 88/94] apply: don't print on stdout when be_silent is set Christian Couder
2016-05-11 13:17 ` [PATCH v2 89/94] usage: add set_warn_routine() Christian Couder
2016-05-11 13:17 ` [PATCH v2 90/94] usage: add get_error_routine() and get_warn_routine() Christian Couder
2016-05-11 13:17 ` [PATCH v2 91/94] apply: change error_routine when be_silent is set Christian Couder
2016-05-11 13:17 ` [PATCH v2 92/94] am: use be_silent in 'struct apply_state' to shut up applying patches Christian Couder
2016-05-11 13:17 ` [PATCH v2 93/94] run-command: make dup_devnull() static again Christian Couder
2016-05-11 13:17 ` [PATCH v2 94/94] builtin/apply: add a cli option for be_silent Christian Couder
2016-05-12 17:06 ` [PATCH v2 00/94] libify apply and use lib in am Johannes Sixt
2016-05-12 18:02   ` Christian Couder
2016-06-09 21:10     ` Johannes Sixt
2016-06-10  6:40       ` Christian Couder
2016-06-10  7:01       ` Johannes Schindelin
2016-06-10  8:59         ` Christian Couder
2016-06-10 11:11           ` Johannes Schindelin
2016-06-10 17:04             ` Johannes Sixt
2016-06-10 20:31               ` Christian Couder
2016-06-11  7:02               ` Johannes Schindelin
2016-05-12 19:04   ` Junio C Hamano
2016-05-12 20:05     ` Christian Couder
2016-05-13  6:32 ` Johannes Schindelin
2016-05-13 18:49   ` Christian Couder
2016-05-14  6:26     ` Johannes Schindelin
2016-05-14  9:19       ` Christian Couder
2016-05-14 18:31         ` Junio C Hamano
2016-05-14 19:37           ` Christian Couder
2016-05-15 18:30             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cQrLZiwZm34+hFZXPmFGVtyPCvCEv4TwsTeL__cfzuORA@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=avarab@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karsten.blees@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.