diff mbox series

[v3,17/32] submodule--helper: don't redundantly check "else if (res)"

Message ID patch-v3-17.32-fa2417c7a17-20220821T130231Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series submodule--helper: add tests, rm dead code, refactor & leak prep | expand

Commit Message

Ævar Arnfjörð Bjarmason Aug. 21, 2022, 1:57 p.m. UTC
The "res" variable must be true at this point in update_submodule(),
as just a few lines above this we've unconditionally:

	if (!res)
		return 0;

So we don't need to guard the "return 1" with an "else if (res)", we
an return unconditionally at this point. See b3c5f5cb048 (submodule:
move core cmd_update() logic to C, 2022-03-15) for the initial
introduction of this code, this check of "res" has always been
redundant.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/submodule--helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Eric Sunshine Aug. 21, 2022, 4:12 p.m. UTC | #1
On Sun, Aug 21, 2022 at 10:00 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> The "res" variable must be true at this point in update_submodule(),
> as just a few lines above this we've unconditionally:
>
>         if (!res)
>                 return 0;
>
> So we don't need to guard the "return 1" with an "else if (res)", we
> an return unconditionally at this point. See b3c5f5cb048 (submodule:

s/an/can/

> move core cmd_update() logic to C, 2022-03-15) for the initial
> introduction of this code, this check of "res" has always been
> redundant.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
diff mbox series

Patch

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index a694b18b55e..a9808224f01 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2446,8 +2446,7 @@  static int update_submodule(struct update_data *update_data)
 			    update_data->displaypath);
 		if (res == 128)
 			exit(res);
-		else if (res)
-			return 1;
+		return 1;
 	}
 
 	return 0;