Skip to content

Commit c4dfd22

Browse files
committed
Merge branch 'jk/clone-recursive-progress'
"git clone --recurse-submodules" lost the progress eye-candy in recent update, which has been corrected. * jk/clone-recursive-progress: clone: pass --progress decision to recursive submodules
2 parents bd250ab + 72c5f88 commit c4dfd22

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

builtin/clone.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
670670
}
671671
}
672672

673-
static int checkout(void)
673+
static int checkout(int submodule_progress)
674674
{
675675
unsigned char sha1[20];
676676
char *head;
@@ -734,6 +734,9 @@ static int checkout(void)
734734
if (max_jobs != -1)
735735
argv_array_pushf(&args, "--jobs=%d", max_jobs);
736736

737+
if (submodule_progress)
738+
argv_array_push(&args, "--progress");
739+
737740
err = run_command_v_opt(args.argv, RUN_GIT_CMD);
738741
argv_array_clear(&args);
739742
}
@@ -841,6 +844,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
841844
const char *src_ref_prefix = "refs/heads/";
842845
struct remote *remote;
843846
int err = 0, complete_refs_before_fetch = 1;
847+
int submodule_progress;
844848

845849
struct refspec *refspec;
846850
const char *fetch_pattern;
@@ -1099,6 +1103,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10991103

11001104
update_head(our_head_points_at, remote_head, reflog_msg.buf);
11011105

1106+
/*
1107+
* We want to show progress for recursive submodule clones iff
1108+
* we did so for the main clone. But only the transport knows
1109+
* the final decision for this flag, so we need to rescue the value
1110+
* before we free the transport.
1111+
*/
1112+
submodule_progress = transport->progress;
1113+
11021114
transport_unlock_pack(transport);
11031115
transport_disconnect(transport);
11041116

@@ -1108,7 +1120,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11081120
}
11091121

11101122
junk_mode = JUNK_LEAVE_REPO;
1111-
err = checkout();
1123+
err = checkout(submodule_progress);
11121124

11131125
strbuf_release(&reflog_msg);
11141126
strbuf_release(&branch_top);

builtin/submodule--helper.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,17 @@ static int module_name(int argc, const char **argv, const char *prefix)
443443
}
444444

445445
static int clone_submodule(const char *path, const char *gitdir, const char *url,
446-
const char *depth, struct string_list *reference, int quiet)
446+
const char *depth, struct string_list *reference,
447+
int quiet, int progress)
447448
{
448449
struct child_process cp = CHILD_PROCESS_INIT;
449450

450451
argv_array_push(&cp.args, "clone");
451452
argv_array_push(&cp.args, "--no-checkout");
452453
if (quiet)
453454
argv_array_push(&cp.args, "--quiet");
455+
if (progress)
456+
argv_array_push(&cp.args, "--progress");
454457
if (depth && *depth)
455458
argv_array_pushl(&cp.args, "--depth", depth, NULL);
456459
if (reference->nr) {
@@ -575,6 +578,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
575578
{
576579
const char *name = NULL, *url = NULL, *depth = NULL;
577580
int quiet = 0;
581+
int progress = 0;
578582
FILE *submodule_dot_git;
579583
char *p, *path = NULL, *sm_gitdir;
580584
struct strbuf rel_path = STRBUF_INIT;
@@ -601,6 +605,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
601605
N_("string"),
602606
N_("depth for shallow clones")),
603607
OPT__QUIET(&quiet, "Suppress output for cloning a submodule"),
608+
OPT_BOOL(0, "progress", &progress,
609+
N_("force cloning progress")),
604610
OPT_END()
605611
};
606612

@@ -634,7 +640,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
634640

635641
prepare_possible_alternates(name, &reference);
636642

637-
if (clone_submodule(path, sm_gitdir, url, depth, &reference, quiet))
643+
if (clone_submodule(path, sm_gitdir, url, depth, &reference,
644+
quiet, progress))
638645
die(_("clone of '%s' into submodule path '%s' failed"),
639646
url, path);
640647
} else {
@@ -684,6 +691,7 @@ struct submodule_update_clone {
684691
struct submodule_update_strategy update;
685692

686693
/* configuration parameters which are passed on to the children */
694+
int progress;
687695
int quiet;
688696
int recommend_shallow;
689697
struct string_list references;
@@ -702,7 +710,7 @@ struct submodule_update_clone {
702710
int failed_clones_nr, failed_clones_alloc;
703711
};
704712
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
705-
SUBMODULE_UPDATE_STRATEGY_INIT, 0, -1, STRING_LIST_INIT_DUP, \
713+
SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \
706714
NULL, NULL, NULL, \
707715
STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
708716

@@ -804,6 +812,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
804812
child->err = -1;
805813
argv_array_push(&child->args, "submodule--helper");
806814
argv_array_push(&child->args, "clone");
815+
if (suc->progress)
816+
argv_array_push(&child->args, "--progress");
807817
if (suc->quiet)
808818
argv_array_push(&child->args, "--quiet");
809819
if (suc->prefix)
@@ -951,6 +961,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
951961
OPT_BOOL(0, "recommend-shallow", &suc.recommend_shallow,
952962
N_("whether the initial clone should follow the shallow recommendation")),
953963
OPT__QUIET(&suc.quiet, N_("don't print cloning progress")),
964+
OPT_BOOL(0, "progress", &suc.progress,
965+
N_("force cloning progress")),
954966
OPT_END()
955967
};
956968

git-submodule.sh

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ update=
4444
prefix=
4545
custom_name=
4646
depth=
47+
progress=
4748

4849
die_if_unmatched ()
4950
{
@@ -498,6 +499,9 @@ cmd_update()
498499
-q|--quiet)
499500
GIT_QUIET=1
500501
;;
502+
--progress)
503+
progress="--progress"
504+
;;
501505
-i|--init)
502506
init=1
503507
;;
@@ -573,6 +577,7 @@ cmd_update()
573577

574578
{
575579
git submodule--helper update-clone ${GIT_QUIET:+--quiet} \
580+
${progress:+"$progress"} \
576581
${wt_prefix:+--prefix "$wt_prefix"} \
577582
${prefix:+--recursive-prefix "$prefix"} \
578583
${update:+--update "$update"} \

0 commit comments

Comments
 (0)