@@ -40,7 +40,8 @@ static const char * const builtin_clone_usage[] = {
40
40
41
41
static int option_no_checkout , option_bare , option_mirror , option_single_branch = -1 ;
42
42
static 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 ;
44
45
static char * option_origin = NULL ;
45
46
static char * option_branch = NULL ;
46
47
static const char * real_git_dir ;
@@ -86,6 +87,8 @@ static struct option builtin_clone_options[] = {
86
87
N_ ("path to git-upload-pack on the remote" )),
87
88
OPT_STRING (0 , "depth" , & option_depth , N_ ("depth" ),
88
89
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" )),
89
92
OPT_BOOL (0 , "single-branch" , & option_single_branch ,
90
93
N_ ("clone only one branch, HEAD or --branch" )),
91
94
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)
849
852
usage_msg_opt (_ ("You must specify a repository to clone." ),
850
853
builtin_clone_usage , builtin_clone_options );
851
854
855
+ if (option_depth || option_since )
856
+ deepen = 1 ;
852
857
if (option_single_branch == -1 )
853
- option_single_branch = option_depth ? 1 : 0 ;
858
+ option_single_branch = deepen ? 1 : 0 ;
854
859
855
860
if (option_mirror )
856
861
option_bare = 1 ;
@@ -976,6 +981,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
976
981
if (is_local ) {
977
982
if (option_depth )
978
983
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." ));
979
986
if (!access (mkpath ("%s/shallow" , path ), F_OK )) {
980
987
if (option_local > 0 )
981
988
warning (_ ("source repository is shallow, ignoring --local" ));
@@ -994,14 +1001,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
994
1001
if (option_depth )
995
1002
transport_set_option (transport , TRANS_OPT_DEPTH ,
996
1003
option_depth );
1004
+ if (option_since )
1005
+ transport_set_option (transport , TRANS_OPT_DEEPEN_SINCE ,
1006
+ option_since );
997
1007
if (option_single_branch )
998
1008
transport_set_option (transport , TRANS_OPT_FOLLOWTAGS , "1" );
999
1009
1000
1010
if (option_upload_pack )
1001
1011
transport_set_option (transport , TRANS_OPT_UPLOADPACK ,
1002
1012
option_upload_pack );
1003
1013
1004
- if (transport -> smart_options && !option_depth )
1014
+ if (transport -> smart_options && !deepen )
1005
1015
transport -> smart_options -> check_self_contained_and_connected = 1 ;
1006
1016
1007
1017
refs = transport_get_remote_refs (transport );
0 commit comments