git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Fredrik Gustafsson <iveqy@iveqy.com>
Cc: git@vger.kernel.org, gitster@pobox.com, hvoigt@hvoigt.net,
	jens.lehmann@web.de
Subject: Re: [RFC 2/2] Don't push a repository with unpushed submodules
Date: Tue, 28 Jun 2011 11:29:15 -0700	[thread overview]
Message-ID: <7v1uydvmh0.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1309112987-3185-3-git-send-email-iveqy@iveqy.com> (Fredrik Gustafsson's message of "Sun, 26 Jun 2011 20:29:47 +0200")

Fredrik Gustafsson <iveqy@iveqy.com> writes:

> +static int is_submodule_commit_pushed(const char *path, const unsigned char sha1[20])
> +{
> +	int is_pushed = 0;
> +	if (!add_submodule_odb(path) && lookup_commit_reference(sha1)) {
> +		struct child_process cp;
> +		const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
> +		struct strbuf buf = STRBUF_INIT;
> +
> +		argv[1] = sha1_to_hex(sha1);
> +		memset(&cp, 0, sizeof(cp));
> +		cp.argv = argv;
> +		cp.env = local_repo_env;
> +		cp.git_cmd = 1;
> +		cp.no_stdin = 1;
> +		cp.out = -1;
> +		cp.dir = path;
> +		if (!run_command(&cp) && !strbuf_read(&buf, cp.out, 41))
> +			is_pushed = 1;
> +		close(cp.out);
> +		strbuf_release(&buf);
> +	}

What if

 (1) you are binding somebody else's project as your own submodule, you do
     not make any local changes (you won't be pushing them out anyway),
     and you do not have remote tracking branches in that submodule
     project?

 (2) you have a project you can push to that is bound as a submodule, you
     have pushed the commit that is bound in the superproject's tree to
     that submodule project, but you do not have remote tracking branches
     in that submodule project?

 (3) you have a project you can push to that is bound as a submodule, you
     have multiple remotes defined (e.g. one for the public server you
     intend for this check to be in effect, the other is just for your
     private backup), and you have pushed the necessary commit to your
     backup but not to the public one?

The above check would fail in cases (1) and (2) even though it does not
have to. It would succeed in case (3), but people would not be able to use
the superproject as the necessary commit is not there but only on your
work and backup repositories.

What am I missing?

I am not sure if the check imposed on the client end is such a great
idea. I suspect that it would depend on the superproject which submodule
commit must exist "out there" for others to fetch. If you assume a closed
environment where all the superprojects and necessary submodule projects
are housed at a central location everybody pushes into and have tight
control over how project participants clone and check out the
superprojects and submodules, you do not have to worry about any of the
above, but then the server-side can perform the check when it accepts a
push (and you would already be doing other checks there in your hooks
anyway in the industrial setup, I would guess).

  reply	other threads:[~2011-06-28 18:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-26 18:29 [RFC 0/2] push checks for unpushed remotes in submodules Fredrik Gustafsson
2011-06-26 18:29 ` [RFC 1/2] test whether " Fredrik Gustafsson
2011-06-26 18:29 ` [RFC 2/2] Don't push a repository with unpushed submodules Fredrik Gustafsson
2011-06-28 18:29   ` Junio C Hamano [this message]
2011-06-28 19:30     ` Heiko Voigt
2011-06-28 20:43       ` Junio C Hamano
2011-06-28 21:59         ` Fredrik Gustafsson
2011-06-28 22:24         ` Jens Lehmann
2011-07-04 20:05         ` Heiko Voigt
2011-06-28 22:06   ` Marc Branchaud
2011-06-28 22:32     ` Jens Lehmann
2011-06-29 17:29       ` Marc Branchaud
2011-06-28 23:02     ` Fredrik Gustafsson
2011-06-29 17:34       ` Marc Branchaud

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1uydvmh0.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=iveqy@iveqy.com \
    --cc=jens.lehmann@web.de \
    /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.
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 NNTP newsgroup(s).