Skip to content

Commit 0faf84d

Browse files
avargitster
authored andcommitted
gc: return from cmd_gc(), don't call exit()
A minor code cleanup. Let's "return" from cmd_gc() instead of calling exit(). See 338abb0 (builtins + test helpers: use return instead of exit() in cmd_*, 2021-06-08) for other such cases. While we're at it add a \n to separate the variable declaration from the rest of the code in this block. Both of these changes make a subsequent change smaller and easier to read. This change isn't really needed for that subsequent change, but now someone viewing that future behavior change won't need to wonder why we're either still calling exit() here, or fixing it while we're at it. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent adcd4d4 commit 0faf84d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
611611
}
612612
if (detach_auto) {
613613
int ret = report_last_gc_error();
614+
614615
if (ret < 0)
615616
/* an I/O error occurred, already reported */
616-
exit(128);
617+
return 128;
617618
if (ret == 1)
618619
/* Last gc --auto failed. Skip this one. */
619620
return 0;

0 commit comments

Comments
 (0)