git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	"Robin H. Johnson" <robbat2@gentoo.org>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: git-clone --config order & fetching extra refs during initial clone
Date: Wed, 15 Mar 2017 13:08:29 -0400	[thread overview]
Message-ID: <20170315170829.7gp44typsyrlw6kg@sigill.intra.peff.net> (raw)
In-Reply-To: <CAM0VKj=rsAfKvVccOMOoo5==Q1yW1U0zJBbUV=faKppWFm-u+g@mail.gmail.com>

On Sat, Mar 11, 2017 at 01:41:34AM +0100, SZEDER Gábor wrote:

> >>  static struct ref *wanted_peer_refs(const struct ref *refs,
> >> -             struct refspec *refspec)
> >> +             struct refspec *refspec, unsigned int refspec_count)
> >
> > Most of the changes here and elsewhere are just about passing along
> > multiple refspecs instead of a single, which makes sense.
> 
> The new parameter should perhaps be renamed to 'refspec_nr', though,
> as '_nr' suffix seems to be more common in the codebase than '_count'.

Yeah, agreed.

> > Though if I'm bikeshedding, I'd probably have written the whole thing
> > with an argv_array and avoided counting at all.
> 
> Yeah, I did notice that you love argv_array :)  I had to raise an
> eyebrow recently while looking at send-pack and how it uses argv_array
> to read refspecs from stdin into an array.  I think argv_array feels a
> bit out of place in both cases.  Yes, it does exactly what's needed.
> However, it's called *argv*_array, indicating that its contents is
> destined to become the options of some command.  But that's not the
> case in these two cases, we are not dealing with arguments to a
> command, these are just arrays of strings.

In my mind, "argv" is synonymous with "NULL-terminated array of
strings". If the name is the only thing keeping it from wider use, I'd
much prefer us to give it a more generic name. All I really care about
is simplifying memory management. :)

> However, leveraging get_remote() makes it moot anyway.

Even better.

> > I do also notice that right _after_ this parsing, we use remote_get(),
> > which is supposed to give us this config anyway. Which makes me wonder
> > if we could just reorder this to put remote_get() first, and then read
> > the resulting refspecs from remote->fetch.
> 
> Though get_remote() does give us this config, at this point the
> default fetch refspec has not been configured yet, therefore it's not
> included in the resulting remote->fetch array.  The default refspec is
> set in write_refspec_config(), but that's called only about two
> screenfulls later.  So there is a bit of extra work to do in order to
> leverage get_remote()'s parsing.
> 
> I think the simplest way is to keep parsing the default fetch refspec
> manually, and then append it to the remote->fetch array.  Definitely
> shorter and simpler than that parsing in the current patch.
> Alternatively, we could set the default fetch refspec in the
> configuration temporarily, only for the duration of the get_remote()
> call, but it feels a bit too hackish...

Yeah, I think manually combining the two here is fine. Though I won't
complain if you want to look into setting the config earlier. If the
refactoring isn't too bad, it would probably provide the nicest outcome.

> However, the tests should also check that refs matching the default
> fetch refspec are transferred, too, i.e. that the clone has something
> under refs/remotes/origin/ as well.  Case in point is using the result
> of get_remote(): at first I naively set out to use remote->fetch
> as-is, which didn't include the default fetch refspec, hence didn't
> fetch refs/heads/master, but the test succeeded nonetheless.

Good point.

> > If we wanted to be thorough, we could also check that the feature works
> > correctly with "--origin" (I think it does).
> 
> I think it works, but I'm not quite sure what you mean with "works
> correctly with --origin".
> 
> So just to be clear: the behaviour depends on whether the remote name
> given in '-c remote.<name>.fetch=<refspec>' matches the name given to
> the '--origin=<name>'.  If they match, then refs matching the
> additional refspec are transferred, too.  That's good.  However, if
> the two remote names don't match, then refs matching the additional
> refspec are NOT transferred.  I think this is good, too, because only
> the origin remote should be cloned, whatever it is called, and in this
> case that additional refspec belongs to a different remote.

Yes, exactly. Mostly I was suggesting that if you do "--origin=foo",
then we do not fetch items named "remote.origin.fetch" (i.e., that the
code correctly uses the origin variable and not the hard-coded name
"origin").

-Peff

  reply	other threads:[~2017-03-15 17:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25 19:12 git-clone --config order & fetching extra refs during initial clone Robin H. Johnson
2017-02-25 20:21 ` Jeff King
2017-02-25 20:50 ` Jeff King
2017-02-27 19:16   ` Junio C Hamano
2017-02-27 21:12     ` Jeff King
2017-03-11  0:41       ` SZEDER Gábor
2017-03-15 17:08         ` Jeff King [this message]
2017-05-03 14:42           ` SZEDER Gábor
2017-05-03 20:22             ` Jeff King
2017-05-04  6:57               ` Sebastian Schuberth
2017-05-09  1:33               ` Junio C Hamano
2017-05-09  2:10                 ` Jeff King
2017-05-09  2:26                   ` Jeff King
2017-05-09  2:50                     ` Junio C Hamano
2017-05-04  7:28             ` Ævar Arnfjörð Bjarmason

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=20170315170829.7gp44typsyrlw6kg@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=robbat2@gentoo.org \
    --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).