From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: bmwill@google.com, jrnieder@gmail.com,
Stefan Beller <sbeller@google.com>
Subject: [PATCH 6/7] submodule--helper, update_clone: store index to update_clone instead of ce
Date: Wed, 15 Aug 2018 19:30:59 -0700 [thread overview]
Message-ID: <20180816023100.161626-7-sbeller@google.com> (raw)
In-Reply-To: <20180816023100.161626-1-sbeller@google.com>
In update_submodules, we use the run_processes_parallel(get_task, finished)
API, which allows to pass around a task specific callback cookie from the
get_next function to the finish function. That finish function in turn may
alter generic callback cookie to have the next call of get_task come up
with another new task.
Up to now we passed around the index into a list of cache entries,
which was stored in the generic callback cookie which is a struct
submodule_update_clone.
Change this to an index into 'update_clone' array, which is the potential
output of this helper. This will allow for a future change to make
use of the data the update_clone_data struct.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/submodule--helper.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1c9a12781fd..36de64902ec 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1511,8 +1511,10 @@ static int module_update_module_mode(int argc, const char **argv, const char *pr
struct update_clone_data {
const struct submodule *sub;
+ const struct cache_entry *ce;
struct object_id oid;
unsigned just_cloned;
+ unsigned retried;
};
struct submodule_update_clone {
@@ -1541,8 +1543,8 @@ struct submodule_update_clone {
/* If we want to stop as fast as possible and return an error */
unsigned quickstop : 1;
- /* failed clones to be retried again */
- const struct cache_entry **failed_clones;
+ /* failed clones to be retried again, indexes into update_clone */
+ int *failed_clones;
int failed_clones_nr, failed_clones_alloc;
int max_jobs;
@@ -1649,6 +1651,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
oidcpy(&suc->update_clone[suc->update_clone_nr].oid, &ce->oid);
suc->update_clone[suc->update_clone_nr].just_cloned = needs_cloning;
suc->update_clone[suc->update_clone_nr].sub = sub;
+ suc->update_clone[suc->update_clone_nr].retried = 0;
+ suc->update_clone[suc->update_clone_nr].ce = ce;
suc->update_clone_nr++;
if (!needs_cloning)
@@ -1707,7 +1711,8 @@ static int update_clone_get_next_task(struct child_process *child,
for (; suc->current < suc->list.nr; suc->current++) {
ce = suc->list.entries[suc->current];
if (prepare_to_clone_next_submodule(ce, child, suc, err)) {
- *idx_task_cb = update_clone_alloc_cb(suc->current);
+ *idx_task_cb = update_clone_alloc_cb(
+ suc->update_clone_nr - 1);
suc->current++;
return 1;
}
@@ -1720,7 +1725,9 @@ static int update_clone_get_next_task(struct child_process *child,
*/
index = suc->current - suc->list.nr;
if (index < suc->failed_clones_nr) {
- ce = suc->failed_clones[index];
+ int ucd_index = suc->failed_clones[index];
+ struct update_clone_data *ucd = &suc->update_clone[ucd_index];
+ ce = ucd->ce;
if (!prepare_to_clone_next_submodule(ce, child, suc, err)) {
suc->current ++;
strbuf_addstr(err, "BUG: submodule considered for "
@@ -1728,7 +1735,7 @@ static int update_clone_get_next_task(struct child_process *child,
"any more?\n");
return 0;
}
- *idx_task_cb = update_clone_alloc_cb(suc->current);
+ *idx_task_cb = update_clone_alloc_cb(ucd_index);
suc->current ++;
return 1;
}
@@ -1750,31 +1757,31 @@ static int update_clone_task_finished(int result,
void *suc_cb,
void *idx_task_cb)
{
- const struct cache_entry *ce;
struct submodule_update_clone *suc = suc_cb;
+ struct update_clone_data *ucd;
int *idxP = idx_task_cb;
int idx = *idxP;
+ ucd = &suc->update_clone[idx];
free(idxP);
if (!result)
return 0;
- if (idx < suc->list.nr) {
- ce = suc->list.entries[idx];
+ if (!ucd->retried) {
+ ucd->retried = 1;
strbuf_addf(err, _("Failed to clone '%s'. Retry scheduled"),
- ce->name);
+ ucd->ce->name);
strbuf_addch(err, '\n');
ALLOC_GROW(suc->failed_clones,
suc->failed_clones_nr + 1,
suc->failed_clones_alloc);
- suc->failed_clones[suc->failed_clones_nr++] = ce;
+ suc->failed_clones[suc->failed_clones_nr++] = idx;
return 0;
} else {
idx -= suc->list.nr;
- ce = suc->failed_clones[idx];
strbuf_addf(err, _("Failed to clone '%s' a second time, aborting"),
- ce->name);
+ ucd->ce->name);
strbuf_addch(err, '\n');
suc->quickstop = 1;
return 1;
--
2.18.0.265.g16de1b435c9.dirty
next prev parent reply other threads:[~2018-08-16 2:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 2:30 [RFC PATCH 0/7] Unset the submodule URL in the superproject when no longer needed Stefan Beller
2018-08-16 2:30 ` [PATCH 1/7] t7410: update to new style Stefan Beller
2018-08-16 17:06 ` Junio C Hamano
2018-08-16 2:30 ` [PATCH 2/7] builtin/submodule--helper: remove stray new line Stefan Beller
2018-08-16 2:30 ` [PATCH 3/7] submodule: is_submodule_active to differentiate between new and old mode Stefan Beller
2018-08-16 17:37 ` Junio C Hamano
2018-08-20 19:50 ` Stefan Beller
2018-08-21 21:39 ` Junio C Hamano
2018-08-16 2:30 ` [PATCH 4/7] submodule sync: omit setting submodule URL in config if possible Stefan Beller
2018-08-16 2:30 ` [PATCH 5/7] submodule--helper: factor out allocation of callback cookie Stefan Beller
2018-08-16 2:30 ` Stefan Beller [this message]
2018-08-16 2:31 ` [PATCH 7/7] builtin/submodule--helper: unset submodule url if possible Stefan Beller
2018-08-16 15:12 ` [RFC PATCH 0/7] Unset the submodule URL in the superproject when no longer needed Junio C Hamano
2018-08-16 15:45 ` 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=20180816023100.161626-7-sbeller@google.com \
--to=sbeller@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.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).