summaryrefslogtreecommitdiff
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-09-22 05:24:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-22 18:22:47 (GMT)
commit72c5f88311dab7149fcca1f6029414ccb776fee8 (patch)
tree1946c5cd7dce0399a852661ad2e35c088184a61e /builtin/submodule--helper.c
parent02c6c14d6c304f094b680f583a1dd6e4fe75736c (diff)
downloadgit-72c5f88311dab7149fcca1f6029414ccb776fee8.zip
git-72c5f88311dab7149fcca1f6029414ccb776fee8.tar.gz
git-72c5f88311dab7149fcca1f6029414ccb776fee8.tar.bz2
clone: pass --progress decision to recursive submodules
When cloning with "--recursive", we'd generally expect submodules to show progress reports if the main clone did, too. In older versions of git, this mostly worked out of the box. Since we show progress by default when stderr is a tty, and since the child clones inherit the parent stderr, then both processes would come to the same decision by default. If the parent clone was asked for "--quiet", we passed down "--quiet" to the child. However, if stderr was not a tty and the user specified "--progress", we did not propagate this to the child. That's a minor bug, but things got much worse when we switched recently to submodule--helper's update_clone command. With that change, the stderr of the child clones are always connected to a pipe, and we never output progress at all. This patch teaches git-submodule and git-submodule--helper how to pass down an explicit "--progress" flag when cloning. The clone command then decides to propagate that flag based on the cloning decision made earlier (which takes into account isatty(2) of the parent process, existing --progress or --quiet flags, etc). Since the child processes always run without a tty on stderr, we don't have to worry about passing an explicit "--no-progress"; it's the default for them. This fixes the recent loss of progress during recursive clones. And as a bonus, it makes: git clone --recursive --progress ... 2>&1 | cat work by triggering progress explicitly in the children. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 9d79f19..a0c3427 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -442,7 +442,8 @@ static int module_name(int argc, const char **argv, const char *prefix)
}
static int clone_submodule(const char *path, const char *gitdir, const char *url,
- const char *depth, struct string_list *reference, int quiet)
+ const char *depth, struct string_list *reference,
+ int quiet, int progress)
{
struct child_process cp = CHILD_PROCESS_INIT;
@@ -450,6 +451,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
argv_array_push(&cp.args, "--no-checkout");
if (quiet)
argv_array_push(&cp.args, "--quiet");
+ if (progress)
+ argv_array_push(&cp.args, "--progress");
if (depth && *depth)
argv_array_pushl(&cp.args, "--depth", depth, NULL);
if (reference->nr) {
@@ -574,6 +577,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
{
const char *name = NULL, *url = NULL, *depth = NULL;
int quiet = 0;
+ int progress = 0;
FILE *submodule_dot_git;
char *p, *path = NULL, *sm_gitdir;
struct strbuf rel_path = STRBUF_INIT;
@@ -600,6 +604,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
N_("string"),
N_("depth for shallow clones")),
OPT__QUIET(&quiet, "Suppress output for cloning a submodule"),
+ OPT_BOOL(0, "progress", &progress,
+ N_("force cloning progress")),
OPT_END()
};
@@ -633,7 +639,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
prepare_possible_alternates(name, &reference);
- if (clone_submodule(path, sm_gitdir, url, depth, &reference, quiet))
+ if (clone_submodule(path, sm_gitdir, url, depth, &reference,
+ quiet, progress))
die(_("clone of '%s' into submodule path '%s' failed"),
url, path);
} else {
@@ -683,6 +690,7 @@ struct submodule_update_clone {
struct submodule_update_strategy update;
/* configuration parameters which are passed on to the children */
+ int progress;
int quiet;
int recommend_shallow;
struct string_list references;
@@ -701,7 +709,7 @@ struct submodule_update_clone {
int failed_clones_nr, failed_clones_alloc;
};
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
- SUBMODULE_UPDATE_STRATEGY_INIT, 0, -1, STRING_LIST_INIT_DUP, \
+ SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \
NULL, NULL, NULL, \
STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
@@ -803,6 +811,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
child->err = -1;
argv_array_push(&child->args, "submodule--helper");
argv_array_push(&child->args, "clone");
+ if (suc->progress)
+ argv_array_push(&child->args, "--progress");
if (suc->quiet)
argv_array_push(&child->args, "--quiet");
if (suc->prefix)
@@ -949,6 +959,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "recommend-shallow", &suc.recommend_shallow,
N_("whether the initial clone should follow the shallow recommendation")),
OPT__QUIET(&suc.quiet, N_("don't print cloning progress")),
+ OPT_BOOL(0, "progress", &suc.progress,
+ N_("force cloning progress")),
OPT_END()
};