From patchwork Tue Sep 11 23:49:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596497 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 2B9646CB for ; Tue, 11 Sep 2018 23:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18C212993E for ; Tue, 11 Sep 2018 23:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07FC529976; Tue, 11 Sep 2018 23:50:03 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 74CC82993E for ; Tue, 11 Sep 2018 23:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbeILEvj (ORCPT ); Wed, 12 Sep 2018 00:51:39 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:48843 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbeILEvj (ORCPT ); Wed, 12 Sep 2018 00:51:39 -0400 Received: by mail-ua1-f73.google.com with SMTP id i4-v6so41136ual.15 for ; Tue, 11 Sep 2018 16:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lMk6V2S9Ij9c1Tflda+kLjZxJTK7ji21TJ3lMoyYnE8=; b=QyDQgmt7c0kKoFJgeB/YqjEpB1sDrdO5DIWlbx1mEztY7U4E3W+QPP7as/ekouWOaT HQ/JUoMBFvjSVwKIII9Ao03Rloo8pG1G/TixhQ5xk8fpJ2u5acYLM2SZPL+kGfbhocSV 136gPbN5XrO4+OFqnEz8lO6i+eWXCzKIg9Jjbrmavw4H/b04MGNSAukln5hiF2MioGol xe9K0iGl44y5Ce9a93qZhwwWTKB8w9LSHKUBMe595bg2cAdPAN+P8Vjc9AacwqLAtv0F t/zx0aXSoi66mV3CjMGiJbDv7DwVrJhL3YibqqYrBsCIMewzm7JtGzCaQ8I80yec0E4A /sZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lMk6V2S9Ij9c1Tflda+kLjZxJTK7ji21TJ3lMoyYnE8=; b=es9+anwYpRkKr6aMe7FZBNy0QAPD+Hj50/ngIifAtmELscW9lwweG3y5Iz1Xi/4W3d mj/FesJsLfWnE8BMoE3CMtQ+S22yDVzsOWzZ/5t11DfqPLmtUmJGicfs0FnznDxNzo4R nBkJQ8OKysrV8nw76+nOTFhIDgC1HF8r4phwaXTgvBxAUBV23KyoPtYYKLSIZVYU6uEq W6eGHYe7tGT7NSwWVjmw5I4HzZUcvaqUMkoLSFfX5JYHBZcqcmicZgo1V0pk9N24TeYT DhmAWTQKnjRACb7l819fM7zt7TN71MZ+UfNwSMraKqNYAlXmW1WFGm4GFKhpTbruI45o nrvQ== X-Gm-Message-State: APzg51A3bocRHENqz+J0IGhaFERKWUhfLr7cCfxKrhxF2OhnFIaDWgsN lwRBN54n8cIOjpCFXiL7Ip7JMLgkfApbZhnwYXz04gOYRmQpE/Anh5k0jJx8QTYZk9J+N872U79 AzLOWIbgrBZON2YM9mMsFSf4Yd7OznQcnTX/lkP6YRjUQ4RMe8G3a2UCco43M X-Google-Smtp-Source: ANB0VdbufBtFm1RkBC744eg/vjE6CjNjP7Dg1Yau0frs0BVyIfzZAEdsD4HHr19CUlpI4Dn5mAmqZ/p2rPZG X-Received: by 2002:ab0:59c1:: with SMTP id k1-v6mr5295869uad.70.1536709799906; Tue, 11 Sep 2018 16:49:59 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:43 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-2-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 1/9] string-list: add string_list_{pop, last} functions From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a few functions to allow a string-list to be used as a stack: - string_list_last() lets a caller peek the string_list_item at the end of the string list. The caller needs to be aware that it is borrowing a pointer, which can become invalid if/when the string_list is resized. - string_list_pop() removes the string_list_item at the end of the string list. - _pop usually has a friend _push. This role is taken by string_list_append already, as they are not symmetrical in our code base: _append returns the pointer, such that adding a util is easy, but _pop doesn't return such a pointer. You can use them in this pattern: while (list.nr) { struct string_list_item *item = string_list_last(&list); work_on(item); string_list_pop(&list); } Helped-by: Junio C Hamano Signed-off-by: Stefan Beller --- string-list.c | 14 ++++++++++++++ string-list.h | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/string-list.c b/string-list.c index 771c4550980..04db2b537c0 100644 --- a/string-list.c +++ b/string-list.c @@ -80,6 +80,20 @@ void string_list_remove(struct string_list *list, const char *string, } } +void string_list_pop(struct string_list *list, int free_util) +{ + if (list->nr == 0) + BUG("tried to remove an item from empty string list"); + + if (list->strdup_strings) + free(list->items[list->nr - 1].string); + + if (free_util) + free(list->items[list->nr - 1].util); + + list->nr--; +} + int string_list_has_string(const struct string_list *list, const char *string) { int exact_match; diff --git a/string-list.h b/string-list.h index ff8f6094a33..ce2528bbe15 100644 --- a/string-list.h +++ b/string-list.h @@ -191,6 +191,17 @@ extern void string_list_remove(struct string_list *list, const char *string, */ struct string_list_item *string_list_lookup(struct string_list *list, const char *string); +/** + * Removes the last item from the list. + * The caller must ensure that the list is not empty. + */ +void string_list_pop(struct string_list *list, int free_util); + +static inline struct string_list_item *string_list_last(struct string_list *list) +{ + return &list->items[list->nr - 1]; +} + /* * Remove all but the first of consecutive entries with the same * string value. If free_util is true, call free() on the util From patchwork Tue Sep 11 23:49:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596501 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 E87D014E5 for ; Tue, 11 Sep 2018 23:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D74902993E for ; Tue, 11 Sep 2018 23:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB30629976; Tue, 11 Sep 2018 23:50:04 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 8027A29949 for ; Tue, 11 Sep 2018 23:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbeILEvl (ORCPT ); Wed, 12 Sep 2018 00:51:41 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:44607 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbeILEvl (ORCPT ); Wed, 12 Sep 2018 00:51:41 -0400 Received: by mail-yb1-f202.google.com with SMTP id 189-v6so120460ybz.11 for ; Tue, 11 Sep 2018 16:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YfBDaNAD0rN0MtBEkxpcso45kYioPIIIjy45WTOmugM=; b=ua619HBwvnkhyub2Q7VoihDBy2wjlSCuhDwZiWjw3c3gZ+ceGg2cX9dBNfPZIQQwlb /3GnIRCRN0iIhIzXT2gSyKuGj8SFR2qvgC2sDY5oTW5jpPjIknOHjOM3XB8dnS7/ujR7 6i3x5ZZAhg/wfrWyJVDXxFF2QHlohehfI1VG9kWjdVTYaFncEi8mHoLjOXV1hAgw9Ge+ PU2vdFsZV2DovKOoR2+mJPNYDHYJPXKdUx29rHT/+ulMfGugwmc0Nrhau3ns7Jd8sW8U 4Jk+YY1LQmA6eMayS8/8qTEpp34t1mC8Hf5p2KpbudxzB+hrjvvUGFlC4QnstKy8RzRU syUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YfBDaNAD0rN0MtBEkxpcso45kYioPIIIjy45WTOmugM=; b=WGDQ07exlpr4z5OIOWg7IF0ABqpCu8pwvGL+svtmlvHoALnHwIObbVylE3fFRJENIq Oik7ujW5DRmaU+7Iosgw4ahLNJjf2vxUroumRfhE95lOO2fjNS0Vp5nt2HzOfJr3fCIn rIMW4ag2IWlucH+DuxL4aKY2iNHwD0AEbiUEca58A7uPWfmian+jZF36/MSktMel/KLa fvEb5hKOtZYZREka/dUC3WkBS/S7JHdDLiobB0g/xSMpfQ5X9Ig1EmwTgBAljFAEcO/h HuI5ecjLPKhvjpAxk1HmN/xAt9JRluM8jFsvZ56zd0Uhdn83mdekrcSJ+unFSxizvtv5 Pc3A== X-Gm-Message-State: APzg51CFj+ZyPeJ5/cWeOMSidqY0SPOOAE8M1uHy35+fHs9/sLxPxDYR 2ID757nDIf7Q5IuLFyXuel9gIA+zYXozyzUlWy1uynW5x5dFoF77baFnnzyH4jJ28TgJcUSPqew W3HVfeOwHWblcZB18zG5gdX0NRc/v5er5bV8Kb74cXKBLGEqCA8ftdL5egs41 X-Google-Smtp-Source: ANB0VdYyf8i9xez1vcEMCQ9dQ1n0UASEumIkPJSboGqvv0HRm208N3uMApIS9CWm9pXorwxDWsIek0GWunqe X-Received: by 2002:a81:a092:: with SMTP id x140-v6mr7961607ywg.52.1536709802586; Tue, 11 Sep 2018 16:50:02 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:44 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-3-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 2/9] sha1-array: provide oid_array_filter From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Helped-by: Junio C Hamano Signed-off-by: Stefan Beller --- sha1-array.c | 18 ++++++++++++++++++ sha1-array.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/sha1-array.c b/sha1-array.c index 265941fbf40..76323935dd7 100644 --- a/sha1-array.c +++ b/sha1-array.c @@ -77,3 +77,21 @@ int oid_array_for_each_unique(struct oid_array *array, } return 0; } + +int oid_array_filter(struct oid_array *array, + for_each_oid_fn fn, + void *cbdata) +{ + int src, dst; + + for (src = dst = 0; src < array->nr; src++) { + if (fn(&array->oid[src], cbdata)) { + if (dst < src) + oidcpy(&array->oid[dst], &array->oid[src]); + dst++; + } + } + array->nr = dst; + + return 0; +} diff --git a/sha1-array.h b/sha1-array.h index 232bf950172..a2d7c210835 100644 --- a/sha1-array.h +++ b/sha1-array.h @@ -23,4 +23,9 @@ int oid_array_for_each_unique(struct oid_array *array, for_each_oid_fn fn, void *data); +/* Call fn for each oid, and remove it if fn returns 0, retain it otherwise */ +int oid_array_filter(struct oid_array *array, + for_each_oid_fn fn, + void *cbdata); + #endif /* SHA1_ARRAY_H */ From patchwork Tue Sep 11 23:49:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596503 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 0CAAF14E5 for ; Tue, 11 Sep 2018 23:50:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F08312990C for ; Tue, 11 Sep 2018 23:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E448629949; Tue, 11 Sep 2018 23:50:07 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 9FF862990C for ; Tue, 11 Sep 2018 23:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbeILEvo (ORCPT ); Wed, 12 Sep 2018 00:51:44 -0400 Received: from mail-ua1-f74.google.com ([209.85.222.74]:35901 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbeILEvo (ORCPT ); Wed, 12 Sep 2018 00:51:44 -0400 Received: by mail-ua1-f74.google.com with SMTP id m19-v6so53598uap.3 for ; Tue, 11 Sep 2018 16:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UY9P6GTLun6sLU3lqilisBa+iFBbQb4RZUF6QIpwrXk=; b=tvjyCuZzGOSyLyMq9Nq+jvB7e/EdyMLQLB8AZn6NlXyNXaEtZghVJ4jADhogYla06G AnGsrsj4YBCH1pKX0VxB6rm4IoqaHP59rDxFg+lHe+DEXyMjAexZS816Z0sBDmR1sdVO yoSErZVbDKOT/3NvxviBxj1SoT9aJdbp2R9ahpndJ+TjpYMul2RxuWdmuGbxMamdNlvW CAZRC24NzBK8vfq+kW0kpzEbNEUG9Gtil5L/s3b0+fJwn/akPLcL1LljA2ta6P4qKJo4 sYuo71YDDCZij2InFpj1utBg2juBucRy0fu7JZVSmprPrre+9i1r1FpOH+WsJXu5bcTV 5FRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UY9P6GTLun6sLU3lqilisBa+iFBbQb4RZUF6QIpwrXk=; b=t2rL5x90kQcEqUDXbRrgHWvzqDxfC+eE2AGa6qqAHdZDYp1wH0eOPK+1APpI+1S/OX okFW8O+/fYm7G54cbzMpsjjTtB7uPhiKZqmdSAJAwyMj+C/WGeYzosbd9gMcXzmWRlFl TJIAMyMvRKtV3Jd0XHErlyEWj6ND8hMVVK93natvv3liKBVpNs8UYJ4x29Zy259R3igc KHTpZCf77NgtiSi5epLFu52XDv3kRs5p5R4GiYKkK9B1ltLFV7fIzpBlRadMAUHnHClG uuMoZf6ZihHZ/Wzb6oug2cl9Me2IyiMIIvrpxboLpASvK7VsSDgO7jAsibIHQPwhEq9L +fBg== X-Gm-Message-State: APzg51Dvz9/p9JqkyljVeeIfiPIV8g/mEyACm4aT5iHoBU/HcM+xeyHk nTZLw2pGi9nui78itHY/nlTGq48IBdnLrrhV3b4RD+hUtq+OShkf7ElhH+TIR7tK7J+mO4pLSE9 26s+6qn/dIVP6tZuS+mEljjznHFp0MwIsZfQTw4B6JSFSnOgXCKJhJ4WRfCRf X-Google-Smtp-Source: ANB0VdZhAOP/NEE0q97S40Ga/+BJc4A9oKw4ws75vV31UZ3CMowpZwEcqm+76t3IDb8+INSOGa6USeh53dU4 X-Received: by 2002:a67:3e1c:: with SMTP id l28-v6mr2979932vsa.54.1536709805251; Tue, 11 Sep 2018 16:50:05 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:45 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-4-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 3/9] submodule.c: fix indentation From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The submodule subsystem is really bad at staying within 80 characters. Fix it while we are here. Signed-off-by: Stefan Beller --- submodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/submodule.c b/submodule.c index a2b266fbfae..d29dfa3d1f5 100644 --- a/submodule.c +++ b/submodule.c @@ -1244,7 +1244,8 @@ static int get_next_submodule(struct child_process *cp, if (!submodule) { const char *name = default_name_or_path(ce->name); if (name) { - default_submodule.path = default_submodule.name = name; + default_submodule.path = name; + default_submodule.name = name; submodule = &default_submodule; } } @@ -1254,8 +1255,10 @@ static int get_next_submodule(struct child_process *cp, default: case RECURSE_SUBMODULES_DEFAULT: case RECURSE_SUBMODULES_ON_DEMAND: - if (!submodule || !unsorted_string_list_lookup(&changed_submodule_names, - submodule->name)) + if (!submodule || + !unsorted_string_list_lookup( + &changed_submodule_names, + submodule->name)) continue; default_argv = "on-demand"; break; From patchwork Tue Sep 11 23:49:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596505 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 CFAA414E5 for ; Tue, 11 Sep 2018 23:50:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEEF92990C for ; Tue, 11 Sep 2018 23:50:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B33FA29976; Tue, 11 Sep 2018 23:50:10 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 568A72990C for ; Tue, 11 Sep 2018 23:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbeILEvr (ORCPT ); Wed, 12 Sep 2018 00:51:47 -0400 Received: from mail-ua1-f74.google.com ([209.85.222.74]:43775 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbeILEvr (ORCPT ); Wed, 12 Sep 2018 00:51:47 -0400 Received: by mail-ua1-f74.google.com with SMTP id g19-v6so44929uah.10 for ; Tue, 11 Sep 2018 16:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aePnPx2YqOtLYlyVK5CDLEc/HmVD9vFEee9X8pOHmKg=; b=Ixc9w42ODD7xJvAPXWWh8II5kLBEq/e/Izh7XRrSv6DtvUxM9b4JrAetLD0GzWaV6n olExrq9UiDod1fxtor7jTrrpdXGVoDW2m99a+Ekhq8xMjeJAZJ3kZbbxiOduEmbPgtRQ QnWQGttZyczqPdxfQ+EKnXhmbOiufSRe4grQ2TGUKdvIElZ91yVsC+KCXwwG61JaaiRv HOVWKR+JvOAyFZobOYrDX62AtXQB/HyVjWH2o0vjjbh2hIKQNpIkrEIBuTa+7xmwYGxO jFH80BE2/uh2b2UQPgN5+u+HeZO+SKz9djaK3pcInXzY3PnVd3r4HrGfAz6NNu6CuMsp Bkjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aePnPx2YqOtLYlyVK5CDLEc/HmVD9vFEee9X8pOHmKg=; b=dlKUVS22khuSfBoPa3bzFxVYwau1bUx3WjWztebeiN/3C5pGy4umVzvW4UWiXl5K8X pFTMEfjtR0x5MOEuZR8xIydqkgE/XCCWHDoDsPnLDJNGJme4YItIgMlp0OfShXV/3+Ka mLnigrOwDe5zcl5pi830wRh6VXuUV1aQRwPlq5Mw6vpY0mfP8L056cmQKg/AWXYWtOnl T7qfI5g4mCKB3DxRdSjS3DjYf56OWcRHYINYHAQtYI1TiYRBpTlDVhw+pPzz9JnUTTKv Ovrwn+4t6/5RNfw+FSSugNukFJ8VSzf9w/7DL4Ei5HxCxDzLMwMZd+nM5DLovBK/KEUU WojQ== X-Gm-Message-State: APzg51CwqohISAjfOqy1e4qTCCm9GmmAJAXFwjjMIZ4aCLZ2bGQznfPb /2j5eRB42swF93u05zMUsIAbZTm4XcOY9otCrrEFltnJGglLkIZVWX1Rg0Fz1e/ydPVeZOwu2nZ r15tQprGgjVFdJ//cVqFzRTsWZmoQpWOr+4jwFZRFWUlVlgnMLpJ8SOjYwf+/ X-Google-Smtp-Source: ANB0VdaN31jOj4K020MQfineqCvZJfVjZKFHCIt8oOS+r1SfQ208u4ZZMfCc6EPYOIPNyyL2QjjTdGKrYKM3 X-Received: by 2002:a67:3b17:: with SMTP id i23-v6mr2981324vsa.10.1536709807967; Tue, 11 Sep 2018 16:50:07 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:46 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-5-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 4/9] submodule.c: sort changed_submodule_names before searching it From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We can string_list_insert() to maintain sorted-ness of the list as we find new items, or we can string_list_append() to build an unsorted list and sort it at the end just once. To pick which one is more appropriate, we notice the fact that we discover new items more or less in the already sorted order. That makes "append then sort" more appropriate. Signed-off-by: Stefan Beller --- submodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/submodule.c b/submodule.c index d29dfa3d1f5..c6eff7699f3 100644 --- a/submodule.c +++ b/submodule.c @@ -1256,7 +1256,7 @@ static int get_next_submodule(struct child_process *cp, case RECURSE_SUBMODULES_DEFAULT: case RECURSE_SUBMODULES_ON_DEMAND: if (!submodule || - !unsorted_string_list_lookup( + !string_list_lookup( &changed_submodule_names, submodule->name)) continue; @@ -1350,6 +1350,7 @@ int fetch_populated_submodules(struct repository *r, /* default value, "--submodule-prefix" and its value are added later */ calculate_changed_submodule_paths(); + string_list_sort(&changed_submodule_names); run_processes_parallel(max_parallel_jobs, get_next_submodule, fetch_start_failure, From patchwork Tue Sep 11 23:49:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596507 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 B15096CB for ; Tue, 11 Sep 2018 23:50:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A12262990C for ; Tue, 11 Sep 2018 23:50:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95C5929976; Tue, 11 Sep 2018 23:50:13 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 355282990C for ; Tue, 11 Sep 2018 23:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbeILEvu (ORCPT ); Wed, 12 Sep 2018 00:51:50 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:42809 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbeILEvt (ORCPT ); Wed, 12 Sep 2018 00:51:49 -0400 Received: by mail-ua1-f73.google.com with SMTP id g10-v6so47384uap.9 for ; Tue, 11 Sep 2018 16:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N+C9LG44r+za892wkBrqwOOomAK6Va9G9n8tpBcil7o=; b=If8fl565zplg58gC3i7WgmWCgg1BSxZslYn06vBgS6Dtr/oBxUHkz/HGQdA6aOo+9/ ZXV+xRZbCemfhrWiz4ouAB1O3OeptQpUmiaSXsnQCzlAF6HtON+udt/8yNEHbgEhaO8K rNxLB864bNwF5NIlNn624/fzyQID0DNF5m/mDcVDwSvuU+ObV1PW5LhNAjWAxVV6eWom A0azdsbJLwGVmbCqxIVDedqYbY5BWJJBWonvbC0mEWuZfSKTuOQi7nY5JAs3k0dUfXpL k2yfHq03CL0A7fjmhO8WG115dBQ21W6p7wFkiMKPKnkldWcckstSlCinYnkXcikFQ2W6 K1GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N+C9LG44r+za892wkBrqwOOomAK6Va9G9n8tpBcil7o=; b=ORifrV2+OCego3hrcvt+tMN0MNyNOj7VVw9hYDvvyRq7uc8LQsZEBuVBntqI5J0ZiB LTqJqlWBOCVE07vECv35lPOoVgHX39xPps4yOLarANVLht6QGgXHDLQ0w8Fc3vpKrAbz 3PcD9btFZUP/2mp7+bK/nctPaMNgsd+j6iEjnDPg8rt2o8XsoxVb9qVS4S1zkQElNU6G PzroK90suNjDs5RQqZI/K2rRUJ7iQDm0AV/6w3nterRYCs01cTOu8gHdcJQmu8itTblp YaQr0/KiNAYxW9De89PPuqa5Mx6fMEwgqpncAffXos8f0IOSMv7Rw95M3lv6H6xdV9fK qHzA== X-Gm-Message-State: APzg51BzVHQKLIzzSqMbefWccU1rYeegIt9thVbJq5RRwBxpB/yckL3E jTCOUugnuStJb2AI2JJycwgYxAZXsQQ4bsXDRGeJwczadd6jwboxvoHK3am8Ypv84nfj3Qc0swS twYde2oe0JOK2mdxGpnB0zLx9dk13ikGc9BlSRZxCkHg1M7qyNkhCRHCrn1Gb X-Google-Smtp-Source: ANB0VdauSAQCzduNR+Hl79XJmH8lf6vuQL2w/Tf61z7YnEQbd8O3z/g7erjb4rq5t74T9KY4ehp2OIvxqH7t X-Received: by 2002:a9f:3190:: with SMTP id v16-v6mr5801004uad.1.1536709810597; Tue, 11 Sep 2018 16:50:10 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:47 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-6-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 5/9] submodule: move global changed_submodule_names into fetch submodule struct From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The `changed_submodule_names` are only used for fetching, so let's make it part of the struct that is passed around for fetching submodules. Signed-off-by: Stefan Beller --- submodule.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/submodule.c b/submodule.c index c6eff7699f3..3520dd76bdf 100644 --- a/submodule.c +++ b/submodule.c @@ -24,7 +24,7 @@ #include "object-store.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; -static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP; + static int initialized_fetch_ref_tips; static struct oid_array ref_tips_before_fetch; static struct oid_array ref_tips_after_fetch; @@ -1110,7 +1110,22 @@ 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) +struct submodule_parallel_fetch { + int count; + struct argv_array args; + struct repository *r; + const char *prefix; + int command_line_option; + int default_option; + int quiet; + int result; + + struct string_list changed_submodule_names; +}; +#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, STRING_LIST_INIT_DUP } + +static void calculate_changed_submodule_paths( + struct submodule_parallel_fetch *spf) { struct argv_array argv = ARGV_ARRAY_INIT; struct string_list changed_submodules = STRING_LIST_INIT_DUP; @@ -1148,7 +1163,8 @@ static void calculate_changed_submodule_paths(void) continue; if (!submodule_has_commits(path, commits)) - string_list_append(&changed_submodule_names, name->string); + string_list_append(&spf->changed_submodule_names, + name->string); } free_submodules_oids(&changed_submodules); @@ -1185,18 +1201,6 @@ int submodule_touches_in_range(struct object_id *excl_oid, return ret; } -struct submodule_parallel_fetch { - int count; - struct argv_array args; - struct repository *r; - const char *prefix; - int command_line_option; - int default_option; - int quiet; - int result; -}; -#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0} - static int get_fetch_recurse_config(const struct submodule *submodule, struct submodule_parallel_fetch *spf) { @@ -1257,7 +1261,7 @@ static int get_next_submodule(struct child_process *cp, case RECURSE_SUBMODULES_ON_DEMAND: if (!submodule || !string_list_lookup( - &changed_submodule_names, + &spf->changed_submodule_names, submodule->name)) continue; default_argv = "on-demand"; @@ -1349,8 +1353,8 @@ 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(); - string_list_sort(&changed_submodule_names); + calculate_changed_submodule_paths(&spf); + string_list_sort(&spf.changed_submodule_names); run_processes_parallel(max_parallel_jobs, get_next_submodule, fetch_start_failure, @@ -1359,7 +1363,7 @@ int fetch_populated_submodules(struct repository *r, argv_array_clear(&spf.args); out: - string_list_clear(&changed_submodule_names, 1); + string_list_clear(&spf.changed_submodule_names, 1); return spf.result; } From patchwork Tue Sep 11 23:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596509 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 42E4A14E5 for ; Tue, 11 Sep 2018 23:50:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32C9B2990C for ; Tue, 11 Sep 2018 23:50:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 271BC29976; Tue, 11 Sep 2018 23:50:16 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 C56622990C for ; Tue, 11 Sep 2018 23:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbeILEvx (ORCPT ); Wed, 12 Sep 2018 00:51:53 -0400 Received: from mail-io0-f202.google.com ([209.85.223.202]:53916 "EHLO mail-io0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbeILEvw (ORCPT ); Wed, 12 Sep 2018 00:51:52 -0400 Received: by mail-io0-f202.google.com with SMTP id h20-v6so68251iob.20 for ; Tue, 11 Sep 2018 16:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kUdA9oKdgU249YiNpRsaZOph17WEjyfJNVIA3Yy8Wmg=; b=kZNa1DZ7Rro1Wm/GzVL+I1NTBRRkcs8WIIWc56JAc1R8ZFmABJHBMH4g5N6R0jShRC 3b0kKwV1fc04IJ60zpxHWDpZ24q7WpnWRCy691DCpHROtVY+IPO3pmLJaPfonAKBgTSp 5JTcUAINGn7HI77kV4EwyCWQLAkUDSTc48z1yxH6Ns1ZQRQU77ZEe5FRGObqXeNr1jyd oKJ/SPOGVC2vUO0684dfVF+sxznSZGsgXxnxYHTaG07ANAKEgUj6SiAkd58sgydw9TJq 8g5QuK+m6YimfViJMIydcnbw9ask4km2IqNXbHv+x2WFl9+qZD064EA8dfJ9v/gCePaI ZvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kUdA9oKdgU249YiNpRsaZOph17WEjyfJNVIA3Yy8Wmg=; b=R++cC5XMyq8kQKDbqXIkY0eyJqumvT4I73FNva4+QVrWlWp6nWyKK81ebwPpCrm9Gh 5RggmGE2NYbo3Y8nqxw1ydqcfgP/NARZtKyQoxUBulXLnHvU6j235QHYpnMTeyMsXhT/ Caxp3QwQ75vdCZYBqRq9rVPSHrpcNSME4d394kVjDSlBrpkG7IAr0hmTJygy1WgUa/ct Fdgds3p3Dhk/tyU4IoADtIi6XvyVt4t4uXqSUsLIamM5C8Lv7epX3zllBEm9yzGkove3 S4Y26bCI0P/AuLXw38J5YsQobVaNue2U2NFdysZ6RnbNZB5cdcQxelOIDCrBywuBAeEd Njcg== X-Gm-Message-State: APzg51Cxok9W/bSZ8njNWkoc2TTq69Lzb6u6mRkl+NzkjvgMBrtNY93B UyrS+0YUedh53jiflDP8hqOdVW15IvKfFyl1FgBHCX3mjVmZ4dkIheIw2DOKt5WUgaNxXQbPXeG Xcyv2MGJnqw8ROtUvkYDLo7ZbBpB95ehtjIUvENY4oGaNOSYvVChPy/zDeKgO X-Google-Smtp-Source: ANB0VdbOu3j1CH2Kct+V4nIfJMLKKpFrZq7am1soqAPEBGW88V+6LTrcV6sCxZAJtFFqPzgHChjGV3+Q0gT7 X-Received: by 2002:a24:47ca:: with SMTP id t193-v6mr3629264itb.24.1536709813340; Tue, 11 Sep 2018 16:50:13 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:48 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-7-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 6/9] submodule.c: do not copy around submodule list From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'calculate_changed_submodule_paths' uses a local list to compute the changed submodules, and then produces the result by copying appropriate items into the result list. Instead use the result list directly and prune items afterwards using string_list_remove_empty_items. By doin so we'll have access to the util pointer for longer that contains the commits that we need to fetch, which will be useful in a later patch. Signed-off-by: Stefan Beller --- submodule.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/submodule.c b/submodule.c index 3520dd76bdf..00a9a3c6b12 100644 --- a/submodule.c +++ b/submodule.c @@ -1128,8 +1128,7 @@ static void calculate_changed_submodule_paths( struct submodule_parallel_fetch *spf) { struct argv_array argv = ARGV_ARRAY_INIT; - struct string_list changed_submodules = STRING_LIST_INIT_DUP; - const struct string_list_item *name; + struct string_list_item *name; /* No need to check if there are no submodules configured */ if (!submodule_from_path(the_repository, NULL, NULL)) @@ -1146,9 +1145,9 @@ static void calculate_changed_submodule_paths( * 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(&spf->changed_submodule_names, &argv); - for_each_string_list_item(name, &changed_submodules) { + for_each_string_list_item(name, &spf->changed_submodule_names) { struct oid_array *commits = name->util; const struct submodule *submodule; const char *path = NULL; @@ -1162,12 +1161,14 @@ static void calculate_changed_submodule_paths( if (!path) continue; - if (!submodule_has_commits(path, commits)) - string_list_append(&spf->changed_submodule_names, - name->string); + if (submodule_has_commits(path, commits)) { + oid_array_clear(commits); + *name->string = '\0'; + } } - free_submodules_oids(&changed_submodules); + string_list_remove_empty_items(&spf->changed_submodule_names, 1); + argv_array_clear(&argv); oid_array_clear(&ref_tips_before_fetch); oid_array_clear(&ref_tips_after_fetch); @@ -1363,7 +1364,7 @@ int fetch_populated_submodules(struct repository *r, argv_array_clear(&spf.args); out: - string_list_clear(&spf.changed_submodule_names, 1); + free_submodules_oids(&spf.changed_submodule_names); return spf.result; } From patchwork Tue Sep 11 23:49:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596511 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 AE72714E5 for ; Tue, 11 Sep 2018 23:50:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EB082990C for ; Tue, 11 Sep 2018 23:50:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 934D7299D7; Tue, 11 Sep 2018 23:50:20 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 00BA92990C for ; Tue, 11 Sep 2018 23:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbeILEv4 (ORCPT ); Wed, 12 Sep 2018 00:51:56 -0400 Received: from mail-vk0-f73.google.com ([209.85.213.73]:48761 "EHLO mail-vk0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbeILEvz (ORCPT ); Wed, 12 Sep 2018 00:51:55 -0400 Received: by mail-vk0-f73.google.com with SMTP id g71-v6so7310vke.15 for ; Tue, 11 Sep 2018 16:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KItobHqCCVzmLBPJnMnC50u9fHZIScwfPEg4MpAgDDw=; b=HF/0mrY246tz8b1AMZ8UHnHFNQywArDNVnq9YH04pVd4R7Z9RPsRE5OL6o4bOnfVAo R9yt9ht/tol0tQNUp1lSPDDYQK1vpvfTzw/RUj/Tq1uGlNGWH/mRCamT4cCWdMkSMnWt VK2QEpAv39cDMxHYZ/v/TcqZVy4C4Dl8ohhQJxTjlYXrlUqtRlspkaoTBTnhxqyiQThg Fihmcay3p/KjQMu3Gim+hnTENiO6qm1/6cu/jug1rG9SRBoUgQhQHybaCoDjnATEMwkP Q1+dFkif7V5xDBoPUYAqqAX3B2jNbZ6xlT2SiuUckaaskSqOkBkJgHAY3aI7QDsbkyif oUfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KItobHqCCVzmLBPJnMnC50u9fHZIScwfPEg4MpAgDDw=; b=aa7rB1/0eUFOub6nL3d7rCLUPhhj9R3+rxFBT6kvnIc55ArW9873eqDBfdAZwBWgKK p5I6W+ev+4FqYX0RxFX0F8xrRuXBm8AlzWqj6CMDb4Ib9OCz98BnrW+pm2+Gmj02phbu OUxcZ1qhXkHaUJPJPGDaO6cYZN/jmrDLlFhJM1AWk4FmqpkwaRM0d+AFEAmEqO2FgJm5 DLOn7MMMjEPo6o9jtuxMPRsfebreo2ETijpazZS2RqyD1MLwkIL95XKrdYUz/gK4wH8i 886mXN1AA4m92d9n49ogT0nZQx/gdDrF9yOFVbjh3AROmvZvT8aNW0waqRPA1/u39Z82 oXdg== X-Gm-Message-State: APzg51Cm32KeW5dBykuen+Of7AAEFT06/7YzZvRbVpgT79zk1HWYkDXs OcSHOxYqqgkgqmX8cyRgz0TYZmoF16uwiUm7VX81bPZsqdf4PFdoVWIGCFJKz7rCk/RxvbSKzW8 GHKfv2Sj5CyJ1YTDGFdxxCwvQBgixFJFOMwWcOkS3Au1dL/txO7CYRFDYRgsw X-Google-Smtp-Source: ANB0VdZBnhBK7wsR6uxuLehlRhH2R1Hdk9ysUszV1KNligQyiqdNELKRoTzuQgYun0rVjYQWCovnmkYKq9vw X-Received: by 2002:a1f:b781:: with SMTP id h123-v6mr4540618vkf.31.1536709815950; Tue, 11 Sep 2018 16:50:15 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:49 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-8-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 7/9] submodule: fetch in submodules git directory instead of in worktree From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch started as a refactoring to make 'get_next_submodule' more readable, but upon doing so, I realized that git-fetch actually doesn't need to be run in the worktree. So let's run it in the git dir instead. That should pave the way towards fetching submodules that are currently not checked out. Signed-off-by: Stefan Beller --- submodule.c | 43 ++++++++++++++++++++++++++----------- t/t5526-fetch-submodules.sh | 7 +++++- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/submodule.c b/submodule.c index 00a9a3c6b12..1e6781504f0 100644 --- a/submodule.c +++ b/submodule.c @@ -481,6 +481,12 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } +static void prepare_submodule_repo_env_in_gitdir(struct argv_array *out) +{ + prepare_submodule_repo_env_no_git_dir(out); + argv_array_pushf(out, "%s=.", GIT_DIR_ENVIRONMENT); +} + /* Helper function to display the submodule header line prior to the full * summary output. If it can locate the submodule objects directory it will * attempt to lookup both the left and right commits and put them into the @@ -1227,6 +1233,27 @@ static int get_fetch_recurse_config(const struct submodule *submodule, return spf->default_option; } +static const char *get_submodule_git_dir(struct repository *r, const char *path) +{ + struct repository subrepo; + const char *ret; + + if (repo_submodule_init(&subrepo, r, path)) { + /* no entry in .gitmodules? */ + struct strbuf gitdir = STRBUF_INIT; + strbuf_repo_worktree_path(&gitdir, r, "%s/.git", path); + if (repo_init(&subrepo, gitdir.buf, NULL)) { + strbuf_release(&gitdir); + return NULL; + } + } + + ret = xstrdup(subrepo.gitdir); + repo_clear(&subrepo); + + return ret; +} + static int get_next_submodule(struct child_process *cp, struct strbuf *err, void *data, void **task_cb) { @@ -1234,8 +1261,6 @@ static int get_next_submodule(struct child_process *cp, struct submodule_parallel_fetch *spf = data; for (; spf->count < spf->r->index->cache_nr; spf->count++) { - struct strbuf submodule_path = STRBUF_INIT; - struct strbuf submodule_git_dir = STRBUF_INIT; struct strbuf submodule_prefix = STRBUF_INIT; const struct cache_entry *ce = spf->r->index->cache[spf->count]; const char *git_dir, *default_argv; @@ -1274,16 +1299,12 @@ static int get_next_submodule(struct child_process *cp, continue; } - strbuf_repo_worktree_path(&submodule_path, spf->r, "%s", ce->name); - strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf); strbuf_addf(&submodule_prefix, "%s%s/", spf->prefix, ce->name); - git_dir = read_gitfile(submodule_git_dir.buf); - if (!git_dir) - git_dir = submodule_git_dir.buf; - if (is_directory(git_dir)) { + git_dir = get_submodule_git_dir(spf->r, ce->name); + if (git_dir) { child_process_init(cp); - cp->dir = strbuf_detach(&submodule_path, NULL); - prepare_submodule_repo_env(&cp->env_array); + prepare_submodule_repo_env_in_gitdir(&cp->env_array); + cp->dir = git_dir; cp->git_cmd = 1; if (!spf->quiet) strbuf_addf(err, "Fetching submodule %s%s\n", @@ -1295,8 +1316,6 @@ static int get_next_submodule(struct child_process *cp, argv_array_push(&cp->args, submodule_prefix.buf); ret = 1; } - strbuf_release(&submodule_path); - strbuf_release(&submodule_git_dir); strbuf_release(&submodule_prefix); if (ret) { spf->count++; diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 6c2f9b2ba26..42692219a1a 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -566,7 +566,12 @@ test_expect_success 'fetching submodule into a broken repository' ' test_must_fail git -C dst status && test_must_fail git -C dst diff && - test_must_fail git -C dst fetch --recurse-submodules + + # git-fetch cannot find the git directory of the submodule, + # so it will do nothing, successfully, as it cannot distinguish between + # this broken submodule and a submodule that was just set active but + # not cloned yet + git -C dst fetch --recurse-submodules ' test_expect_success "fetch new commits when submodule got renamed" ' From patchwork Tue Sep 11 23:49:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596513 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 2172A6CB for ; Tue, 11 Sep 2018 23:50:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 109CB2990C for ; Tue, 11 Sep 2018 23:50:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04D9B29976; Tue, 11 Sep 2018 23:50:22 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 597C02990C for ; Tue, 11 Sep 2018 23:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbeILEv6 (ORCPT ); Wed, 12 Sep 2018 00:51:58 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:46976 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbeILEv5 (ORCPT ); Wed, 12 Sep 2018 00:51:57 -0400 Received: by mail-ua1-f73.google.com with SMTP id g12-v6so42654ual.13 for ; Tue, 11 Sep 2018 16:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4e73je6QrgD2Rw5w5iDkdsjxNnErqFrUhPSygK/wYgk=; b=dySlGI5TThfdHu9EO7QfzUojc17FQrpBNtidCmjdAAEsCZwV6yvK3FEpSqLP0WsAaT 7IYeSLKH+/euNaBwiPXXc6ausNmediMMUldJ4HjxatwlW2Nyoz6ap6GGY6yBWe/EwRwx vKS+ED2X1bEnlO2csQ/tHHJbDnPEpQ9HOhF0lcljGcXatjgFZM8dJszU+R/JBVEolYIm qMSQNfdCRqCd+1kkydI1YaeRVf3KCVXktCcE/xB2QUkt+VDERfxbkU/CQHX7+WsxR4bC XpcPK/F3nJ8lPJIpyPNRSnhDlXWmR24n/A9vPz1bjsudlVSTtJdwPyAm2nOUU6DaQeMu iujw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4e73je6QrgD2Rw5w5iDkdsjxNnErqFrUhPSygK/wYgk=; b=JsR64jaCnqU6iTkPRHNJuTwa7x4fJ7RvGZHCtymVaCAxz1qZulbC8+1a8jyT9eGmBt GZHc8lxyNyu86gvc2k8uoEICPCQLsFKmwJXlIzVk/UoFpKKHyJ9p+a6sm356Yuz39U48 oXRNnMxGKYwL0Yn8ZFd5VKcxkMD4KFvuWcX4y3CF5m9dSUMJUvDqgBdw0BzSrfZVIudz +8/1GrSEZQYI4O6LNZk/EUoaijACvkeCxUqAT9M/VDq0bhSuGMCekW+fXGDfSuywhMQR HEIEfoIpJJie8E1OyK2liQOW6VoiACKnabzRTuuN1razCjKktJSOvW3yCx5LHtHcSZeX rKJA== X-Gm-Message-State: APzg51A7GmmUCtRRySBxloMAq9+nLWWTNIuWrpQ9qWiQm3Ff8JZXgrqH mmYvINRRk/5gm4pljEm/JlrI3LVZgYaXVzxnVKsM8Aag/bV0sq36rdyJADXkzf5uceanwRXtJh1 QMk/f6RqMJJGOTEdo04QBbbjE10htNnO8hNn2fxv5tJmglejoaZCsP+2WoGoi X-Google-Smtp-Source: ANB0Vdaf51M9BPFX/uwAzU+g/5t6IowaI7ihdqMULDMIUAfcTH4SCpCMUFTM00sFh4MdWJjVtouWst5h4JGq X-Received: by 2002:a9f:2469:: with SMTP id 96-v6mr5309524uaq.64.1536709818540; Tue, 11 Sep 2018 16:50:18 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:50 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-9-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 8/9] fetch: retry fetching submodules if sha1 were not fetched From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently when git-fetch is asked to recurse into submodules, it dispatches a plain "git-fetch -C " (and some submodule related options such as prefix and recusing strategy, but) without any information of the remote or the tip that should be fetched. This works surprisingly well in some workflows (such as using submodules as a third party library), while not so well in other scenarios, such as in a Gerrit topic-based workflow, that can tie together changes (potentially across repositories) on the server side. One of the parts of such a Gerrit workflow is to download a change when wanting to examine it, and you'd want to have its submodule changes that are in the same topic downloaded as well. However these submodule changes reside in their own repository in their own ref (refs/changes/). Retry fetching a submodule if the object id that the superproject points to, cannot be found. This doesn't support fetching to FETCH_HEAD yet, but only into a local branch. To make fetching into FETCH_HEAD work, we need some refactoring in builtin/fetch.c to adjust the calls to 'check_for_new_submodule_commits' that is coming in the next patch. Signed-off-by: Stefan Beller --- builtin/fetch.c | 9 ++-- submodule.c | 87 ++++++++++++++++++++++++++++++++++++- t/t5526-fetch-submodules.sh | 16 +++++++ 3 files changed, 104 insertions(+), 8 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 61bec5d213d..95c44bf6ffa 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -700,8 +700,7 @@ static int update_local_ref(struct ref *ref, what = _("[new ref]"); } - if ((recurse_submodules != RECURSE_SUBMODULES_OFF) && - (recurse_submodules != RECURSE_SUBMODULES_ON)) + if (recurse_submodules != RECURSE_SUBMODULES_OFF) check_for_new_submodule_commits(&ref->new_oid); r = s_update_ref(msg, ref, 0); format_display(display, r ? '!' : '*', what, @@ -716,8 +715,7 @@ static int update_local_ref(struct ref *ref, strbuf_add_unique_abbrev(&quickref, ¤t->object.oid, DEFAULT_ABBREV); strbuf_addstr(&quickref, ".."); strbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV); - if ((recurse_submodules != RECURSE_SUBMODULES_OFF) && - (recurse_submodules != RECURSE_SUBMODULES_ON)) + if (recurse_submodules != RECURSE_SUBMODULES_OFF) check_for_new_submodule_commits(&ref->new_oid); r = s_update_ref("fast-forward", ref, 1); format_display(display, r ? '!' : ' ', quickref.buf, @@ -731,8 +729,7 @@ static int update_local_ref(struct ref *ref, strbuf_add_unique_abbrev(&quickref, ¤t->object.oid, DEFAULT_ABBREV); strbuf_addstr(&quickref, "..."); strbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV); - if ((recurse_submodules != RECURSE_SUBMODULES_OFF) && - (recurse_submodules != RECURSE_SUBMODULES_ON)) + if (recurse_submodules != RECURSE_SUBMODULES_OFF) check_for_new_submodule_commits(&ref->new_oid); r = s_update_ref("forced-update", ref, 1); format_display(display, r ? '!' : '+', quickref.buf, diff --git a/submodule.c b/submodule.c index 1e6781504f0..a75146e89cf 100644 --- a/submodule.c +++ b/submodule.c @@ -1127,8 +1127,11 @@ struct submodule_parallel_fetch { int result; struct string_list changed_submodule_names; + struct string_list retry; }; -#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, STRING_LIST_INIT_DUP } +#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, \ + STRING_LIST_INIT_DUP, \ + STRING_LIST_INIT_NODUP} static void calculate_changed_submodule_paths( struct submodule_parallel_fetch *spf) @@ -1259,8 +1262,10 @@ static int get_next_submodule(struct child_process *cp, { int ret = 0; struct submodule_parallel_fetch *spf = data; + struct string_list_item *it; for (; spf->count < spf->r->index->cache_nr; spf->count++) { + int recurse_config; struct strbuf submodule_prefix = STRBUF_INIT; const struct cache_entry *ce = spf->r->index->cache[spf->count]; const char *git_dir, *default_argv; @@ -1280,7 +1285,9 @@ static int get_next_submodule(struct child_process *cp, } } - switch (get_fetch_recurse_config(submodule, spf)) + recurse_config = get_fetch_recurse_config(submodule, spf); + + switch (recurse_config) { default: case RECURSE_SUBMODULES_DEFAULT: @@ -1319,9 +1326,50 @@ static int get_next_submodule(struct child_process *cp, strbuf_release(&submodule_prefix); if (ret) { spf->count++; + if (submodule != &default_submodule) + /* discard const-ness: */ + *task_cb = (void*)submodule; return 1; } } + +retry_next: + + if (spf->retry.nr) { + struct strbuf submodule_prefix = STRBUF_INIT; + const struct submodule *sub; + + it = string_list_last(&spf->retry); + sub = submodule_from_name(spf->r, &null_oid, + it->string); + + child_process_init(cp); + cp->dir = get_submodule_git_dir(spf->r, sub->path); + if (!cp->dir) { + string_list_pop(&spf->retry, 0); + goto retry_next; + } + prepare_submodule_repo_env_in_gitdir(&cp->env_array); + cp->git_cmd = 1; + + strbuf_addf(&submodule_prefix, "%s%s/", spf->prefix, sub->path); + argv_array_init(&cp->args); + argv_array_pushv(&cp->args, spf->args.argv); + argv_array_push(&cp->args, "on-demand"); + argv_array_push(&cp->args, "--submodule-prefix"); + argv_array_push(&cp->args, submodule_prefix.buf); + + /* NEEDSWORK: have get_default_remote from s--h */ + argv_array_push(&cp->args, "origin"); + oid_array_for_each_unique(it->util, + append_oid_to_argv, &cp->args); + + *task_cb = NULL; /* make sure we do not recurse forever */ + strbuf_release(&submodule_prefix); + string_list_pop(&spf->retry, 0); + return 1; + } + return 0; } @@ -1335,14 +1383,49 @@ static int fetch_start_failure(struct strbuf *err, return 0; } +static int commit_exists_in_sub(const struct object_id *oid, void *data) +{ + struct repository *subrepo = data; + + enum object_type type = oid_object_info(subrepo, oid, NULL); + + return type != OBJ_COMMIT; +} + static int fetch_finish(int retvalue, struct strbuf *err, void *cb, void *task_cb) { struct submodule_parallel_fetch *spf = cb; + struct submodule *sub = task_cb; + struct repository subrepo; if (retvalue) spf->result = 1; + if (!sub) + return 0; + + if (repo_submodule_init(&subrepo, spf->r, sub->path) < 0) + warning(_("Could not get submodule repository for submodule '%s' in repository '%s'"), + sub->path, spf->r->worktree); + else { + struct string_list_item *it; + struct oid_array *commits; + + it = string_list_lookup(&spf->changed_submodule_names, sub->name); + if (!it) + return 0; + + commits = it->util; + oid_array_filter(commits, + commit_exists_in_sub, + &subrepo); + + if (commits->nr) + string_list_append(&spf->retry, sub->name) + ->util = commits; + } + return 0; } diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 42692219a1a..af12c50e7dd 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -605,4 +605,20 @@ test_expect_success "fetch new commits when submodule got renamed" ' test_cmp expect actual ' +test_expect_success "fetch new commits on-demand when they are not reachable" ' + git checkout --detach && + C=$(git -C submodule commit-tree -m "new change outside refs/heads" HEAD^{tree}) && + git -C submodule update-ref refs/changes/1 $C && + git update-index --cacheinfo 160000 $C submodule && + git commit -m "updated submodule outside of refs/heads" && + D=$(git rev-parse HEAD) && + git update-ref refs/changes/2 $D && + ( + cd downstream && + git fetch --recurse-submodules --recurse-submodules-default on-demand origin refs/changes/2:refs/heads/my_branch && + git -C submodule cat-file -t $C && + git checkout --recurse-submodules FETCH_HEAD + ) +' + test_done From patchwork Tue Sep 11 23:49:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10596515 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 68F7314E5 for ; Tue, 11 Sep 2018 23:50:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 582702990C for ; Tue, 11 Sep 2018 23:50:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C84029976; Tue, 11 Sep 2018 23:50:24 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 EBD622990C for ; Tue, 11 Sep 2018 23:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728172AbeILEwB (ORCPT ); Wed, 12 Sep 2018 00:52:01 -0400 Received: from mail-ua1-f74.google.com ([209.85.222.74]:54877 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbeILEwA (ORCPT ); Wed, 12 Sep 2018 00:52:00 -0400 Received: by mail-ua1-f74.google.com with SMTP id l14-v6so34255uaf.21 for ; Tue, 11 Sep 2018 16:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tk87CXyJVQNQVWPNNs5RozzS/pTt0APvY/pavxAMu8c=; b=a+iHYXKGOeEoVb22/hOwCXRlvQkRoaYsOgTXJG0AUEp3eBda76Xl5OnER0NJVSKuA/ 1RexRcXjWpwMX3CSeKdiTlqPA/5Lu8qP6IkPL0xCar6Nrg4891yigD7rqunf3iUfKfr2 xgp190A/NbiglCtFYPbKz3I0Is/FYK+9FHpA6Yi6n5WQNdrUdjONZM0/cYoJXOJPVOOV Iy3Umtv9cKyFvUwHPkT2GjcrgEZnz5/0aKQov7O+iKdfA4sGTawY6dwV4nbnG7JWFYN1 aOrgXXeC/oZ1RCwPpaH7xQ7Spr4OztmPl0c12CJSBmUkLIaTQQusSbg/TXLDQDEnKKDF F/Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tk87CXyJVQNQVWPNNs5RozzS/pTt0APvY/pavxAMu8c=; b=Gb8tyjO8h9PXOgHvIoAUrKII7z3XDD4jUniLDy0+YeWGRftcQgnhQ9EEHnDTgyutXy Qow9iLXiw3bfAm7OlOhyMWlR9z4ZTUpsBLJAuiFzAe08MN2Wid7Qg3H/e/kjvHqs3L+D q8NOJ29lsPsDnMtjLqUEDL+jnEz8HvDsMT1stO1wglPCG5CTa/EArq1646YCd4Q0Pz6C 4KOh2O/EOvhFB20thRnU21R7ptyAdHMvRQrt6RZFZmSiyJthJGkqSmvxGkUCuu1lM1Z2 4SDNBJcP/tQKdluIcn06J8c4XIHCoWYPeaSbcPpZ+hOsOzTn6L0dFbPCrJE+gBV3Ndwo OPBA== X-Gm-Message-State: APzg51Anbb4PO3H/LjCLo0BK+kl0rcIt3MrgFAGnpt2CEc+pfF4Ta8Ad 04hFX0rAoqJytRCgjK/eOUGrCWqjPXk2C2bQZf1ZtniW6PcKBCURk0ZVr9XOtLtzGSiErihYsfd +NeuAFO/b4b01O9xqJTLftncqHhu80tNYSpu13XUh3sQRMnQc6qG18c14w9JB X-Google-Smtp-Source: ANB0VdZBjBfbHvisPnBG68N45NDVuJME0+z/jAdGGuMCZEYtr6bJz1NcN3QqoJk5exXhdL5SjpntfGN1MvFB X-Received: by 2002:a67:4689:: with SMTP id a9-v6mr2882639vsg.31.1536709821028; Tue, 11 Sep 2018 16:50:21 -0700 (PDT) Date: Tue, 11 Sep 2018 16:49:51 -0700 In-Reply-To: <20180911234951.14129-1-sbeller@google.com> Message-Id: <20180911234951.14129-10-sbeller@google.com> Mime-Version: 1.0 References: <20180911234951.14129-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 9/9] builtin/fetch: check for submodule updates for non branch fetches From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For Gerrit users that use submodules the invocation of fetch without a branch is their main use case. Signed-off-by: Stefan Beller --- builtin/fetch.c | 5 ++++- t/t5526-fetch-submodules.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 95c44bf6ffa..ea6ecd123e7 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -887,11 +887,14 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, rc |= update_local_ref(ref, what, rm, ¬e, summary_width); free(ref); - } else + } else { + check_for_new_submodule_commits(&rm->old_oid); format_display(¬e, '*', *kind ? kind : "branch", NULL, *what ? what : "HEAD", "FETCH_HEAD", summary_width); + } + if (note.len) { if (verbosity >= 0 && !shown_url) { fprintf(stderr, _("From %.*s\n"), diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index af12c50e7dd..a509eabb044 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -615,7 +615,7 @@ test_expect_success "fetch new commits on-demand when they are not reachable" ' git update-ref refs/changes/2 $D && ( cd downstream && - git fetch --recurse-submodules --recurse-submodules-default on-demand origin refs/changes/2:refs/heads/my_branch && + git fetch --recurse-submodules origin refs/changes/2 && git -C submodule cat-file -t $C && git checkout --recurse-submodules FETCH_HEAD )