summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorGlen Choo <chooglen@google.com>2022-01-19 00:00:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-01-19 00:22:53 (GMT)
commitbec587d4c11e851c1e7b5ed7890d627c8346d1cb (patch)
treec64617402e4eda21771b4c10b0ee4765732866b4 /builtin/fetch.c
parent69a9c10c95e28df457e33b3c7400b16caf2e2962 (diff)
downloadgit-bec587d4c11e851c1e7b5ed7890d627c8346d1cb.zip
git-bec587d4c11e851c1e7b5ed7890d627c8346d1cb.tar.gz
git-bec587d4c11e851c1e7b5ed7890d627c8346d1cb.tar.bz2
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 <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f7abbc3..eab73d7 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -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;
@@ -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 &&
@@ -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;
}