summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-12-05 20:02:37 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-12-10 16:14:16 -0800
commita796ccee5198c6ae11dd73c837f3ec46aaa1e8bf (patch)
tree53b45c6d01fcc6dfe6444d1fe92e68ba917dc991 /fetch-pack.c
parentshallow.c: steps 6 and 7 to select new commits for .git/shallow (diff)
downloadtgif-a796ccee5198c6ae11dd73c837f3ec46aaa1e8bf.tar.xz
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>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index 0e7483e1fe..35d097e1b1 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -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,
@@ -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;
}