From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com, bmwill@google.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH 3/7] builtin/submodule--helper: factor out submodule updating
Date: Mon, 13 Aug 2018 15:42:31 -0700 [thread overview]
Message-ID: <20180813224235.154580-4-sbeller@google.com> (raw)
In-Reply-To: <20180813224235.154580-1-sbeller@google.com>
Separate the command line parsing from the actual execution of the command
within the repository. For now there is not a lot of execution as
most of it is still in git-submodule.sh.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/submodule--helper.c | 59 +++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 26 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index da700c88963..32f00ca6f87 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1474,6 +1474,8 @@ struct submodule_update_clone {
/* failed clones to be retried again */
const struct cache_entry **failed_clones;
int failed_clones_nr, failed_clones_alloc;
+
+ int max_jobs;
};
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, \
@@ -1716,11 +1718,36 @@ static int git_update_clone_config(const char *var, const char *value,
return 0;
}
+static int update_submodules(struct submodule_update_clone *suc)
+{
+ struct string_list_item *item;
+
+ run_processes_parallel(suc->max_jobs,
+ update_clone_get_next_task,
+ update_clone_start_failure,
+ update_clone_task_finished,
+ suc);
+
+ /*
+ * We saved the output and put it out all at once now.
+ * That means:
+ * - the listener does not have to interleave their (checkout)
+ * work with our fetching. The writes involved in a
+ * checkout involve more straightforward sequential I/O.
+ * - the listener can avoid doing any work if fetching failed.
+ */
+ if (suc->quickstop)
+ return 1;
+
+ for_each_string_list_item(item, &suc->projectlines)
+ fprintf(stdout, "%s", item->string);
+
+ return 0;
+}
+
static int update_clone(int argc, const char **argv, const char *prefix)
{
const char *update = NULL;
- int max_jobs = 1;
- struct string_list_item *item;
struct pathspec pathspec;
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
@@ -1742,7 +1769,7 @@ static int update_clone(int argc, const char **argv, const char *prefix)
OPT_STRING(0, "depth", &suc.depth, "<depth>",
N_("Create a shallow clone truncated to the "
"specified number of revisions")),
- OPT_INTEGER('j', "jobs", &max_jobs,
+ OPT_INTEGER('j', "jobs", &suc.max_jobs,
N_("parallel jobs")),
OPT_BOOL(0, "recommend-shallow", &suc.recommend_shallow,
N_("whether the initial clone should follow the shallow recommendation")),
@@ -1758,8 +1785,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
};
suc.prefix = prefix;
- update_clone_config_from_gitmodules(&max_jobs);
- git_config(git_update_clone_config, &max_jobs);
+ update_clone_config_from_gitmodules(&suc.max_jobs);
+ git_config(git_update_clone_config, &suc.max_jobs);
argc = parse_options(argc, argv, prefix, module_update_clone_options,
git_submodule_helper_usage, 0);
@@ -1774,27 +1801,7 @@ static int update_clone(int argc, const char **argv, const char *prefix)
if (pathspec.nr)
suc.warn_if_uninitialized = 1;
- run_processes_parallel(max_jobs,
- update_clone_get_next_task,
- update_clone_start_failure,
- update_clone_task_finished,
- &suc);
-
- /*
- * We saved the output and put it out all at once now.
- * That means:
- * - the listener does not have to interleave their (checkout)
- * work with our fetching. The writes involved in a
- * checkout involve more straightforward sequential I/O.
- * - the listener can avoid doing any work if fetching failed.
- */
- if (suc.quickstop)
- return 1;
-
- for_each_string_list_item(item, &suc.projectlines)
- fprintf(stdout, "%s", item->string);
-
- return 0;
+ return update_submodules(&suc);
}
static int resolve_relative_path(int argc, const char **argv, const char *prefix)
--
2.18.0.865.gffc8e1a3cd6-goog
next prev parent reply other threads:[~2018-08-13 22:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-03 22:23 [PATCH 0/7] Resend of sb/submodule-update-in-c Stefan Beller
2018-08-03 22:23 ` [PATCH 1/7] git-submodule.sh: align error reporting for update mode to use path Stefan Beller
2018-08-03 22:23 ` [PATCH 2/7] git-submodule.sh: rename unused variables Stefan Beller
2018-08-03 22:23 ` [PATCH 3/7] builtin/submodule--helper: factor out submodule updating Stefan Beller
2018-08-03 22:23 ` [PATCH 4/7] builtin/submodule--helper: store update_clone information in a struct Stefan Beller
2018-08-03 22:23 ` [PATCH 5/7] builtin/submodule--helper: factor out method to update a single submodule Stefan Beller
2018-08-03 22:23 ` [PATCH 6/7] submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree Stefan Beller
2018-08-10 21:47 ` Brandon Williams
2018-08-10 21:52 ` Stefan Beller
2018-08-10 22:02 ` Brandon Williams
2018-08-03 22:23 ` [PATCH 7/7] submodule--helper: introduce new update-module-mode helper Stefan Beller
2018-08-03 22:36 ` [PATCH 0/7] Resend of sb/submodule-update-in-c Junio C Hamano
2018-08-13 22:42 ` Stefan Beller
2018-08-13 22:42 ` [PATCH 1/7] git-submodule.sh: align error reporting for update mode to use path Stefan Beller
2018-08-13 22:42 ` [PATCH 2/7] git-submodule.sh: rename unused variables Stefan Beller
2018-08-13 22:42 ` Stefan Beller [this message]
2018-08-13 22:42 ` [PATCH 4/7] builtin/submodule--helper: store update_clone information in a struct Stefan Beller
2018-08-13 22:42 ` [PATCH 5/7] builtin/submodule--helper: factor out method to update a single submodule Stefan Beller
2018-08-13 22:42 ` [PATCH 6/7] submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree Stefan Beller
2018-08-13 22:42 ` [PATCH 7/7] submodule--helper: introduce new update-module-mode helper Stefan Beller
2018-08-18 16:10 ` Duy Nguyen
2018-08-20 19:44 ` Stefan Beller
2018-08-14 21:01 ` [PATCH 0/7] Resend of sb/submodule-update-in-c Junio C Hamano
2018-08-14 21:24 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180813224235.154580-4-sbeller@google.com \
--to=sbeller@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).