From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id A670F20323 for ; Thu, 16 Mar 2017 22:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbdCPWhA (ORCPT ); Thu, 16 Mar 2017 18:37:00 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:35736 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752122AbdCPWgy (ORCPT ); Thu, 16 Mar 2017 18:36:54 -0400 Received: by mail-pf0-f177.google.com with SMTP id x63so25249408pfx.2 for ; Thu, 16 Mar 2017 15:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g5UBIwJuaFE92+VZfLWnQO40IsdGpHY1zas05c58m3Q=; b=ReyRZnxsoksTrHPc+6mqigt/QQChr9FTFMnLZ4kvgOQ3wfpCL3jhGeXKxlsY5DhWj+ Ee7WL2Y2DW/m7aNNBDYUeAwJSqE9f3bdaiQ15HGfHH216yE7Ple+Eh+x3eyStMAFn0qS 00ILpcOAM5U9xsnl8sTFySV9TA48fec2dobBBx0IQKtf4SU19y8YOl4vbwdodJJSgi4Z fDVrW/QiWi4LWv58A5LdyJ1wvjw/jM71GFwSfq5Y+L7h/f6Hsfm9YjovEs+5Ppj4X4ys xco+SegpxBlYrkK3BdgmJWwBdduYHQbN3gYTh8RRjZYVfCBmmqITchta8D+ub1wHpGF0 OLyw== 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; bh=g5UBIwJuaFE92+VZfLWnQO40IsdGpHY1zas05c58m3Q=; b=PjAfU2CpYNgldzDFbTTov6PJ7OUSU7LVCRItvhQJyLPT2ZKRoM/WcHZO1zgjSj91Na bUEBS1GVxa6SuQ0tC6aWHF/nIJ9W1WVzqQyBwH/OAVT81W+7xNgQslXJM9b3N9QOkSZZ xcUUbuYrB4kQUeh0PF58uZbkHHa3ykkA42XAS4K2M+2FKVWX1TXhpjD7XLkT5Gwoh2PR Z45KdZyU9d+S4LGw9R+UXmnXymt+qnlAelAI2eAmdo99DXe39s1Rq1+Mh9O6TNe1GQFr vEW1KmDnV7qBQjFlW0IAu4rObekvrk7t0Jzxeuqh02dyKYOXxYUX7wQUwb3mf6oW3WNo GdmQ== X-Gm-Message-State: AFeK/H1Ttd7z6c/maAkuLTeN3JQvlpS2gRra/tvOyDk/MrCv3LL0ne/iBZUEc+CWVhH/gxl7 X-Received: by 10.98.157.12 with SMTP id i12mr13389617pfd.166.1489703403308; Thu, 16 Mar 2017 15:30:03 -0700 (PDT) Received: from roshar.mtv.corp.google.com ([100.96.238.26]) by smtp.gmail.com with ESMTPSA id t5sm12520946pgb.36.2017.03.16.15.30.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Mar 2017 15:30:02 -0700 (PDT) From: Brandon Williams To: git@vger.kernel.org Cc: Brandon Williams , sbeller@google.com, gitster@pobox.com Subject: [PATCH v4 03/10] submodule sync: skip work for inactive submodules Date: Thu, 16 Mar 2017 15:29:45 -0700 Message-Id: <20170316222952.53801-4-bmwill@google.com> X-Mailer: git-send-email 2.12.0.367.g23dc2f6d3c-goog In-Reply-To: <20170316222952.53801-1-bmwill@google.com> References: <20170313214341.172676-1-bmwill@google.com> <20170316222952.53801-1-bmwill@google.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Sync does some work determining what URLs should be used for a submodule but then throws this work away if the submodule isn't active. Instead perform the activity check earlier and skip inactive submodule in order to avoid doing unnecessary work. Signed-off-by: Brandon Williams --- git-submodule.sh | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index ab233712d..577136148 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -1090,6 +1090,13 @@ cmd_sync() do die_if_unmatched "$mode" "$sha1" name=$(git submodule--helper name "$sm_path") + + # skip inactive submodules + if ! git config "submodule.$name.url" >/dev/null 2>/dev/null + then + continue + fi + url=$(git config -f .gitmodules --get submodule."$name".url) # Possibly a url relative to parent @@ -1111,27 +1118,24 @@ cmd_sync() ;; esac - if git config "submodule.$name.url" >/dev/null 2>/dev/null + displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix") + say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")" + git config submodule."$name".url "$super_config_url" + + if test -e "$sm_path"/.git then - displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix") - say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")" - git config submodule."$name".url "$super_config_url" + ( + sanitize_submodule_env + cd "$sm_path" + remote=$(get_default_remote) + git config remote."$remote".url "$sub_origin_url" - if test -e "$sm_path"/.git + if test -n "$recursive" then - ( - sanitize_submodule_env - cd "$sm_path" - remote=$(get_default_remote) - git config remote."$remote".url "$sub_origin_url" - - if test -n "$recursive" - then - prefix="$prefix$sm_path/" - eval cmd_sync - fi - ) + prefix="$prefix$sm_path/" + eval cmd_sync fi + ) fi done } -- 2.12.0.367.g23dc2f6d3c-goog