]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: return "ret", not "1" from update_submodule()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 31 Aug 2022 23:18:02 +0000 (01:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:16:24 +0000 (09:16 -0700)
Amend the update_submodule() function to return the failing "ret" on
error, instead of overriding it with "1".

This code was added in b3c5f5cb048 (submodule: move core cmd_update()
logic to C, 2022-03-15), and this change ends up not making a
difference as this function is only called in update_submodules(). If
we return non-zero here we'll always in turn return "1" in
module_update().

But if we didn't do that and returned any other non-zero exit code in
update_submodules() we'd fail the test that's being amended
here. We're still testing the status quo here.

This change makes subsequent refactoring of update_submodule() easier,
as we'll no longer need to worry about clobbering the "ret" we get
from the run_command().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
t/t7406-submodule-update.sh

index d76ee0323e80ab91debca7ed4ccff7d93ab3e6f4..d6a827366dedeeae22d09866eb849805781772dc 100644 (file)
@@ -2445,7 +2445,7 @@ static int update_submodule(struct update_data *update_data)
                            update_data->displaypath);
                if (ret == 128)
                        exit(ret);
-               return 1;
+               return ret;
        }
 
        return 0;
index 6cc07460dd2a1f1f8b06010f06a5915ef88ce8eb..c5f5dbe55e0a91e24589c8c9d85ba53995091b36 100755 (executable)
@@ -769,7 +769,7 @@ test_expect_success 'submodule update continues after recursive checkout error'
           echo "" > file
          )
         ) &&
-        test_must_fail git submodule update --recursive &&
+        test_expect_code 1 git submodule update --recursive &&
         (cd submodule2 &&
          git rev-parse --verify HEAD >../actual
         ) &&