1010#include "sideband.h"
1111#include "argv-array.h"
1212#include "credential.h"
13+ #include "sha1-array.h"
1314
1415static struct remote * remote ;
1516/* always ends with a trailing slash */
@@ -20,6 +21,8 @@ struct options {
2021 unsigned long depth ;
2122 unsigned progress : 1 ,
2223 check_self_contained_and_connected : 1 ,
24+ cloning : 1 ,
25+ update_shallow : 1 ,
2326 followtags : 1 ,
2427 dry_run : 1 ,
2528 thin : 1 ;
@@ -87,8 +90,23 @@ static int set_option(const char *name, const char *value)
8790 string_list_append (& cas_options , val .buf );
8891 strbuf_release (& val );
8992 return 0 ;
90- }
91- else {
93+ } else if (!strcmp (name , "cloning" )) {
94+ if (!strcmp (value , "true" ))
95+ options .cloning = 1 ;
96+ else if (!strcmp (value , "false" ))
97+ options .cloning = 0 ;
98+ else
99+ return -1 ;
100+ return 0 ;
101+ } else if (!strcmp (name , "update-shallow" )) {
102+ if (!strcmp (value , "true" ))
103+ options .update_shallow = 1 ;
104+ else if (!strcmp (value , "false" ))
105+ options .update_shallow = 0 ;
106+ else
107+ return -1 ;
108+ return 0 ;
109+ } else {
92110 return 1 /* unsupported */ ;
93111 }
94112}
@@ -99,6 +117,7 @@ struct discovery {
99117 char * buf ;
100118 size_t len ;
101119 struct ref * refs ;
120+ struct sha1_array shallow ;
102121 unsigned proto_git : 1 ;
103122};
104123static struct discovery * last_discovery ;
@@ -107,7 +126,7 @@ static struct ref *parse_git_refs(struct discovery *heads, int for_push)
107126{
108127 struct ref * list = NULL ;
109128 get_remote_heads (-1 , heads -> buf , heads -> len , & list ,
110- for_push ? REF_NORMAL : 0 , NULL , NULL );
129+ for_push ? REF_NORMAL : 0 , NULL , & heads -> shallow );
111130 return list ;
112131}
113132
@@ -168,6 +187,7 @@ static void free_discovery(struct discovery *d)
168187 if (d ) {
169188 if (d == last_discovery )
170189 last_discovery = NULL ;
190+ free (d -> shallow .sha1 );
171191 free (d -> buf_alloc );
172192 free_refs (d -> refs );
173193 free (d );
@@ -688,7 +708,7 @@ static int fetch_git(struct discovery *heads,
688708 struct strbuf preamble = STRBUF_INIT ;
689709 char * depth_arg = NULL ;
690710 int argc = 0 , i , err ;
691- const char * argv [16 ];
711+ const char * argv [17 ];
692712
693713 argv [argc ++ ] = "fetch-pack" ;
694714 argv [argc ++ ] = "--stateless-rpc" ;
@@ -704,6 +724,10 @@ static int fetch_git(struct discovery *heads,
704724 }
705725 if (options .check_self_contained_and_connected )
706726 argv [argc ++ ] = "--check-self-contained-and-connected" ;
727+ if (options .cloning )
728+ argv [argc ++ ] = "--cloning" ;
729+ if (options .update_shallow )
730+ argv [argc ++ ] = "--update-shallow" ;
707731 if (!options .progress )
708732 argv [argc ++ ] = "--no-progress" ;
709733 if (options .depth ) {
0 commit comments