]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: fix initialization of warn_if_uninitialized
authorOrgad Shaneh <orgads@gmail.com>
Mon, 25 Apr 2022 12:45:41 +0000 (12:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Apr 2022 18:14:10 +0000 (11:14 -0700)
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>
builtin/submodule--helper.c
t/t7406-submodule-update.sh

index 8d03d3f6b1eb6d4dfd9594bec16a00ef87a3e188..9f7fdd866e5bbaab3ca2b023e47d3874364d7486 100644 (file)
@@ -2026,7 +2026,6 @@ struct update_data {
        .references = STRING_LIST_INIT_DUP, \
        .single_branch = -1, \
        .max_jobs = 1, \
-       .warn_if_uninitialized = 1, \
 }
 
 static void next_submodule_warn_missing(struct submodule_update_clone *suc,
index 000e055811c67f2d7cfe89b50ce8fa0aee1af61d..43f779d751cfe2645b038811e69b6f67fee2ed34 100755 (executable)
@@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
        )
 '
 
+test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
+       test_when_finished "rm -fr selective" &&
+       git clone super selective &&
+       (
+               cd selective &&
+               git submodule init submodule &&
+
+               git submodule update submodule 2>err &&
+               ! grep "Submodule path .* not initialized" err &&
+
+               git submodule update rebasing 2>err &&
+               grep "Submodule path .rebasing. not initialized" err &&
+
+               test_path_exists submodule/.git &&
+               test_path_is_missing rebasing/.git
+       )
+
+'
+
+test_expect_success 'submodule update without pathspec updates only initialized ones' '
+       test_when_finished "rm -fr selective" &&
+       git clone super selective &&
+       (
+               cd selective &&
+               git submodule init submodule &&
+               git submodule update 2>err &&
+               test_path_exists submodule/.git &&
+               test_path_is_missing rebasing/.git &&
+               ! grep "Submodule path .* not initialized" err
+       )
+
+'
+
 test_expect_success 'submodule update continues after checkout error' '
        (cd super &&
         git reset --hard HEAD &&