Skip to content

Commit a796cce

Browse files
pcloudsgitster
authored andcommitted
fetch-pack.c: move shallow update code out of fetch_pack()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8e27738 commit a796cce

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

fetch-pack.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,18 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr)
925925
return dst;
926926
}
927927

928+
static void update_shallow(struct fetch_pack_args *args)
929+
{
930+
if (args->depth > 0 && alternate_shallow_file) {
931+
if (*alternate_shallow_file == '\0') { /* --unshallow */
932+
unlink_or_warn(git_path("shallow"));
933+
rollback_lock_file(&shallow_lock);
934+
} else
935+
commit_lock_file(&shallow_lock);
936+
return;
937+
}
938+
}
939+
928940
struct ref *fetch_pack(struct fetch_pack_args *args,
929941
int fd[], struct child_process *conn,
930942
const struct ref *ref,
@@ -943,15 +955,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
943955
die("no matching remote head");
944956
}
945957
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought, pack_lockfile);
946-
947-
if (args->depth > 0 && alternate_shallow_file) {
948-
if (*alternate_shallow_file == '\0') { /* --unshallow */
949-
unlink_or_warn(git_path("shallow"));
950-
rollback_lock_file(&shallow_lock);
951-
} else
952-
commit_lock_file(&shallow_lock);
953-
}
954-
958+
update_shallow(args);
955959
reprepare_packed_git();
956960
return ref_cpy;
957961
}

0 commit comments

Comments
 (0)