Skip to content

Commit

Permalink
fetch-pack.c: move shallow update code out of fetch_pack()
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Dec 11, 2013
1 parent 8e27738 commit a796cce
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,18 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr)
return dst;
}

static void update_shallow(struct fetch_pack_args *args)
{
if (args->depth > 0 && alternate_shallow_file) {
if (*alternate_shallow_file == '\0') { /* --unshallow */
unlink_or_warn(git_path("shallow"));
rollback_lock_file(&shallow_lock);
} else
commit_lock_file(&shallow_lock);
return;
}
}

struct ref *fetch_pack(struct fetch_pack_args *args,
int fd[], struct child_process *conn,
const struct ref *ref,
Expand All @@ -943,15 +955,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
die("no matching remote head");
}
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought, pack_lockfile);

if (args->depth > 0 && alternate_shallow_file) {
if (*alternate_shallow_file == '\0') { /* --unshallow */
unlink_or_warn(git_path("shallow"));
rollback_lock_file(&shallow_lock);
} else
commit_lock_file(&shallow_lock);
}

update_shallow(args);
reprepare_packed_git();
return ref_cpy;
}

0 comments on commit a796cce

Please sign in to comment.