diff options
Diffstat (limited to 'builtin/ls-remote.c')
-rw-r--r-- | builtin/ls-remote.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 6ef519514b..f4fd823af8 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -45,7 +45,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) int show_symref_target = 0; const char *uploadpack = NULL; const char **pattern = NULL; - struct argv_array ref_prefixes = ARGV_ARRAY_INIT; + struct transport_ls_refs_options transport_options = + TRANSPORT_LS_REFS_OPTIONS_INIT; int i; struct string_list server_options = STRING_LIST_INIT_DUP; @@ -83,18 +84,22 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) PARSE_OPT_STOP_AT_NON_OPTION); dest = argv[0]; + packet_trace_identity("ls-remote"); + + UNLEAK(sorting); + if (argc > 1) { int i; - pattern = xcalloc(argc, sizeof(const char *)); + CALLOC_ARRAY(pattern, argc); for (i = 1; i < argc; i++) { pattern[i - 1] = xstrfmt("*/%s", argv[i]); } } if (flags & REF_TAGS) - argv_array_push(&ref_prefixes, "refs/tags/"); + strvec_push(&transport_options.ref_prefixes, "refs/tags/"); if (flags & REF_HEADS) - argv_array_push(&ref_prefixes, "refs/heads/"); + strvec_push(&transport_options.ref_prefixes, "refs/heads/"); remote = remote_get(dest); if (!remote) { @@ -107,7 +112,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) if (get_url) { printf("%s\n", *remote->url); - UNLEAK(sorting); return 0; } @@ -117,10 +121,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) if (server_options.nr) transport->server_options = &server_options; - ref = transport_get_remote_refs(transport, &ref_prefixes); - if (transport_disconnect(transport)) { - UNLEAK(sorting); - return 1; + ref = transport_get_remote_refs(transport, &transport_options); + if (ref) { + int hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport)); + repo_set_hash_algo(the_repository, hash_algo); } if (!dest && !quiet) @@ -146,7 +150,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) status = 0; /* we found something */ } - UNLEAK(sorting); ref_array_clear(&ref_array); + if (transport_disconnect(transport)) + return 1; return status; } |