From: ZheNing Hu <adlternative@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>,
Git List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Christian Couder <christian.couder@gmail.com>,
Hariom Verma <hariom18599@gmail.com>,
Bagas Sanjaya <bagasdotme@gmail.com>, Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>,
Philip Oakley <philipoakley@iee.email>
Subject: Re: [PATCH 2/5] [GSOC] ref-filter: add %(raw) atom
Date: Thu, 22 Jul 2021 16:31:18 +0800 [thread overview]
Message-ID: <CAOLTT8TP4z1vR8i9DX09+oBiPVgaF1isTgD2ZQ4nfoBJwTd9_w@mail.gmail.com> (raw)
In-Reply-To: <877dhivkei.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于2021年7月22日周四 下午4:10写道:
>
>
> On Thu, Jul 22 2021, ZheNing Hu via GitGitGadget wrote:
>
> > [..] add a new member in
> > `struct atom_value`: `s_size`, which can record raw object size, it
> > can help us add raw object data to the buffer or compare two buffers
> > which contain raw object data.
>
> I didn't look in detail, just one nit/comment, no need to re-roll for this:
>
>
> > struct atom_value {
> > const char *s;
> > + size_t s_size;
> > int (*handler)(struct atom_value *atomv, struct ref_formatting_state *state,
> > struct strbuf *err);
> > uintmax_t value; /* used for sorting when not FIELD_STR */
> > struct used_atom *atom;
> > };
> >
> > +#define ATOM_VALUE_S_SIZE_INIT (-1)
> > +
>
> This and then later doing (this appears to be the only initialization?):
Yes, "s_size = -1” is the only initialization.
>
> > if (format->need_color_reset_at_eol) {
> > struct atom_value resetv;
> > + resetv.s_size = ATOM_VALUE_S_SIZE_INIT;
> > resetv.s = GIT_COLOR_RESET;
> > if (append_atom(&resetv, &state, error_buf)) {
> > pop_stack_element(&state.stack);
>
> Is a rather unusual pattern, more typical would be:
>
> struct atom_value { .... }
> #define ATOM_VALUE_INIT { \
> .s_size = -1, \
> }
>
> Then:
>
> struct atom_value resetv = ATOM_VALUE_INIT;
>
> You could keep that "#define ATOM_VALUE_S_SIZE_INIT (-1)" to check the
> init value, personally I think it's just fine to hardcode the -1 literal
> and do "size < 0" checks, which we us as convention in a lot of other
> places for "not initialized".
Maybe you are right, hard-coding "-1" is ok.
Thanks.
--
ZheNing Hu
next prev parent reply other threads:[~2021-07-22 8:31 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 7:39 [PATCH 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-22 8:51 ` Christian Couder
2021-07-22 9:15 ` ZheNing Hu
2021-07-22 7:39 ` [PATCH 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-22 8:06 ` Ævar Arnfjörð Bjarmason
2021-07-22 8:31 ` ZheNing Hu [this message]
2021-07-22 7:39 ` [PATCH 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-22 8:11 ` Ævar Arnfjörð Bjarmason
2021-07-22 9:10 ` ZheNing Hu
2021-07-23 9:09 ` Jacob Keller
2021-07-23 14:11 ` ZheNing Hu
2021-07-22 8:08 ` [PATCH 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms Christian Couder
2021-07-22 8:22 ` ZheNing Hu
2021-07-23 9:03 ` [PATCH v2 " ZheNing Hu via GitGitGadget
2021-07-23 9:03 ` [PATCH v2 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-23 16:38 ` Junio C Hamano
2021-07-24 7:57 ` ZheNing Hu
2021-07-24 17:41 ` Junio C Hamano
2021-07-25 12:47 ` ZheNing Hu
2021-07-23 9:04 ` [PATCH v2 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-25 8:22 ` Jacob Keller
2021-07-24 14:14 ` [PATCH v3 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-25 8:27 ` Jacob Keller
2021-07-25 13:18 ` ZheNing Hu
2021-07-24 14:14 ` [PATCH v3 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-25 8:29 ` Jacob Keller
2021-07-26 17:34 ` Junio C Hamano
2021-07-26 3:26 ` [PATCH v4 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-26 19:15 ` Junio C Hamano
2021-07-27 1:41 ` ZheNing Hu
2021-07-26 3:26 ` [PATCH v4 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 3/5] [GSOC] ref-filter: --format=%(raw) support --perl ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
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
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=CAOLTT8TP4z1vR8i9DX09+oBiPVgaF1isTgD2ZQ4nfoBJwTd9_w@mail.gmail.com \
--to=adlternative@gmail.com \
--cc=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=hariom18599@gmail.com \
--cc=peff@peff.net \
--cc=philipoakley@iee.email \
--cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).