git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Stefan Beller <sbeller@google.com>,
	git@vger.kernel.org, Jens.Lehmann@web.de,
	Fredrik Gustafsson <iveqy@iveqy.com>,
	Leandro Lucarella <leandro.lucarella@sociomantic.com>
Subject: Re: [PATCH v2 3/3] batch check whether submodule needs pushing into one call
Date: Thu, 13 Oct 2016 17:59:29 +0200	[thread overview]
Message-ID: <20161013155929.GB29710@book.hvoigt.net> (raw)
In-Reply-To: <xmqqwphd4gf6.fsf@gitster.mtv.corp.google.com>

On Wed, Oct 12, 2016 at 10:37:33AM -0700, Junio C Hamano wrote:
> Heiko Voigt <hvoigt@hvoigt.net> writes:
> 
> >> If we do not even have these commits locally, then there is no point
> >> attempting to push, so returning 0 (i.e. it is not "needs pushing"
> >> situation) is correct but it is a but subtle.  It's not "we know
> >> they already have them", but it is "even if we tried to push, it
> >> won't do us or the other side any good."  A single-liner in-code
> >> comment may help.
> >
> > First the naming part. How about:
> >
> > 	submodule_has_commits()
> 
> Nice.

Ok will use that. And while I am at it: I will also rename all the
'hashes' variables to commits because that makes the code way clearer I
think.

> > Returning 0 here means: "No push needed" but the correct answer would
> > be: "We do not know". 
> 
> Is it?  Perhaps I am misreading the "submodule-has-commits"; I
> thought it was "the remote may or may not need updating, but we
> ourselves don't have what they may need to have commits in their
> submodule that are referenced by their superproject, so it would not
> help them even if we pushed our submodule to them".  It indeed is
> different from "No push needed" (rather, "our pushing would be
> pointless").

Yes you could also rephrase/see it that way. But the question is: If we
do not have what the remote needs would the user expect us to tell him
that fact and stop or does he usually not care?

> > So how about:
> >
> >
> > 	if (!submodule_has_hashes(path, hashes))
> > 		/* NEEDSWORK: The correct answer here is "We do not
> > 		 * know" instead of "No". We currently proceed pushing
> > 		 * here as if the submodules commits are available on a
> > 		 * remote, which is not always correct. */
> > 		return 0;
> 
> I am not sure.  
> 
> What should happen in this scenario?
> 
>  * We have two remotes, A and B, for our superproject.
> 
>  * We are not interested in one submodule at path X.  Our repository
>    is primarily used to work on the superproject and possibly other
>    submodules but not the one at path X.
> 
>  * We pulled from A to update ourselves.  They were actively working
>    on the submodule we are not interested in, and path X in the
>    superproject records a new commit that we do not have.
> 
>  * We are now trying to push to B.

I am not sure if this is a typical scenario? Well, if you are updating
your main branch from someone else and then push it to your own fork
maybe. You could specify --no-recurse-submodules for this case though.
The proper solution for this case would probably be something along the
lines of 'submodule.<name>.fetchRecurseSubmodules' but for push so we
can mark certain submodules as uninteresting by default.

I like to be more protective to the user here. Its usually more
annoying for possibly many others when you push out things that have
missing things compared to one person not being able to push because his
submodule is not up-to-date/initialized.

> Should different things happen in these two subcases?
> 
>  - We are not interested in submodule at path X, so we haven't even
>    done "submodule init" on it.
> 
>  - We are not interested in submodule at path X, so even though we
>    do have a rather stale clone of it, we do not usually bother
>    updating what is checked out at path X and commit our changes
>    outside that area.
> 
> I tend to think that in these two cases the same thing should
> happen.  I am not sure if that same thing should be rejection
> (i.e. "you do not know for sure that the commit at path X of the
> superproject you are pushing exists in the submodule repository at
> the receiving end, so I'd refuse to push the superproject"), as it
> makes the only remedy for the situation is for you to make a full
> clone of the submodule you are not interested in and you have never
> touched yourself in either of these two subcases.

I also think in both situations the same thing should happen. A decision
that something different should happen should be made explicitly instead
of implicitly just because some submodule is not initialized. That might
be by accident or because a certain submodule is new so here the choice
should be made deliberately by the user, IMO.

Cheers Heiko

      reply	other threads:[~2016-10-13 16:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07 15:06 [PATCH v2 0/3] Speedup finding of unpushed submodules Heiko Voigt
2016-10-07 15:06 ` [PATCH v2 1/3] serialize collection of changed submodules Heiko Voigt
2016-10-07 17:59   ` Stefan Beller
2016-10-10 22:43     ` Junio C Hamano
2016-10-12 13:00       ` Heiko Voigt
2016-10-12 17:18         ` Junio C Hamano
2016-10-13 15:27           ` Heiko Voigt
2016-10-12 13:11     ` Heiko Voigt
2016-10-07 15:06 ` [PATCH v2 2/3] serialize collection of refs that contain submodule changes Heiko Voigt
2016-10-07 18:16   ` Stefan Beller
2016-10-12 13:10     ` Heiko Voigt
2016-10-20 23:00       ` Stefan Beller
2016-10-10 22:48   ` Junio C Hamano
2016-10-07 15:06 ` [PATCH v2 3/3] batch check whether submodule needs pushing into one call Heiko Voigt
2016-10-07 18:30   ` Stefan Beller
2016-10-10 22:56   ` Junio C Hamano
2016-10-12 13:33     ` Heiko Voigt
2016-10-12 17:37       ` Junio C Hamano
2016-10-13 15:59         ` Heiko Voigt [this message]

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=20161013155929.GB29710@book.hvoigt.net \
    --to=hvoigt@hvoigt.net \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=iveqy@iveqy.com \
    --cc=leandro.lucarella@sociomantic.com \
    --cc=peff@peff.net \
    --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
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).