Skip to content

Commit bec587d

Browse files
chooglengitster
authored andcommitted
fetch: use goto cleanup in cmd_fetch()
Replace an early return with 'goto cleanup' in cmd_fetch() so that the string_list is always cleared (the string_list_clear() call is purely cleanup; the string_list is not reused). This makes cleanup consistent so that a subsequent commit can use 'goto cleanup' to bail out early. Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69a9c10 commit bec587d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/fetch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
20762076
gtransport->smart_options->acked_commits = &acked_commits;
20772077
} else {
20782078
warning(_("Protocol does not support --negotiate-only, exiting."));
2079-
return 1;
2079+
result = 1;
2080+
goto cleanup;
20802081
}
20812082
if (server_options.nr)
20822083
gtransport->server_options = &server_options;
@@ -2132,8 +2133,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21322133
strvec_clear(&options);
21332134
}
21342135

2135-
string_list_clear(&list, 0);
2136-
21372136
prepare_repo_settings(the_repository);
21382137
if (fetch_write_commit_graph > 0 ||
21392138
(fetch_write_commit_graph < 0 &&
@@ -2151,5 +2150,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21512150
if (enable_auto_gc)
21522151
run_auto_maintenance(verbosity < 0);
21532152

2153+
cleanup:
2154+
string_list_clear(&list, 0);
21542155
return result;
21552156
}

0 commit comments

Comments
 (0)