From patchwork Sat Sep 15 16:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10601519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3D8814DB for ; Sat, 15 Sep 2018 16:19:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D792AF3D for ; Sat, 15 Sep 2018 16:19:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62552AF3F; Sat, 15 Sep 2018 16:19:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 459902AF3D for ; Sat, 15 Sep 2018 16:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbeIOVif (ORCPT ); Sat, 15 Sep 2018 17:38:35 -0400 Received: from mail-lf1-f50.google.com ([209.85.167.50]:45667 "EHLO mail-lf1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbeIOVib (ORCPT ); Sat, 15 Sep 2018 17:38:31 -0400 Received: by mail-lf1-f50.google.com with SMTP id r4-v6so10259381lff.12 for ; Sat, 15 Sep 2018 09:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TZos09seLerEkDcAipA2xI788Qg1S7bLBhtsEHrbgFA=; b=Mnyn2TpZjx5c3A5OJXHcuu+kIVCfAlL3VAJ1fLt3Yxvbmx7BPwEqIlhUU4cZd2eZne ZSosucRzMjZib0uBYJrqELcZnS50pWd+PumAOcHFKVcS7RD5fh5qnro404K7QhQrBinK mm9ZGbAf4BRn9E+WbJpE/eNz4smbHflOu765EA+nlZvo+jP5LGr7G//ogA685Sv15jP6 fPmM32a7Fsk0RQkc48s9FVh/GIyBgCUvxF3+2fjLFQ6KsJ+/KKQ6LX8vLGafGA4MiKd6 pBmW1ramd1G9OzZ6MBk76DSEVKoidJ2ddBAFIszq8if0fYT/w7iWYJogpd3kI8n3KcJj BTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TZos09seLerEkDcAipA2xI788Qg1S7bLBhtsEHrbgFA=; b=I9cQ2sjwe3sOWH6yyUXpif0FAvebiZgb8nQa18Zsv1DIY/hJWoxvZ9edBzhk9cia7V Evth3DTeIk0rtDZkXBHmJd5/8pByk7MZtI3UvhkWJ5d13IdeN/zzFvkbyzgBJB6efvy2 aQ1UJaJ+rEznhGiyMn6OhE+TiaWgOEF9F/N6Z61oFgsRhamHsomaWQS4N5SZTb0eXokt Cj+ZNeGZEQYaE03OL9vf38McX3taaqBNZdeo2OJjy2w5TBDuRiJ2sm4qILcdmy+pIXDL Ol4i3bnYpIeyoGynbwSRxgGssVTHvakjSjQCCuBFIJSQux/5VJDrQeB2duVQfvJRhfDa QcMQ== X-Gm-Message-State: APzg51DVIYu8t0Q0wdrwTYWCQoCFXRbQkIHdhtBo+hkLaiyHvgN9x5ge VO/4s8Rgz4Ve/ZHquQnQySBjjYBA X-Google-Smtp-Source: ANB0VdagfqQIEGDfe2EjChWu8p1GfBOA+5rVIDa2oFpyPWyTcWFJ9h6wcbvdmkcl6CmcZtNxATsq0w== X-Received: by 2002:a19:dd49:: with SMTP id u70-v6mr12126170lfg.135.1537028338732; Sat, 15 Sep 2018 09:18:58 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id i2-v6sm1934852lfa.78.2018.09.15.09.18.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 09:18:58 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Stefan Beller , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 19/23] submodule.c: remove implicit dependency on the_index Date: Sat, 15 Sep 2018 18:17:55 +0200 Message-Id: <20180915161759.8272-20-pclouds@gmail.com> X-Mailer: git-send-email 2.19.0.rc0.337.ge906d732e7 In-Reply-To: <20180915161759.8272-1-pclouds@gmail.com> References: <20180909085418.31531-1-pclouds@gmail.com> <20180915161759.8272-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/pull.c | 2 +- submodule.c | 28 +++++++++++++++++----------- submodule.h | 9 ++++++--- transport.c | 9 ++++++--- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 33b7100837..9c455984d1 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -944,7 +944,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) int ret = 0; if ((recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && - submodule_touches_in_range(&rebase_fork_point, &curr_head)) + submodule_touches_in_range(&the_index, &rebase_fork_point, &curr_head)) die(_("cannot rebase with locally recorded submodule modifications")); if (!autostash) { struct commit_list *list = NULL; diff --git a/submodule.c b/submodule.c index 50cbf5f13e..c0c1224760 100644 --- a/submodule.c +++ b/submodule.c @@ -766,7 +766,8 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q, * have a corresponding 'struct oid_array' (in the 'util' field) which lists * what the submodule pointers were updated to during the change. */ -static void collect_changed_submodules(struct string_list *changed, +static void collect_changed_submodules(struct index_state *istate, + struct string_list *changed, struct argv_array *argv) { struct rev_info rev; @@ -930,8 +931,10 @@ static int submodule_needs_pushing(const char *path, struct oid_array *commits) return 0; } -int find_unpushed_submodules(struct oid_array *commits, - const char *remotes_name, struct string_list *needs_pushing) +int find_unpushed_submodules(struct index_state *istate, + struct oid_array *commits, + const char *remotes_name, + struct string_list *needs_pushing) { struct string_list submodules = STRING_LIST_INIT_DUP; struct string_list_item *name; @@ -943,7 +946,7 @@ int find_unpushed_submodules(struct oid_array *commits, argv_array_push(&argv, "--not"); argv_array_pushf(&argv, "--remotes=%s", remotes_name); - collect_changed_submodules(&submodules, &argv); + collect_changed_submodules(istate, &submodules, &argv); for_each_string_list_item(name, &submodules) { struct oid_array *commits = name->util; @@ -1044,7 +1047,8 @@ static void submodule_push_check(const char *path, const char *head, die("process for submodule '%s' failed", path); } -int push_unpushed_submodules(struct oid_array *commits, +int push_unpushed_submodules(struct index_state *istate, + struct oid_array *commits, const struct remote *remote, const struct refspec *rs, const struct string_list *push_options, @@ -1053,7 +1057,8 @@ int push_unpushed_submodules(struct oid_array *commits, int i, ret = 1; struct string_list needs_pushing = STRING_LIST_INIT_DUP; - if (!find_unpushed_submodules(commits, remote->name, &needs_pushing)) + if (!find_unpushed_submodules(istate, commits, + remote->name, &needs_pushing)) return 1; /* @@ -1110,7 +1115,7 @@ void check_for_new_submodule_commits(struct object_id *oid) oid_array_append(&ref_tips_after_fetch, oid); } -static void calculate_changed_submodule_paths(void) +static void calculate_changed_submodule_paths(struct index_state *istate) { struct argv_array argv = ARGV_ARRAY_INIT; struct string_list changed_submodules = STRING_LIST_INIT_DUP; @@ -1131,7 +1136,7 @@ static void calculate_changed_submodule_paths(void) * Collect all submodules (whether checked out or not) for which new * commits have been recorded upstream in "changed_submodule_names". */ - collect_changed_submodules(&changed_submodules, &argv); + collect_changed_submodules(istate, &changed_submodules, &argv); for_each_string_list_item(name, &changed_submodules) { struct oid_array *commits = name->util; @@ -1158,7 +1163,8 @@ static void calculate_changed_submodule_paths(void) initialized_fetch_ref_tips = 0; } -int submodule_touches_in_range(struct object_id *excl_oid, +int submodule_touches_in_range(struct index_state *istate, + struct object_id *excl_oid, struct object_id *incl_oid) { struct string_list subs = STRING_LIST_INIT_DUP; @@ -1176,7 +1182,7 @@ int submodule_touches_in_range(struct object_id *excl_oid, argv_array_push(&args, oid_to_hex(excl_oid)); } - collect_changed_submodules(&subs, &args); + collect_changed_submodules(istate, &subs, &args); ret = subs.nr; argv_array_clear(&args); @@ -1346,7 +1352,7 @@ int fetch_populated_submodules(struct repository *r, argv_array_push(&spf.args, "--recurse-submodules-default"); /* default value, "--submodule-prefix" and its value are added later */ - calculate_changed_submodule_paths(); + calculate_changed_submodule_paths(r->index); run_processes_parallel(max_parallel_jobs, get_next_submodule, fetch_start_failure, diff --git a/submodule.h b/submodule.h index 7d476cefa7..600d41d765 100644 --- a/submodule.h +++ b/submodule.h @@ -102,13 +102,16 @@ int add_submodule_odb(const char *path); * Checks if there are submodule changes in a..b. If a is the null OID, * checks b and all its ancestors instead. */ -int submodule_touches_in_range(struct object_id *a, +int submodule_touches_in_range(struct index_state *istate, + struct object_id *a, struct object_id *b); -int find_unpushed_submodules(struct oid_array *commits, +int find_unpushed_submodules(struct index_state *istate, + struct oid_array *commits, const char *remotes_name, struct string_list *needs_pushing); struct refspec; -int push_unpushed_submodules(struct oid_array *commits, +int push_unpushed_submodules(struct index_state *istate, + struct oid_array *commits, const struct remote *remote, const struct refspec *rs, const struct string_list *push_options, diff --git a/transport.c b/transport.c index 06ffea2774..cb40a23d45 100644 --- a/transport.c +++ b/transport.c @@ -1139,7 +1139,8 @@ int transport_push(struct transport *transport, oid_array_append(&commits, &ref->new_oid); - if (!push_unpushed_submodules(&commits, + if (!push_unpushed_submodules(&the_index, + &commits, transport->remote, rs, transport->push_options, @@ -1163,8 +1164,10 @@ int transport_push(struct transport *transport, oid_array_append(&commits, &ref->new_oid); - if (find_unpushed_submodules(&commits, transport->remote->name, - &needs_pushing)) { + if (find_unpushed_submodules(&the_index, + &commits, + transport->remote->name, + &needs_pushing)) { oid_array_clear(&commits); die_with_unpushed_submodules(&needs_pushing); }