Skip to content

Commit 79891cb

Browse files
pcloudsgitster
authored andcommitted
fetch-pack: use a separate flag for fetch in deepening mode
The shallow repo could be deepened or shortened when then user gives --depth. But in future that won't be the only way to deepen/shorten a repo. Stop relying on args->depth in this mode. Future deepening methods can simply set this flag on instead of updating all these if expressions. The new name "deepen" was chosen after the command to define shallow boundary in pack protocol. New commands also follow this tradition. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1dd73e2 commit 79891cb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

fetch-pack.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ enum ack_type {
197197

198198
static void consume_shallow_list(struct fetch_pack_args *args, int fd)
199199
{
200-
if (args->stateless_rpc && args->depth > 0) {
200+
if (args->stateless_rpc && args->deepen) {
201201
/* If we sent a depth we will get back "duplicate"
202202
* shallow and unshallow commands every time there
203203
* is a block of have lines exchanged.
@@ -348,7 +348,7 @@ static int find_common(struct fetch_pack_args *args,
348348
packet_buf_flush(&req_buf);
349349
state_len = req_buf.len;
350350

351-
if (args->depth > 0) {
351+
if (args->deepen) {
352352
char *line;
353353
const char *arg;
354354
unsigned char sha1[20];
@@ -557,7 +557,7 @@ static void filter_refs(struct fetch_pack_args *args,
557557
}
558558

559559
if (!keep && args->fetch_all &&
560-
(!args->depth || !starts_with(ref->name, "refs/tags/")))
560+
(!args->deepen || !starts_with(ref->name, "refs/tags/")))
561561
keep = 1;
562562

563563
if (keep) {
@@ -627,7 +627,7 @@ static int everything_local(struct fetch_pack_args *args,
627627
}
628628
}
629629

630-
if (!args->depth) {
630+
if (!args->deepen) {
631631
for_each_ref(mark_complete_oid, NULL);
632632
for_each_alternate_ref(mark_alternate_complete, NULL);
633633
commit_list_sort_by_date(&complete);
@@ -812,6 +812,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
812812

813813
if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
814814
die(_("Server does not support shallow clients"));
815+
if (args->depth > 0)
816+
args->deepen = 1;
815817
if (server_supports("multi_ack_detailed")) {
816818
print_verbose(args, _("Server supports multi_ack_detailed"));
817819
multi_ack = 2;
@@ -872,7 +874,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
872874

873875
if (args->stateless_rpc)
874876
packet_flush(fd[1]);
875-
if (args->depth > 0)
877+
if (args->deepen)
876878
setup_alternate_shallow(&shallow_lock, &alternate_shallow_file,
877879
NULL);
878880
else if (si->nr_ours || si->nr_theirs)
@@ -939,7 +941,7 @@ static void update_shallow(struct fetch_pack_args *args,
939941
int *status;
940942
int i;
941943

942-
if (args->depth > 0 && alternate_shallow_file) {
944+
if (args->deepen && alternate_shallow_file) {
943945
if (*alternate_shallow_file == '\0') { /* --unshallow */
944946
unlink_or_warn(git_path_shallow());
945947
rollback_lock_file(&shallow_lock);

fetch-pack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct fetch_pack_args {
2525
unsigned self_contained_and_connected:1;
2626
unsigned cloning:1;
2727
unsigned update_shallow:1;
28+
unsigned deepen:1;
2829
};
2930

3031
/*

0 commit comments

Comments
 (0)