@@ -40,7 +40,8 @@ static const char * const builtin_clone_usage[] = {
4040
4141static int option_no_checkout , option_bare , option_mirror , option_single_branch = -1 ;
4242static int option_local = -1 , option_no_hardlinks , option_shared , option_recursive ;
43- static char * option_template , * option_depth ;
43+ static int deepen ;
44+ static char * option_template , * option_depth , * option_since ;
4445static char * option_origin = NULL ;
4546static char * option_branch = NULL ;
4647static const char * real_git_dir ;
@@ -86,6 +87,8 @@ static struct option builtin_clone_options[] = {
8687 N_ ("path to git-upload-pack on the remote" )),
8788 OPT_STRING (0 , "depth" , & option_depth , N_ ("depth" ),
8889 N_ ("create a shallow clone of that depth" )),
90+ OPT_STRING (0 , "shallow-since" , & option_since , N_ ("time" ),
91+ N_ ("create a shallow clone since a specific time" )),
8992 OPT_BOOL (0 , "single-branch" , & option_single_branch ,
9093 N_ ("clone only one branch, HEAD or --branch" )),
9194 OPT_STRING (0 , "separate-git-dir" , & real_git_dir , N_ ("gitdir" ),
@@ -849,8 +852,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
849852 usage_msg_opt (_ ("You must specify a repository to clone." ),
850853 builtin_clone_usage , builtin_clone_options );
851854
855+ if (option_depth || option_since )
856+ deepen = 1 ;
852857 if (option_single_branch == -1 )
853- option_single_branch = option_depth ? 1 : 0 ;
858+ option_single_branch = deepen ? 1 : 0 ;
854859
855860 if (option_mirror )
856861 option_bare = 1 ;
@@ -976,6 +981,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
976981 if (is_local ) {
977982 if (option_depth )
978983 warning (_ ("--depth is ignored in local clones; use file:// instead." ));
984+ if (option_since )
985+ warning (_ ("--shallow-since is ignored in local clones; use file:// instead." ));
979986 if (!access (mkpath ("%s/shallow" , path ), F_OK )) {
980987 if (option_local > 0 )
981988 warning (_ ("source repository is shallow, ignoring --local" ));
@@ -994,14 +1001,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
9941001 if (option_depth )
9951002 transport_set_option (transport , TRANS_OPT_DEPTH ,
9961003 option_depth );
1004+ if (option_since )
1005+ transport_set_option (transport , TRANS_OPT_DEEPEN_SINCE ,
1006+ option_since );
9971007 if (option_single_branch )
9981008 transport_set_option (transport , TRANS_OPT_FOLLOWTAGS , "1" );
9991009
10001010 if (option_upload_pack )
10011011 transport_set_option (transport , TRANS_OPT_UPLOADPACK ,
10021012 option_upload_pack );
10031013
1004- if (transport -> smart_options && !option_depth )
1014+ if (transport -> smart_options && !deepen )
10051015 transport -> smart_options -> check_self_contained_and_connected = 1 ;
10061016
10071017 refs = transport_get_remote_refs (transport );
0 commit comments