Skip to content

Commit

Permalink
fetch: use goto cleanup in cmd_fetch()
Browse files Browse the repository at this point in the history
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 <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
chooglen authored and gitster committed Jan 19, 2022
1 parent 69a9c10 commit bec587d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
gtransport->smart_options->acked_commits = &acked_commits;
} else {
warning(_("Protocol does not support --negotiate-only, exiting."));
return 1;
result = 1;
goto cleanup;
}
if (server_options.nr)
gtransport->server_options = &server_options;
Expand Down Expand Up @@ -2132,8 +2133,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
strvec_clear(&options);
}

string_list_clear(&list, 0);

prepare_repo_settings(the_repository);
if (fetch_write_commit_graph > 0 ||
(fetch_write_commit_graph < 0 &&
Expand All @@ -2151,5 +2150,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (enable_auto_gc)
run_auto_maintenance(verbosity < 0);

cleanup:
string_list_clear(&list, 0);
return result;
}

0 comments on commit bec587d

Please sign in to comment.