git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [RFC/PATCH 0/5] remote: eliminate remote->{fetch,push}_refspec and lazy parsing of refspecs
Date: Fri, 16 Jun 2017 14:55:33 -0700	[thread overview]
Message-ID: <xmqqa857wqay.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170616192837.11035-1-szeder.dev@gmail.com> ("SZEDER Gábor"'s message of "Fri, 16 Jun 2017 21:28:32 +0200")

SZEDER Gábor <szeder.dev@gmail.com> writes:

> 'struct remote' stores refspecs twice: once in their original string
> form in remote->{fetch,push}_refspecs and once in their parsed form in
> remote->{fetch,push}.  This is necessary, because we need the refspecs
> for lazy parsing after we finished reading the configuration: we don't
> want to die() on a bogus refspec while reading the configuration of a
> remote we are not going to access at all.
>
> However, storing refspecs in both forms has some drawbacks:
>
>   - The same information is stored twice, wasting memory.

True (but a few hundred bytes is nothing among friends ;-)

>   - remote->{fetch,push}_refspecs, i.e. the string arrays are
>     conveniently ALLOC_GROW()-able with associated
>     {fetch,push}_refspec_{nr,alloc} fields, but remote->{fetch,push}
>     are not.

This is a more real issue.

>   - Wherever remote->{fetch,push} are accessed, the number of parsed
>     refspecs in there is specified by remote->{fetch,push}_refspec_nr.
>     This requires us to keep the two arrays in sync and makes adding
>     additional refspecs cumbersome and error prone.

You haven't told us which way you want to dedup.  Are you keeping
the original and removing the pre-parsed?  or are you only keeping
the pre-parsed ones?  As long as you want ALLOC_GROW() ability, you
need to maintain the invariants in three-tuple (foo, foo_alloc,
foo_nr).

>   - And worst of all, it pissed me off while working on
>     sg/clone-refspec-from-command-line-config ;)

Your feelings (or mine) do not count ;-).

I do not think we would terribly mind if you only kept a list of
pre-parsed form, with some mechanism to keep an "error" entry in
that list with its original, so that an error can be reported with
the refspec as the user originally gave us (which may mean the
"error" entry may have to keep the original form, since it wasn't
correctly parsable in the first place for it to trigger an error).

> So here is my crack at getting rid of them.

You still haven't told us what "them" are.  Parsed form, or the
original?  Let's find out by reading on....

> The idea is to parse refspecs gently while reading the configuration:
> this way we won't need to store all refspecs as strings, and won't
> die() on a bogus refspec right away.  A bogus refspec, if there's one,
> will be stored in the remote it belongs to, so it will be available
> later when that remote is accessed and can be used in the error
> message.

So normally we only have a list of parsed ones, but optionally there
is a list of malformed originals that are before attempted (and
failed) parsing used for error reporting?  That sounds sensible,
especially given that we can recreate the original textual form from
correctly parsed result (which allows us to report on other kinds
of errors as necessary).

> This applies on top of a merge of master and the fresh reroll (v5) of
> sg/clone-refspec-from-command-line-config:

Thanks.  Will take a look (but not immediately).

  parent reply	other threads:[~2017-06-16 21:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-16 19:28 [RFC/PATCH 0/5] remote: eliminate remote->{fetch,push}_refspec and lazy parsing of refspecs SZEDER Gábor
2017-06-16 19:28 ` [PATCH 1/5] remote: don't use remote->{fetch,push}_refspec SZEDER Gábor
2017-06-16 22:00   ` Junio C Hamano
2017-06-16 19:28 ` [PATCH 2/5] remote.c: don't pass copies of refspecs to add_{fetch,push}_refspec() SZEDER Gábor
2017-06-16 19:28 ` [PATCH 3/5] remote.c: extract a helper function to parse a single refspec SZEDER Gábor
2017-06-16 19:28 ` [PATCH 4/5] remote.c: eliminate remote->fetch_refspec SZEDER Gábor
2017-06-16 19:28 ` [PATCH 5/5] remote.c: eliminate remote->push_refspec SZEDER Gábor
2017-06-16 21:55 ` Junio C Hamano [this message]
2017-06-17 12:25   ` [RFC/PATCH 0/5] remote: eliminate remote->{fetch,push}_refspec and lazy parsing of refspecs SZEDER Gábor
2017-06-17 12:33     ` Jeff King
2017-06-17 11:55 ` Jeff King
2017-06-19 20:07   ` 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

  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=xmqqa857wqay.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.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).