summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-15 22:08:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-15 22:08:28 (GMT)
commitb160b6e69d5e8231cf71b3bcacef63443849d1f9 (patch)
treea9d7d4cd00f10d1b4545b3fa3596bcd24f7c907c /fetch-pack.c
parent6be44b59fc5e957b9d6e25b32b0fc38c45d50f3f (diff)
parente2842b39f4168e3cd39a53961c1e50bb940eedf1 (diff)
downloadgit-b160b6e69d5e8231cf71b3bcacef63443849d1f9.zip
git-b160b6e69d5e8231cf71b3bcacef63443849d1f9.tar.gz
git-b160b6e69d5e8231cf71b3bcacef63443849d1f9.tar.bz2
Merge branch 'jt/connectivity-check-after-unshallow'
"git fetch" sometimes failed to update the remote-tracking refs, which has been corrected. * jt/connectivity-check-after-unshallow: fetch-pack: unify ref in and out param
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index 1ab0b2d..f80a7ac 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1278,25 +1278,26 @@ static void receive_shallow_info(struct fetch_pack_args *args,
args->deepen = 1;
}
-static void receive_wanted_refs(struct packet_reader *reader, struct ref *refs)
+static void receive_wanted_refs(struct packet_reader *reader,
+ struct ref **sought, int nr_sought)
{
process_section_header(reader, "wanted-refs", 0);
while (packet_reader_read(reader) == PACKET_READ_NORMAL) {
struct object_id oid;
const char *end;
- struct ref *r = NULL;
+ int i;
if (parse_oid_hex(reader->line, &oid, &end) || *end++ != ' ')
die(_("expected wanted-ref, got '%s'"), reader->line);
- for (r = refs; r; r = r->next) {
- if (!strcmp(end, r->name)) {
- oidcpy(&r->old_oid, &oid);
+ for (i = 0; i < nr_sought; i++) {
+ if (!strcmp(end, sought[i]->name)) {
+ oidcpy(&sought[i]->old_oid, &oid);
break;
}
}
- if (!r)
+ if (i == nr_sought)
die(_("unexpected wanted-ref: '%s'"), reader->line);
}
@@ -1381,7 +1382,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
receive_shallow_info(args, &reader);
if (process_section_header(&reader, "wanted-refs", 1))
- receive_wanted_refs(&reader, ref);
+ receive_wanted_refs(&reader, sought, nr_sought);
/* get the pack */
process_section_header(&reader, "packfile", 0);
@@ -1448,13 +1449,12 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr)
}
static void update_shallow(struct fetch_pack_args *args,
- struct ref *refs,
+ struct ref **sought, int nr_sought,
struct shallow_info *si)
{
struct oid_array ref = OID_ARRAY_INIT;
int *status;
int i;
- struct ref *r;
if (args->deepen && alternate_shallow_file) {
if (*alternate_shallow_file == '\0') { /* --unshallow */
@@ -1496,8 +1496,8 @@ static void update_shallow(struct fetch_pack_args *args,
remove_nonexistent_theirs_shallow(si);
if (!si->nr_ours && !si->nr_theirs)
return;
- for (r = refs; r; r = r->next)
- oid_array_append(&ref, &r->old_oid);
+ for (i = 0; i < nr_sought; i++)
+ oid_array_append(&ref, &sought[i]->old_oid);
si->ref = &ref;
if (args->update_shallow) {
@@ -1531,12 +1531,12 @@ static void update_shallow(struct fetch_pack_args *args,
* remote is also shallow, check what ref is safe to update
* without updating .git/shallow
*/
- status = xcalloc(ref.nr, sizeof(*status));
+ status = xcalloc(nr_sought, sizeof(*status));
assign_shallow_commits_to_refs(si, NULL, status);
if (si->nr_ours || si->nr_theirs) {
- for (r = refs, i = 0; r; r = r->next, i++)
+ for (i = 0; i < nr_sought; i++)
if (status[i])
- r->status = REF_STATUS_REJECT_SHALLOW;
+ sought[i]->status = REF_STATUS_REJECT_SHALLOW;
}
free(status);
oid_array_clear(&ref);
@@ -1599,7 +1599,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
args->connectivity_checked = 1;
}
- update_shallow(args, ref_cpy, &si);
+ update_shallow(args, sought, nr_sought, &si);
cleanup:
clear_shallow_info(&si);
return ref_cpy;