@@ -36,9 +36,10 @@ static int prune = -1; /* unspecified */
3636
3737static int all , append , dry_run , force , keep , multiple , update_head_ok , verbosity ;
3838static int progress = -1 , recurse_submodules = RECURSE_SUBMODULES_DEFAULT ;
39- static int tags = TAGS_DEFAULT , unshallow , update_shallow ;
39+ static int tags = TAGS_DEFAULT , unshallow , update_shallow , deepen ;
4040static int max_children = 1 ;
4141static const char * depth ;
42+ static const char * deepen_since ;
4243static const char * upload_pack ;
4344static struct strbuf default_rla = STRBUF_INIT ;
4445static struct transport * gtransport ;
@@ -115,6 +116,8 @@ static struct option builtin_fetch_options[] = {
115116 OPT_BOOL (0 , "progress" , & progress , N_ ("force progress reporting" )),
116117 OPT_STRING (0 , "depth" , & depth , N_ ("depth" ),
117118 N_ ("deepen history of shallow clone" )),
119+ OPT_STRING (0 , "shallow-since" , & deepen_since , N_ ("time" ),
120+ N_ ("deepen history of shallow repository based on time" )),
118121 { OPTION_SET_INT , 0 , "unshallow" , & unshallow , NULL ,
119122 N_ ("convert to a complete repository" ),
120123 PARSE_OPT_NONEG | PARSE_OPT_NOARG , NULL , 1 },
@@ -754,7 +757,7 @@ static int quickfetch(struct ref *ref_map)
754757 * really need to perform. Claiming failure now will ensure
755758 * we perform the network exchange to deepen our history.
756759 */
757- if (depth )
760+ if (deepen )
758761 return -1 ;
759762 return check_everything_connected (iterate_ref_map , 1 , & rm );
760763}
@@ -859,7 +862,7 @@ static void set_option(struct transport *transport, const char *name, const char
859862 name , transport -> url );
860863}
861864
862- static struct transport * prepare_transport (struct remote * remote )
865+ static struct transport * prepare_transport (struct remote * remote , int deepen )
863866{
864867 struct transport * transport ;
865868 transport = transport_get (remote , NULL );
@@ -870,15 +873,27 @@ static struct transport *prepare_transport(struct remote *remote)
870873 set_option (transport , TRANS_OPT_KEEP , "yes" );
871874 if (depth )
872875 set_option (transport , TRANS_OPT_DEPTH , depth );
876+ if (deepen && deepen_since )
877+ set_option (transport , TRANS_OPT_DEEPEN_SINCE , deepen_since );
873878 if (update_shallow )
874879 set_option (transport , TRANS_OPT_UPDATE_SHALLOW , "yes" );
875880 return transport ;
876881}
877882
878883static void backfill_tags (struct transport * transport , struct ref * ref_map )
879884{
880- if (transport -> cannot_reuse ) {
881- gsecondary = prepare_transport (transport -> remote );
885+ int cannot_reuse ;
886+
887+ /*
888+ * Once we have set TRANS_OPT_DEEPEN_SINCE, we can't unset it
889+ * when remote helper is used (setting it to an empty string
890+ * is not unsetting). We could extend the remote helper
891+ * protocol for that, but for now, just force a new connection
892+ * without deepen-since.
893+ */
894+ cannot_reuse = transport -> cannot_reuse || deepen_since ;
895+ if (cannot_reuse ) {
896+ gsecondary = prepare_transport (transport -> remote , 0 );
882897 transport = gsecondary ;
883898 }
884899
@@ -1095,7 +1110,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
10951110 die (_ ("No remote repository specified. Please, specify either a URL or a\n"
10961111 "remote name from which new revisions should be fetched." ));
10971112
1098- gtransport = prepare_transport (remote );
1113+ gtransport = prepare_transport (remote , 1 );
10991114
11001115 if (prune < 0 ) {
11011116 /* no command line request */
@@ -1167,6 +1182,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
11671182 /* no need to be strict, transport_set_option() will validate it again */
11681183 if (depth && atoi (depth ) < 1 )
11691184 die (_ ("depth %s is not a positive number" ), depth );
1185+ if (depth || deepen_since )
1186+ deepen = 1 ;
11701187
11711188 if (recurse_submodules != RECURSE_SUBMODULES_OFF ) {
11721189 if (recurse_submodules_default ) {
0 commit comments