From patchwork Wed Oct 17 16:40:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10645921 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 9325B181D for ; Wed, 17 Oct 2018 16:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68586287A4 for ; Wed, 17 Oct 2018 16:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 665AC28752; Wed, 17 Oct 2018 16:40:35 +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 DFED228536 for ; Wed, 17 Oct 2018 16:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbeJRAhD (ORCPT ); Wed, 17 Oct 2018 20:37:03 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:44257 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727214AbeJRAhD (ORCPT ); Wed, 17 Oct 2018 20:37:03 -0400 Received: by mail-qt1-f196.google.com with SMTP id c56-v6so30774583qtd.11 for ; Wed, 17 Oct 2018 09:40:32 -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; bh=I4Jwu8qkQEbRvOUECSKt3I+ZwdOY6/3t4M1e0SBz4Aw=; b=LH8qCDxXp6y6nlV75mbxaBNLis6D9P3AA9h6nytxwzWieezWx1Abrzpw7ekGPNF5Gl mz0D4CnZgP0q0YQ1ucHfroTODR1/Ax6sR0Fhmzr9DfOezXT6DSj7OBorFLR0MPKUHqsw hsL5xJymAK1eNLrQT3iwQOIhZzBK6uJ+r7gQCvN5MSgDuu72scmQZp3db0PJT4ZAjqqO lhKiNPmDtnL+3kQACaKiFyftUkn9vBBm/Eo56DCL56Uya5lKPj27lETYUJTAbOI1tWKr H97Soa4VM/242pX2tL46lC1fcetwt1AfPrAD6wzG8Y529WR4+rz5CG0NGyN3VkkCy2p7 LxDQ== 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=I4Jwu8qkQEbRvOUECSKt3I+ZwdOY6/3t4M1e0SBz4Aw=; b=SzgzwGMrzEgPdyhy0DlSOnLAz9+I4Vt3dfdEzhGfj2AL9u59PuroQdhF84lzfuKu+g H0a1ov12eWxns14uhxlUDuJoWcSrxEN0PtqQSrFb1FgzpntNfPjvvuplh7AoFjVju7yI bITJHYD79TiEpQA74xiHZQRSuADw6A15U3Hc8aMN5lFW/6s0OhYlZHgWUOsTJtILkoGO mRVyCrELX89OlZKULcUGvdP+q6Do+DCpXLtWFWJPQq3qx5bIkvFgBEr/rHts/eo0uWzI 9Rl0p4v5SuLN6Ghcq3lT9XAohYfG0vUTYMnkt7Laru6cvXRk/CzZ9hUWquO+j/k3q2Y8 FTag== X-Gm-Message-State: ABuFfojDYyYuAyVHQna093vyN53/YVX4dWKNDuoEqx+oqXGj4MAqQ26O jeHBdUdaKb7r3UcqD+fTbXWLy0C4Wqo= X-Google-Smtp-Source: ACcGV61SGSpoP6FSvOJrw9isVWwuijcJQpz7WuIQTndkBK5EBS+8Gl0ppn/NV/TEUt7y0XP3nSQSRg== X-Received: by 2002:ac8:1e1e:: with SMTP id n30-v6mr25659851qtl.181.1539794431692; Wed, 17 Oct 2018 09:40:31 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id x12-v6sm10843700qtk.6.2018.10.17.09.40.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 09:40:30 -0700 (PDT) From: Ben Peart To: git@vger.kernel.org Cc: gitster@pobox.com, Ben Peart Subject: [PATCH v1 1/2] reset: don't compute unstaged changes after reset when --quiet Date: Wed, 17 Oct 2018 12:40:20 -0400 Message-Id: <20181017164021.15204-2-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181017164021.15204-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Peart When git reset is run with the --quiet flag, don't bother finding any additional unstaged changes as they won't be output anyway. This speeds up the git reset command by avoiding having to lstat() every file looking for changes that aren't going to be reported anyway. The savings can be significant. In a repo with 200K files "git reset" drops from 7.16 seconds to 0.32 seconds for a savings of 96%. Signed-off-by: Ben Peart --- Documentation/git-reset.txt | 4 +++- builtin/reset.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 1d697d9962..8610309b55 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -95,7 +95,9 @@ OPTIONS -q:: --quiet:: - Be quiet, only report errors. + Be quiet, only report errors. Can optimize the performance of reset + by avoiding scaning all files in the repo looking for additional + unstaged changes. EXAMPLES diff --git a/builtin/reset.c b/builtin/reset.c index 11cd0dcb8c..0822798616 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -376,7 +376,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (read_from_tree(&pathspec, &oid, intent_to_add)) return 1; if (get_git_work_tree()) - refresh_index(&the_index, flags, NULL, NULL, + refresh_index(&the_index, flags, quiet ? &pathspec : NULL, NULL, _("Unstaged changes after reset:")); } else { int err = reset_index(&oid, reset_type, quiet); From patchwork Wed Oct 17 16:40:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10645923 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 5831A157A for ; Wed, 17 Oct 2018 16:40:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4483C28790 for ; Wed, 17 Oct 2018 16:40:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D4A8285C3; Wed, 17 Oct 2018 16:40:38 +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 49924285F0 for ; Wed, 17 Oct 2018 16:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbeJRAhF (ORCPT ); Wed, 17 Oct 2018 20:37:05 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:47043 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727214AbeJRAhE (ORCPT ); Wed, 17 Oct 2018 20:37:04 -0400 Received: by mail-qk1-f196.google.com with SMTP id q12-v6so16861947qkl.13 for ; Wed, 17 Oct 2018 09:40:33 -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; bh=6gP2qUl3U/3DHw8+cgkIMEVWLvvhFyvnEDUIopIF9zE=; b=eNH/rveLIN2MoiXa/Exmb/ds4pyo0T7kIpcmMvKPGSe5Rii+nF/RbbT7FDAXzDlv1X w3HPuXfaO5Teqcjba6AnSWb4iJSZfKbSRiSBrs8Pst/JrfP2p67kOxme4qGXr53mMxJl t22QM7p39Hyw2l2MjFImABn/K8yaPyW65ygtl6unaV/jQKn9ti0+lkTnPcUVYDeZa7yv 1SWwXoLWnPIKzWp/l7F2X0YNYJX8L6feOujYWufzBkcMNojL0NzH6ipZgWQv6p3XrnUf puhsQ/9iOXAduyDm5epUy2jte4kWzsqRgNybbTDFHSkhNUDDIeEUShVltF0zrz+bs3BW +0mw== 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=6gP2qUl3U/3DHw8+cgkIMEVWLvvhFyvnEDUIopIF9zE=; b=qZoSHzmivjum2hFx29eEe46DRv0oUNyZxQkNSWkknRAvZtHgym/HQ5tOC3rA2hOPlw A4K0HkJM+gDY10eI0g0ZQTEhaJxo3dDZRX6uy9ncdXdodPL1YiCaXEGIsLQq1OSQCYih 0tjcDVCl7lAmySziOjo3Ce9ftxjZdr5ZqKSKylGQv8z8v2YZL21e+S4kIEVkj2ovF+Ut V4xSn552sWefTXcdWMiRUuP9vm0+uxG6GfEx57nyQzSbIHzaVWRVb75EPog232bsjO7u i9pGBIqKbWmcfKvePJqm2tjhJbTTk4ej0T2sj+CGH/OiSHJY5yeMEtt6oW0tTdB5JdJb tLzg== X-Gm-Message-State: ABuFfohBI9FnLCuvwUNvFkDMBXvzxWhwsRnM1YxWZSmTwMOLVFq7tMgL g8xtMCKtbOsgsVl3MuvoQB6S4P+/4o8= X-Google-Smtp-Source: ACcGV60h132Pi0rPZ+WyN6FUxlsguzUmdy6mLgzYjHT7h04+ZMRnreFylHzKpInHU5jQP6y05aDaeg== X-Received: by 2002:a37:9a55:: with SMTP id c82-v6mr24471545qke.153.1539794432912; Wed, 17 Oct 2018 09:40:32 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id x12-v6sm10843700qtk.6.2018.10.17.09.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 09:40:32 -0700 (PDT) From: Ben Peart To: git@vger.kernel.org Cc: gitster@pobox.com, Ben Peart Subject: [PATCH v1 2/2] reset: add new reset.quietDefault config setting Date: Wed, 17 Oct 2018 12:40:21 -0400 Message-Id: <20181017164021.15204-3-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181017164021.15204-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Peart Add a reset.quietDefault config setting that sets the default value of the --quiet flag when running the reset command. This enables users to change the default behavior to take advantage of the performance advantages of avoiding the scan for unstaged changes after reset. Defaults to false. Signed-off-by: Ben Peart --- Documentation/config.txt | 6 ++++++ builtin/reset.c | 1 + 2 files changed, 7 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index f6f4c21a54..a5cf4c019b 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2728,6 +2728,12 @@ rerere.enabled:: `$GIT_DIR`, e.g. if "rerere" was previously used in the repository. +reset.quietDefault:: + Sets the default value of the "quiet" option for the reset command. + Choosing "quiet" can optimize the performance of the reset command + by avoiding the scan of all files in the repo looking for additional + unstaged changes. Defaults to false. + include::sendemail-config.txt[] sequence.editor:: diff --git a/builtin/reset.c b/builtin/reset.c index 0822798616..7d151d48a0 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -306,6 +306,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) }; git_config(git_reset_config, NULL); + git_config_get_bool("reset.quietDefault", &quiet); argc = parse_options(argc, argv, prefix, options, git_reset_usage, PARSE_OPT_KEEP_DASHDASH);