submodule_needs_pushing(): explain the behaviour when we cannot answer

When we do not have commits that are involved in the update of the superproject in our copy of submodule, we cannot tell if the remote end needs to acquire these commits to be able to check out the superproject tree. Explain why we answer "no there is no need/point in pushing from our submodule repository" in this case. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Heiko Voigt committed Nov 16, 2016 at 16:11 UTC 250ab24ab3a35d5857855a2e00483dcd8867fdca
1 file changed +11
submodule.c
+11
@@ -553,6 +553,17 @@ static int submodule_has_commits(const char *path, struct sha1_array *commits)
553 static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
554 {
555 if (!submodule_has_commits(path, commits))
556 + /*
557 + * NOTE: We do consider it safe to return "no" here. The
558 + * correct answer would be "We do not know" instead of
559 + * "No push needed", but it is quite hard to change
560 + * the submodule pointer without having the submodule
561 + * around. If a user did however change the submodules
562 + * without having the submodule around, this indicates
563 + * an expert who knows what they are doing or a
564 + * maintainer integrating work from other people. In
565 + * both cases it should be safe to skip this check.
566 + */
567 return 0;
568
569 if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {