From: Duy Nguyen <pclouds@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Brandon Williams <bmwill@google.com>, Antonio Ospite <ao2@ao2.it>,
git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 02/11] repository: introduce repo_read_index_or_die
Date: Tue, 22 May 2018 17:13:06 +0200 [thread overview]
Message-ID: <CACsJy8DfF+Bn94dQH2cSFfHpXqHa07vstAKrJeRhd-5EP8avWA@mail.gmail.com> (raw)
In-Reply-To: <CAGZ79kZ0TBzDMqpim1Wtr9QtF2OtskE=nRPx2Nj+rwyT8HMqTw@mail.gmail.com>
On Mon, May 21, 2018 at 9:27 PM, Stefan Beller <sbeller@google.com> wrote:
> Hi Brandon,
>
>>> One of the reviewers of the series questioned the overall goal of the
>>> series as we want to move away from _die() in top level code but this
>>> series moves more towards it.
>>
>> I've heard every once in a while that we want to move toward this but I
>> don't believe there is an actual effort along those lines just yet. For
>> that to be the case we would need a clearly defined error handling
>> methodology (aside from the existing "die"ing behavior), which we don't
>> currently have.
>
> We have the example in the refs code, which I would want to
> imitate. :)
>
> /*
> * Return 0 if a reference named refname could be created without
> * conflicting with the name of an existing reference. Otherwise,
> * return a negative value and write an explanation to err. [...]
> */
>
> int refs_verify_refname_available(struct ref_store *refs, ...
> struct strbuf *err);
>
> extern int refs_init_db(struct strbuf *err);
apply.c and sequencer.c too are libified and try hard to avoid die()
if I remember correctly.
> But it is true that there is no active effort currently being pushed.
Yeah. It took a lot of work to put refs code in the current shape
today. I think we just be careful about adding die(). If a function
has no way to return an error, then die() is unavoidable. If it's a
really fatal error, then die() might still be the right choice. But if
not we should try to return an error instead.
Speaking of avoiding die() (and going off-topic again), maybe we
should introduce NO_DIE_PLEASE macro in the same spirit as
NO_THE_INDEX_COMPATIBILITY_MACROS. If the macro is defined, die() and
friends are not declared (which will result in compile errors at least
on DEVELOPER=1 builds). This helps draw boundary between die-able code
and un-die-able code (not perfect, but good enough)
--
Duy
next prev parent reply other threads:[~2018-05-22 15:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 1:04 [PATCH] grep: handle corrupt index files early Stefan Beller
2018-05-15 12:18 ` Johannes Schindelin
2018-05-15 13:13 ` Duy Nguyen
2018-05-15 16:44 ` Stefan Beller
2018-05-16 15:24 ` Duy Nguyen
2018-05-16 22:21 ` [PATCH 00/11] Stefan Beller
2018-05-16 22:21 ` [PATCH 01/11] grep: handle corrupt index files early Stefan Beller
2018-05-16 22:21 ` [PATCH 02/11] repository: introduce repo_read_index_or_die Stefan Beller
2018-05-19 6:37 ` Duy Nguyen
2018-05-21 18:38 ` Stefan Beller
2018-05-21 18:50 ` Brandon Williams
2018-05-21 19:27 ` Stefan Beller
2018-05-22 15:13 ` Duy Nguyen [this message]
2018-05-22 17:49 ` Why do we have both x*() and *_or_die() for "do or die"? Ævar Arnfjörð Bjarmason
2018-05-22 17:55 ` Duy Nguyen
2018-05-22 18:38 ` Jonathan Nieder
2018-05-22 18:04 ` Stefan Beller
2018-05-23 3:19 ` Junio C Hamano
2018-05-16 22:21 ` [PATCH 03/11] builtin/grep: use repo_read_index_or_die Stefan Beller
2018-05-16 22:21 ` [PATCH 04/11] submodule: " Stefan Beller
2018-05-16 22:21 ` [PATCH 05/11] builtin/ls-files: " Stefan Beller
2018-05-16 22:21 ` [PATCH 06/11] read_cache: use repo_read_index_or_die with different error messages Stefan Beller
2018-05-16 22:21 ` [PATCH 07/11] rerere: use repo_read_index_or_die Stefan Beller
2018-05-20 17:45 ` Thomas Gummerer
2018-05-21 18:46 ` Stefan Beller
2018-05-16 22:21 ` [PATCH 08/11] check-attr: switch to repo_read_index_or_die Stefan Beller
2018-05-16 22:21 ` [PATCH 09/11] checkout-index: switch to repo_read_index Stefan Beller
2018-05-16 22:21 ` [PATCH 10/11] test helpers: switch to repo_read_index_or_die Stefan Beller
2018-05-16 22:21 ` [PATCH 11/11] read_cache: convert most calls " Stefan Beller
2018-05-16 22:27 ` Brandon Williams
2018-05-19 6:55 ` Duy Nguyen
2018-05-19 6:54 ` Duy Nguyen
2018-05-19 6:57 ` [PATCH 00/11] Duy Nguyen
2018-05-17 1:36 ` [PATCH] grep: handle corrupt index files early Junio C Hamano
2018-05-17 17:21 ` Stefan Beller
2018-05-17 22:57 ` Junio C Hamano
2018-05-15 17:01 ` Brandon Williams
2018-05-15 23:58 ` 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=CACsJy8DfF+Bn94dQH2cSFfHpXqHa07vstAKrJeRhd-5EP8avWA@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=ao2@ao2.it \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 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).