git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH 4/6] builtin/submodule--helper: store update_clone information in a struct
Date: Mon, 16 Jul 2018 16:55:59 -0700
Message-ID: <CAGZ79kaOy0pZJCob4d=66FQLaOu_q_BAJeFc94xkFa0SSqYigw@mail.gmail.com> (raw)
In-Reply-To: <xmqqo9f7t1jy.fsf@gitster-ct.c.googlers.com>

On Mon, Jul 16, 2018 at 12:37 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Stefan Beller <sbeller@google.com> writes:
>
> > The information that is printed for update_submodules in
> > 'submodule--helper update-clone' and consumed by 'git submodule update'
> > is stored as a string per submodule. This made sense at the time of
> > 48308681b07 (git submodule update: have a dedicated helper for cloning,
> > 2016-02-29), but as we want to migrate the rest of the submodule update
> > into C, we're better off having access to the raw information in a helper
> > struct.
>
> The reasoning above makes sense, but I have a few niggles on the
> naming.
>
>  * Anything you'd place to keep track of the state is "information",
>    so a whole "_information" suffix to the structure name does not
>    add much value.  We've seen our fair share of (meaningless)
>    "_data" suffix used in many places but I think the overly long
>    "_information" that is equally meaningless trumps them.  I think
>    we also have "_info", but if we are not going to have a beter
>    name, let's not be original and stick to "_data" like other
>    existing codepath.  An alternative with more meaningful name is
>    of course better, though, but it is not all that much worth to
>    spend too many braincycles on it.

agreed.

>  * Is the fact that these parameters necessary to help populating
>    the submodule repository are sent on a line to external process
>    the most important aspect of the submodule_lines[] array?  As

In terms of what the submodule--helper does, it is.
It is not the most important aspect in the big picture, or once
we finish the migration to not have shell interpret its output.

>    this step is a preparation to migrate out of that line/text
>    oriented IPC, I think line-ness is the least important and
>    interesting thing to name the variable with.

ok.

> If I were writing this patch, perhaps I'd do
>
>         struct update_clone_data *update_clone;
>         int update_clone_nr, update_clone_alloc;
>
> following my gut, but since you've been thinking about submodule
> longer than I have, perhaps you can come up with a better name.

That makes sense. We do not need to mention 'submodule' as that
ought to be obvious from the file name already and 'update_clone'
is just enough to describe what we are doing.
Although there is already struct submodule_update_clone, which
would be the better candidate for 'update_clone' and this new
struct would be used as a helper in that struct, so update_clone_data

I'll think of adding a patch to rename that already existing struct
(submodule_update_clone -> update_clone) and renaming
this to update_clone_data.



>
> > @@ -1463,8 +1469,9 @@ struct submodule_update_clone {
> >       const char *recursive_prefix;
> >       const char *prefix;
> >
> > -     /* Machine-readable status lines to be consumed by git-submodule.sh */
> > -     struct string_list projectlines;
> > +     /* to be consumed by git-submodule.sh */
> > +     struct submodule_update_clone_information *submodule_lines;
> > +     int submodule_lines_nr; int submodule_lines_alloc;
> >
> >       /* If we want to stop as fast as possible and return an error */
> >       unsigned quickstop : 1;
> > @@ -1478,7 +1485,7 @@ struct submodule_update_clone {
> >  #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
> >       SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, \
> >       NULL, NULL, NULL, \
> > -     STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
> > +     NULL, 0, 0, 0, NULL, 0, 0, 0}
>
> The structure definition and this macro definition are nearby, so it
> is not crucial, but its probably not a bad idea to switch to C99
> initializers for a thing like this to make it more readable, once
> the code around this area stabilizes back again sufficiently (IOW,
> let's not distract ourselves in the middle of adding a new feature
> like this one).

Are we still in the phase of "test balloon" or do we now accept
C99 initializers all over the code base?

But I agree to defer the conversion for now.

Thanks,
Stefan

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 19:47 [PATCH 0/6] git-submodule.sh: convert part of cmd_update to C Stefan Beller
2018-07-12 19:47 ` [PATCH 1/6] git-submodule.sh: align error reporting for update mode to use path Stefan Beller
2018-07-12 21:12   ` Junio C Hamano
2018-07-12 19:47 ` [PATCH 2/6] git-submodule.sh: rename unused variables Stefan Beller
2018-07-12 21:24   ` Junio C Hamano
2018-07-12 19:47 ` [PATCH 3/6] builtin/submodule--helper: factor out submodule updating Stefan Beller
2018-07-12 19:47 ` [PATCH 4/6] builtin/submodule--helper: store update_clone information in a struct Stefan Beller
2018-07-16 19:37   ` Junio C Hamano
2018-07-16 23:55     ` Stefan Beller [this message]
2018-07-12 19:47 ` [PATCH 5/6] builtin/submodule--helper: factor out method to update a single submodule Stefan Beller
2018-07-12 19:47 ` [PATCH 6/6] submodule--helper: introduce new update-module-mode helper Stefan Beller
2018-07-18 15:00   ` Derrick Stolee
2018-07-18 19:41     ` Stefan Beller
2018-07-18 19:48 [PATCH 0/6] Resend of origin/sb/submodule-update-in-c Stefan Beller
2018-07-18 19:48 ` [PATCH 4/6] builtin/submodule--helper: store update_clone information in a struct 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='CAGZ79kaOy0pZJCob4d=66FQLaOu_q_BAJeFc94xkFa0SSqYigw@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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