clone: define shallow clone boundary with --shallow-exclude
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
a45a260086
commit
859e5df916
|
@ -196,6 +196,11 @@ objects from the source repository into a pack in the cloned repository.
|
||||||
--shallow-since=<date>::
|
--shallow-since=<date>::
|
||||||
Create a shallow clone with a history after the specified time.
|
Create a shallow clone with a history after the specified time.
|
||||||
|
|
||||||
|
--shallow-exclude=<revision>::
|
||||||
|
Create a shallow clone with a history, excluding commits
|
||||||
|
reachable from a specified remote branch or tag. This option
|
||||||
|
can be specified multiple times.
|
||||||
|
|
||||||
--[no-]single-branch::
|
--[no-]single-branch::
|
||||||
Clone only the history leading to the tip of a single branch,
|
Clone only the history leading to the tip of a single branch,
|
||||||
either specified by the `--branch` option or the primary
|
either specified by the `--branch` option or the primary
|
||||||
|
|
|
@ -44,6 +44,7 @@ static int deepen;
|
||||||
static char *option_template, *option_depth, *option_since;
|
static char *option_template, *option_depth, *option_since;
|
||||||
static char *option_origin = NULL;
|
static char *option_origin = NULL;
|
||||||
static char *option_branch = NULL;
|
static char *option_branch = NULL;
|
||||||
|
static struct string_list option_not = STRING_LIST_INIT_NODUP;
|
||||||
static const char *real_git_dir;
|
static const char *real_git_dir;
|
||||||
static char *option_upload_pack = "git-upload-pack";
|
static char *option_upload_pack = "git-upload-pack";
|
||||||
static int option_verbosity;
|
static int option_verbosity;
|
||||||
|
@ -89,6 +90,8 @@ static struct option builtin_clone_options[] = {
|
||||||
N_("create a shallow clone of that depth")),
|
N_("create a shallow clone of that depth")),
|
||||||
OPT_STRING(0, "shallow-since", &option_since, N_("time"),
|
OPT_STRING(0, "shallow-since", &option_since, N_("time"),
|
||||||
N_("create a shallow clone since a specific time")),
|
N_("create a shallow clone since a specific time")),
|
||||||
|
OPT_STRING_LIST(0, "shallow-exclude", &option_not, N_("revision"),
|
||||||
|
N_("deepen history of shallow clone by excluding rev")),
|
||||||
OPT_BOOL(0, "single-branch", &option_single_branch,
|
OPT_BOOL(0, "single-branch", &option_single_branch,
|
||||||
N_("clone only one branch, HEAD or --branch")),
|
N_("clone only one branch, HEAD or --branch")),
|
||||||
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
|
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
|
||||||
|
@ -852,7 +855,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||||
usage_msg_opt(_("You must specify a repository to clone."),
|
usage_msg_opt(_("You must specify a repository to clone."),
|
||||||
builtin_clone_usage, builtin_clone_options);
|
builtin_clone_usage, builtin_clone_options);
|
||||||
|
|
||||||
if (option_depth || option_since)
|
if (option_depth || option_since || option_not.nr)
|
||||||
deepen = 1;
|
deepen = 1;
|
||||||
if (option_single_branch == -1)
|
if (option_single_branch == -1)
|
||||||
option_single_branch = deepen ? 1 : 0;
|
option_single_branch = deepen ? 1 : 0;
|
||||||
|
@ -983,6 +986,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||||
warning(_("--depth is ignored in local clones; use file:// instead."));
|
warning(_("--depth is ignored in local clones; use file:// instead."));
|
||||||
if (option_since)
|
if (option_since)
|
||||||
warning(_("--shallow-since is ignored in local clones; use file:// instead."));
|
warning(_("--shallow-since is ignored in local clones; use file:// instead."));
|
||||||
|
if (option_not.nr)
|
||||||
|
warning(_("--shallow-exclude is ignored in local clones; use file:// instead."));
|
||||||
if (!access(mkpath("%s/shallow", path), F_OK)) {
|
if (!access(mkpath("%s/shallow", path), F_OK)) {
|
||||||
if (option_local > 0)
|
if (option_local > 0)
|
||||||
warning(_("source repository is shallow, ignoring --local"));
|
warning(_("source repository is shallow, ignoring --local"));
|
||||||
|
@ -1004,6 +1009,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||||
if (option_since)
|
if (option_since)
|
||||||
transport_set_option(transport, TRANS_OPT_DEEPEN_SINCE,
|
transport_set_option(transport, TRANS_OPT_DEEPEN_SINCE,
|
||||||
option_since);
|
option_since);
|
||||||
|
if (option_not.nr)
|
||||||
|
transport_set_option(transport, TRANS_OPT_DEEPEN_NOT,
|
||||||
|
(const char *)&option_not);
|
||||||
if (option_single_branch)
|
if (option_single_branch)
|
||||||
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
|
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue