From f4609b896fac842433bd495c166d5987852a6a73 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 21 Nov 2020 19:20:35 +0100 Subject: merge(3p/git): Merge git subtree at v2.29.2 This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because there is some breakage in the git build related to the netrc credentials helper which someone has taken care of in nixpkgs. The stable channel is not used for anything other than git, so this should be fine. Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb --- third_party/git/ls-refs.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'third_party/git/ls-refs.c') diff --git a/third_party/git/ls-refs.c b/third_party/git/ls-refs.c index 818aef70a09e..a1e0b473e447 100644 --- a/third_party/git/ls-refs.c +++ b/third_party/git/ls-refs.c @@ -2,7 +2,7 @@ #include "repository.h" #include "refs.h" #include "remote.h" -#include "argv-array.h" +#include "strvec.h" #include "ls-refs.h" #include "pkt-line.h" #include "config.h" @@ -11,15 +11,15 @@ * Check if one of the prefixes is a prefix of the ref. * If no prefixes were provided, all refs match. */ -static int ref_match(const struct argv_array *prefixes, const char *refname) +static int ref_match(const struct strvec *prefixes, const char *refname) { int i; - if (!prefixes->argc) + if (!prefixes->nr) return 1; /* no restriction */ - for (i = 0; i < prefixes->argc; i++) { - const char *prefix = prefixes->argv[i]; + for (i = 0; i < prefixes->nr; i++) { + const char *prefix = prefixes->v[i]; if (starts_with(refname, prefix)) return 1; @@ -31,7 +31,7 @@ static int ref_match(const struct argv_array *prefixes, const char *refname) struct ls_refs_data { unsigned peel; unsigned symrefs; - struct argv_array prefixes; + struct strvec prefixes; }; static int send_ref(const char *refname, const struct object_id *oid, @@ -84,7 +84,7 @@ static int ls_refs_config(const char *var, const char *value, void *data) return parse_hide_refs_config(var, value, "uploadpack"); } -int ls_refs(struct repository *r, struct argv_array *keys, +int ls_refs(struct repository *r, struct strvec *keys, struct packet_reader *request) { struct ls_refs_data data; @@ -93,7 +93,7 @@ int ls_refs(struct repository *r, struct argv_array *keys, git_config(ls_refs_config, NULL); - while (packet_reader_read(request) != PACKET_READ_FLUSH) { + while (packet_reader_read(request) == PACKET_READ_NORMAL) { const char *arg = request->line; const char *out; @@ -102,12 +102,15 @@ int ls_refs(struct repository *r, struct argv_array *keys, else if (!strcmp("symrefs", arg)) data.symrefs = 1; else if (skip_prefix(arg, "ref-prefix ", &out)) - argv_array_push(&data.prefixes, out); + strvec_push(&data.prefixes, out); } + if (request->status != PACKET_READ_FLUSH) + die(_("expected flush after ls-refs arguments")); + head_ref_namespaced(send_ref, &data); for_each_namespaced_ref(send_ref, &data); packet_flush(1); - argv_array_clear(&data.prefixes); + strvec_clear(&data.prefixes); return 0; } -- cgit 1.4.1