Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit, much later: As of Git 1.7.7, <code>git-push</code> now has a <code>--recurse-submodules=check</code> option, which refuses to push the parent project if any submodule commits haven't been pushed to their remotes. It doesn't appear that a corresponding <code>push.recurseSubmodules</code> config parameter has been added yet. This of course doesn't entirely address the problem - a clueless user could still push without the check - but it's quite relevant!</p> <p>I think the best approach, rather than examining each individual commit, is to look at the diff across all of the pushed commits: <code>git diff &lt;old&gt; &lt;new&gt;</code>. You don't want to look at the whole diff though, really; it could be enormous. Unfortunately, the git-submodule porcelain command doesn't work in bare repos, but you should still be able to quickly examine <code>.gitmodules</code> to get a list of paths (and maybe URLs). For each one, you can <code>git diff &lt;old&gt; &lt;new&gt; -- path</code>, and if there is a diff, grab the new submodule commit. (And if you're worried about a 000000 old commit possibility, you can just use <code>git show</code> on the new one, I believe.)</p> <p>Once you get all that taken care of, you've reduced the problem to checking whether given commits exist in given remote repositories. Unfortunately, as it looks like you've noticed, that's not straightforward, at least <a href="https://stackoverflow.com/questions/3418674/bash-shell-script-function-to-verify-git-tag-or-commit-exists-and-has-been-pushed">as far as I know</a>. Keeping local, up-to-date clones is probably your best bet, and it sounds like you're good there.</p> <p>By the way, I don't think the caching is going to be relevant here, since the update hook is once per ref. Yes, you could do this in a pre-receive hook, which gets all the refs on stdin, but I don't see why you should bother doing more work. It's not going to be an expensive operation, and with an update hook, you can individually accept or reject the various branches being pushed, instead of preventing <em>all</em> of them from being updated because only one was bad.</p> <p>If you want to save some trouble, I'd probably just avoid parsing the gitmodules file, and hardcode a list into the hook. I doubt your list of submodules changes very often, so it's probably cheaper to maintain that than to write something automated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload