Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/clone.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index efb1e6f..65c4cee 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -23,6 +23,7 @@ #include "branch.h" #include "remote.h" #include "run-command.h" +#include "narrow-tree.h" /* * Overall FIXMEs: @@ -39,7 +40,7 @@ static const char * const builtin_clone_usage[] = { static int option_no_checkout, option_bare, option_mirror; static int option_local, option_no_hardlinks, option_shared, option_recursive; -static char *option_template, *option_reference, *option_depth; +static char *option_template, *option_reference, *option_depth, *option_narrow; static char *option_origin = NULL; static char *option_branch = NULL; static char *option_upload_pack = "git-upload-pack"; @@ -78,6 +79,8 @@ static struct option builtin_clone_options[] = { "path to git-upload-pack on the remote"), OPT_STRING(0, "depth", &option_depth, "depth", "create a shallow clone of that depth"), + OPT_STRING(0, "narrow", &option_narrow, "tree", + "narrow clone"), OPT_END() }; @@ -515,6 +518,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) strbuf_reset(&value); if (path && !is_bundle) { + if (option_narrow) + die("--narrow is not really for local clone. Please consider --shared"); refs = clone_local(path, git_dir); mapped_refs = wanted_peer_refs(refs, refspec); } else { @@ -530,6 +535,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix) transport_set_option(transport, TRANS_OPT_DEPTH, option_depth); + /* Do this early in order to set get_narrow_prefix() != NULL */ + if (option_narrow) { + int fd = open(git_path("narrow"), O_RDWR | O_CREAT, 0644); + write(fd, option_narrow, strlen(option_narrow)); + close(fd); + check_narrow_prefix(); + } + transport_set_verbosity(transport, option_verbosity, option_progress); if (option_upload_pack) -- 1.7.1.rc1.69.g24c2f7 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html