/
uis
/
git
/
x
/
uis
/
git
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fetch-pack: unify ref in and out param
[git/git.git]
/
fetch-pack.c
diff --git
a/fetch-pack.c
b/fetch-pack.c
index
60bbffb
..
660259e
100644
(file)
--- a/
fetch-pack.c
+++ b/
fetch-pack.c
@@
-1338,25
+1338,26
@@
static void receive_shallow_info(struct fetch_pack_args *args,
args->deepen = 1;
}
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;
{
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);
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;
}
}
break;
}
}
- if (
!r
)
+ if (
i == nr_sought
)
die("unexpected wanted-ref: '%s'", reader->line);
}
die("unexpected wanted-ref: '%s'", reader->line);
}
@@
-1439,7
+1440,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_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);
/* get the pack */
process_section_header(&reader, "packfile", 0);
@@
-1503,13
+1504,12
@@
static int remove_duplicates_in_refs(struct ref **ref, int nr)
}
static void update_shallow(struct fetch_pack_args *args,
}
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 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 */
if (args->deepen && alternate_shallow_file) {
if (*alternate_shallow_file == '\0') { /* --unshallow */
@@
-1551,8
+1551,8
@@
static void update_shallow(struct fetch_pack_args *args,
remove_nonexistent_theirs_shallow(si);
if (!si->nr_ours && !si->nr_theirs)
return;
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) {
si->ref = &ref;
if (args->update_shallow) {
@@
-1586,12
+1586,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
*/
* 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) {
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])
if (status[i])
-
r
->status = REF_STATUS_REJECT_SHALLOW;
+
sought[i]
->status = REF_STATUS_REJECT_SHALLOW;
}
free(status);
oid_array_clear(&ref);
}
free(status);
oid_array_clear(&ref);
@@
-1654,7
+1654,7
@@
struct ref *fetch_pack(struct fetch_pack_args *args,
args->connectivity_checked = 1;
}
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;
cleanup:
clear_shallow_info(&si);
return ref_cpy;