git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Brandon Williams <bmwill@google.com>,
	Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>,
	Antonio Ospite <ao2@ao2.it>
Subject: Re: [PATCH] grep: handle corrupt index files early
Date: Wed, 16 May 2018 17:24:11 +0200
Message-ID: <CACsJy8A8WZ-Gqe2Y-whJmbADrt+gZjLZ7MTwCtdnK7JDnEdtog@mail.gmail.com> (raw)
In-Reply-To: <CAGZ79kYYy-r+Zs_6yg1ZVRNsBcTUdPWE=FeHrp_=0cV0Uf_GfQ@mail.gmail.com>

On Tue, May 15, 2018 at 6:44 PM, Stefan Beller <sbeller@google.com> wrote:
> On Tue, May 15, 2018 at 6:13 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Tue, May 15, 2018 at 3:04 AM, Stefan Beller <sbeller@google.com> wrote:
>>> Any other caller of 'repo_read_index' dies upon a negative return of
>>> it, so grep should, too.
>>>
>>> Signed-off-by: Stefan Beller <sbeller@google.com>
>>> ---
>>>
>>> Found while reviewing the series
>>> https://public-inbox.org/git/20180514105823.8378-1-ao2@ao2.it/
>>>
>>>  builtin/grep.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/builtin/grep.c b/builtin/grep.c
>>> index 6e7bc76785a..69f0743619f 100644
>>> --- a/builtin/grep.c
>>> +++ b/builtin/grep.c
>>> @@ -488,7 +488,8 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
>>>                 strbuf_addstr(&name, repo->submodule_prefix);
>>>         }
>>>
>>> -       repo_read_index(repo);
>>> +       if (repo_read_index(repo) < 0)
>>> +               die("index file corrupt");
>>
>> _() the string (and maybe reuse an existing phrase if found to reduce
>> workload on translators)
>
> sbeller@sbeller:/u/git$ git grep -A 1 repo_read_index
> builtin/grep.c:491:     if (repo_read_index(repo) < 0)
> builtin/grep.c-492-             die("index file corrupt");
> --
> builtin/ls-files.c:213: if (repo_read_index(&submodule) < 0)
> builtin/ls-files.c-214-         die("index file corrupt");
> --
> builtin/ls-files.c:582: if (repo_read_index(the_repository) < 0)
> builtin/ls-files.c-583-         die("index file corrupt");
> --
> dir.c:3028:     if (repo_read_index(&subrepo) < 0)
> dir.c-3029-             die("index file corrupt in repo %s", subrepo.gitdir);
> --
> repository.c:245:int repo_read_index(struct repository *repo)
> repository.c-246-{
> --
> repository.h:70:         * 'repo_read_index()' can be used to populate 'index'.
> repository.h-71-         */
> --
> repository.h:119:extern int repo_read_index(struct repository *repo);
> repository.h-120-
> --
> submodule-config.c:583:         if (repo_read_index(repo) < 0)
> submodule-config.c-584-                 return;
> --
> submodule.c:1336:       if (repo_read_index(r) < 0)
> submodule.c-1337-               die("index file corrupt");
>
> I think this is as good as it gets for using an existing phrase.
> None of them are translated, which I would defer to a follow up patch
> that translates all(?) of them or just the porcelains.

If you have time, yes translate them all. I don't see how any of these
strings are meant for script. If not, just _() the new string you
added is fine.

With a majority of call sites dying like this though, I wonder if we
should just add repo_read_index_or_die() with die() inside. Then the
next person won't likely accidentally forget _()

>
> Thanks,
> Stefan



-- 
Duy

  reply index

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15  1:04 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 [this message]
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
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
2018-05-15 20:00 [PATCHv2 0/3] Reroll of sb/submodule-merge-in-merge-recursive Stefan Beller
2018-05-15 20:00 ` [PATCH] grep: handle corrupt index files early Stefan Beller

Reply instructions:

You may reply publically 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CACsJy8A8WZ-Gqe2Y-whJmbADrt+gZjLZ7MTwCtdnK7JDnEdtog@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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox