fetch-pack: put shallow info in output parameter
Expand the transport fetch method signature, by adding an output parameter, to allow transports to return information about the refs they have fetched. Then communicate shallow status information through this mechanism instead of by modifying the input list of refs. This does require clients to sometimes generate the ref map twice: once from the list of refs provided by the remote (as is currently done) and potentially once from the new list of refs that the fetch mechanism provides. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6d1700d564
commit
989b8c4452
15
fetch-pack.c
15
fetch-pack.c
@ -1470,12 +1470,13 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr)
|
||||
}
|
||||
|
||||
static void update_shallow(struct fetch_pack_args *args,
|
||||
struct ref **sought, int nr_sought,
|
||||
struct ref *refs,
|
||||
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 */
|
||||
@ -1517,8 +1518,8 @@ static void update_shallow(struct fetch_pack_args *args,
|
||||
remove_nonexistent_theirs_shallow(si);
|
||||
if (!si->nr_ours && !si->nr_theirs)
|
||||
return;
|
||||
for (i = 0; i < nr_sought; i++)
|
||||
oid_array_append(&ref, &sought[i]->old_oid);
|
||||
for (r = refs; r; r = r->next)
|
||||
oid_array_append(&ref, &r->old_oid);
|
||||
si->ref = &ref;
|
||||
|
||||
if (args->update_shallow) {
|
||||
@ -1552,12 +1553,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(nr_sought, sizeof(*status));
|
||||
status = xcalloc(ref.nr, sizeof(*status));
|
||||
assign_shallow_commits_to_refs(si, NULL, status);
|
||||
if (si->nr_ours || si->nr_theirs) {
|
||||
for (i = 0; i < nr_sought; i++)
|
||||
for (r = refs, i = 0; r; r = r->next, i++)
|
||||
if (status[i])
|
||||
sought[i]->status = REF_STATUS_REJECT_SHALLOW;
|
||||
r->status = REF_STATUS_REJECT_SHALLOW;
|
||||
}
|
||||
free(status);
|
||||
oid_array_clear(&ref);
|
||||
@ -1591,7 +1592,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
|
||||
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought,
|
||||
&si, pack_lockfile);
|
||||
reprepare_packed_git(the_repository);
|
||||
update_shallow(args, sought, nr_sought, &si);
|
||||
update_shallow(args, ref_cpy, &si);
|
||||
clear_shallow_info(&si);
|
||||
return ref_cpy;
|
||||
}
|
||||
|
Reference in New Issue
Block a user