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>

Nguyễn Thái Ngọc Duy committed Dec 5, 2013 at 20:02 UTC a796ccee5198c6ae11dd73c837f3ec46aaa1e8bf
1 file changed +13 -9
fetch-pack.c
+13 -9
@@ -925,6 +925,18 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr)
925 return dst;
926 }
927
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 +
940 struct ref *fetch_pack(struct fetch_pack_args *args,
941 int fd[], struct child_process *conn,
942 const struct ref *ref,
@@ -943,15 +955,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
955 die("no matching remote head");
956 }
957 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);
959 reprepare_packed_git();
960 return ref_cpy;
961 }