submodule--helper: fix initialization of warn_if_uninitialized

The .warn_if_uninitialized member was introduced by 48308681 (git submodule update: have a dedicated helper for cloning, 2016-02-29) to submodule_update_clone struct and initialized to false. When c9911c93 (submodule--helper: teach update_data more options, 2022-03-15) moved it to update_data struct, it started to initialize it to true but this change was not explained in its log message. The member is set to true only when pathspec was given, and is used when a submodule that matched the pathspec is found uninitialized to give diagnostic message. "submodule update" without pathspec is supposed to iterate over all submodules (i.e. without pathspec limitation) and update only the initialized submodules, and finding uninitialized submodules during the iteration is a totally expected and normal thing that should not be warned. [jc: added tests] Signed-off-by: Orgad Shaneh <orgads@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Orgad Shaneh committed Apr 25, 2022 at 12:45 UTC 4f1ccef87ca53a4d4e85f4df3cf2fbe8afb14e89
2 files changed +33 -1
builtin/submodule--helper.c
-1
@@ -2026,7 +2026,6 @@ struct update_data {
2026 .references = STRING_LIST_INIT_DUP, \
2027 .single_branch = -1, \
2028 .max_jobs = 1, \
2029 - .warn_if_uninitialized = 1, \
2029 }
2030
2031 static void next_submodule_warn_missing(struct submodule_update_clone *suc,
t/t7406-submodule-update.sh
+33
@@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
670 )
671 '
672
673 +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
674 + test_when_finished "rm -fr selective" &&
675 + git clone super selective &&
676 + (
677 + cd selective &&
678 + git submodule init submodule &&
679 +
680 + git submodule update submodule 2>err &&
681 + ! grep "Submodule path .* not initialized" err &&
682 +
683 + git submodule update rebasing 2>err &&
684 + grep "Submodule path .rebasing. not initialized" err &&
685 +
686 + test_path_exists submodule/.git &&
687 + test_path_is_missing rebasing/.git
688 + )
689 +
690 +'
691 +
692 +test_expect_success 'submodule update without pathspec updates only initialized ones' '
693 + test_when_finished "rm -fr selective" &&
694 + git clone super selective &&
695 + (
696 + cd selective &&
697 + git submodule init submodule &&
698 + git submodule update 2>err &&
699 + test_path_exists submodule/.git &&
700 + test_path_is_missing rebasing/.git &&
701 + ! grep "Submodule path .* not initialized" err
702 + )
703 +
704 +'
705 +
706 test_expect_success 'submodule update continues after checkout error' '
707 (cd super &&
708 git reset --hard HEAD &&