From patchwork Fri Oct 19 16:12:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10649747 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 4310E13A4 for ; Fri, 19 Oct 2018 16:12:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3250D284F5 for ; Fri, 19 Oct 2018 16:12:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26240284C0; Fri, 19 Oct 2018 16:12:43 +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 CDB15284C0 for ; Fri, 19 Oct 2018 16:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727654AbeJTAT1 (ORCPT ); Fri, 19 Oct 2018 20:19:27 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35083 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727282AbeJTAT0 (ORCPT ); Fri, 19 Oct 2018 20:19:26 -0400 Received: by mail-qt1-f196.google.com with SMTP id k3-v6so3022157qth.2 for ; Fri, 19 Oct 2018 09:12:40 -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=wRtu7/h6Bix6Vcw4Xfx2ru4d12CEnaR6YK8Pms953p0=; b=q7J/ktxgEOE2mmVLthVd/Bp2woM9G3q6yMCN7+5zFY2JxIr5Y/2TVAfMUEX3npDrqi kjIRjLRZju0fKmtD3hqQrkzuGId0oYDlaewjUGWdJ6YKu1wVz/RdVmmNMwb0IruYwcli z3OTjvRVG7W83INH97G6c//ydFg+oFE+K3pAJMtvywER97c0QqzpxXIg+hl7ifTZn0Bx MMI+lbazfsfWbrsLyhbWjGnzgyuZngpq6BxWRDuuol2Aj1jadZawF+sQYO5oHdR/I5QQ B8etL5BcMQMGEpNmOrW9+rZpvvXBNrW9gLe+++rIelyaLUnUq47Qkf9PmBDvi/dffict szwA== 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=wRtu7/h6Bix6Vcw4Xfx2ru4d12CEnaR6YK8Pms953p0=; b=lhPzxdSOG3vvfSGrNy3HyLiNDnj7yMZPO4iMLmNA9fBqeEUCdoS8nWTtdsGZuQAfMq 0l6Op9XnURRnAGzUUQ0a3hdSTdbYoKkKwCvrNtEmQaMOIiFgLodgtZBWcXFTXth5Py61 T2uwrgV07xx4I3Y/0Fp8NEevi26JGBrcYU6/Z0V8ld6VxiLWWLUfJdtvROPn1DKyFfbI lqgrL7tzJh2imjhCrTYiElCqZPsPESt32qtIrRTw/lke8EojbXa7qm2mHmZ/WT0XODTN y62XLcLzIxuKKpANrdjcnIx4NatTZTzg9ZcbIlHyCQ5qYiQK2/nj6aaIAYCDtIK3fW+D pw4g== X-Gm-Message-State: ABuFfohpHcxoTP0kc20IvDZc5tRXRLwS4Zm54qLmRIlk9V+/Gcvvqpni Uch+MOtbullImUzXqafo7rOq/wbPRsU= X-Google-Smtp-Source: ACcGV60FKoHbFcF+cskICrtc0lKbsC2wbPXLuh9Dn8AfqVxTWKFBSG1s7CMUSeiTgBecWZXPCbiRIQ== X-Received: by 2002:ac8:464d:: with SMTP id f13-v6mr32599268qto.377.1539965559646; Fri, 19 Oct 2018 09:12:39 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id l27-v6sm3666485qkj.79.2018.10.19.09.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 09:12:38 -0700 (PDT) From: Ben Peart To: git@vger.kernel.org Cc: gitster@pobox.com, benpeart@microsoft.com, peartben@gmail.com, peff@peff.net, sunshine@sunshineco.com Subject: [PATCH v2 1/3] reset: don't compute unstaged changes after reset when --quiet Date: Fri, 19 Oct 2018 12:12:26 -0400 Message-Id: <20181019161228.17196-2-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181019161228.17196-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181019161228.17196-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 --- builtin/reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/reset.c b/builtin/reset.c index 11cd0dcb8c..04f0d9b4f5 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -375,7 +375,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; if (read_from_tree(&pathspec, &oid, intent_to_add)) return 1; - if (get_git_work_tree()) + if (!quiet && get_git_work_tree()) refresh_index(&the_index, flags, NULL, NULL, _("Unstaged changes after reset:")); } else { From patchwork Fri Oct 19 16:12:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10649749 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 CFC5B13A4 for ; Fri, 19 Oct 2018 16:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD06F284C0 for ; Fri, 19 Oct 2018 16:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B10BC284F9; Fri, 19 Oct 2018 16:12:44 +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 60A67284C0 for ; Fri, 19 Oct 2018 16:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727706AbeJTAT2 (ORCPT ); Fri, 19 Oct 2018 20:19:28 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40704 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727282AbeJTAT2 (ORCPT ); Fri, 19 Oct 2018 20:19:28 -0400 Received: by mail-qt1-f194.google.com with SMTP id b4-v6so38856755qtc.7 for ; Fri, 19 Oct 2018 09:12:42 -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=O9bzCs0rDvQqTzkEpqdmPYnhCJ4ZOCGrni9vIcOWmRE=; b=C6IHrj70H1F1BhiPtOEP4WdNbGxAjGVeL6LbG/FyXgP2rZR8SAg1KV4O2+kCRI8/mc 9lp6CBRzE3vC0cPS42Q+atXXVL3rtFb3sbiZYZoKByKoqn+NiiMh2eD4jXap2XUBVTZu YetzuUJ9SGq2KxXUdNIf/X3NUN/MRgeLqBb2LpHZMV3SxseanH/xBSZ7DhcQ+XIjzfwl BFsTtRmYtAaEdAhQWEGr4h2NEG7BedMHX6ADnoD1gXMwaBEv80Ro4wQJUABEPFYIbpIw 9/JOhTpuCX47ZLDk2dEous9d+L9GbMOE/pJnbsvaxNpDo/MAEHgCtf079noDcnm5So5a yh7g== 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=O9bzCs0rDvQqTzkEpqdmPYnhCJ4ZOCGrni9vIcOWmRE=; b=EnYZs947GB78r/jo86SKCU5yr2l6dGYCPIKgyG0CdUvdB6YhdppgljO16nj4ELYnRv ZgCDWQqrNEdDQU7lNUDN0TQcJnpkmpYxa68+yBfWtlANbjCrko9CZNYVwwase4Fw2xky aaqRc+mpDPL3XkV4R8YbhzLcVCBikssyCWNcQqL7d2JPZmnQQAIBu1o+RMbWl+ABB/p8 H7dwP4HEGQqB/W7iNqNF5OZeaJwHvBN1g2x75MOJDERrakmt7phyzUMTVDZ9YSD/6GWW c78ur1MC43yJm5/Ey+Rg33DyPQqEhGe4sb1QIZjn7Ap5nOzFBDsRQDZcMJJQijdUNc4F L8LA== X-Gm-Message-State: ABuFfoivLRdzmNL0gwz75s9ARyzP0lGAnhePAL0OHb73hxx1+VTCKmQq FPwbHAmREolpleZJYFMYOsDRfUQRRIY= X-Google-Smtp-Source: ACcGV60tOrYFO5KuVMW2FmrxguaFiUqWeOHyJZ6CqQKpdW5wTOkrj9CqfOHND9g1Yh3kyZIKnnZgeQ== X-Received: by 2002:ac8:33d6:: with SMTP id d22-v6mr33410362qtb.313.1539965561295; Fri, 19 Oct 2018 09:12:41 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id l27-v6sm3666485qkj.79.2018.10.19.09.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 09:12:40 -0700 (PDT) From: Ben Peart To: git@vger.kernel.org Cc: gitster@pobox.com, benpeart@microsoft.com, peartben@gmail.com, peff@peff.net, sunshine@sunshineco.com Subject: [PATCH v2 2/3] reset: add new reset.quiet config setting Date: Fri, 19 Oct 2018 12:12:27 -0400 Message-Id: <20181019161228.17196-3-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181019161228.17196-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181019161228.17196-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.quiet 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 | 3 +++ builtin/reset.c | 1 + 2 files changed, 4 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index f6f4c21a54..a2d1b8b116 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2728,6 +2728,9 @@ rerere.enabled:: `$GIT_DIR`, e.g. if "rerere" was previously used in the repository. +reset.quiet:: + When set to true, 'git reset' will default to the '--quiet' option. + include::sendemail-config.txt[] sequence.editor:: diff --git a/builtin/reset.c b/builtin/reset.c index 04f0d9b4f5..3b43aee544 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.quiet", &quiet); argc = parse_options(argc, argv, prefix, options, git_reset_usage, PARSE_OPT_KEEP_DASHDASH); From patchwork Fri Oct 19 16:12:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10649751 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 5F72717DE for ; Fri, 19 Oct 2018 16:12:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E699284C0 for ; Fri, 19 Oct 2018 16:12:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42B64284F9; Fri, 19 Oct 2018 16:12:46 +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 D94E1284C0 for ; Fri, 19 Oct 2018 16:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727724AbeJTAT3 (ORCPT ); Fri, 19 Oct 2018 20:19:29 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42744 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727282AbeJTAT3 (ORCPT ); Fri, 19 Oct 2018 20:19:29 -0400 Received: by mail-qt1-f194.google.com with SMTP id j46-v6so38878330qtc.9 for ; Fri, 19 Oct 2018 09:12:43 -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=RafJZrSVIwfb9lBFq8Y4u0oa5Ww9W19YFPsDy/lATdk=; b=IkOe6g7LB/SuDXnIZWtAsqCNx5ycYa6osV4G7adz248SsUYX1PbAtIT5lR3W96x8gy Nzy7/rpEOXINkT8695b9gTCJNSLs42tqnHefnJ/xmrAyrBwUVAo1Af2ejWI6s6mEX76s pHnQzbVsZfrjlIwHIFF9jY6aYG1iKQtEKwryUelDzd7cHlqTjUQCtBfbjqCq4OanKWF3 mU0D9KGW14spobjykktEiqnOLNFVfYbt7DIvOX4FLlLkMuvUXXfN8hwQ/x2sfpXc6i63 dnviDy2JWj1+hSRA+NDXmm8dUEuQXEsDrzpLOrTixcKzkHbGS4tpka0w7IoMa/QTpwqD 8CSw== 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=RafJZrSVIwfb9lBFq8Y4u0oa5Ww9W19YFPsDy/lATdk=; b=S7JDJ05iKyB9qHwUwqKgNY4BBTS3mnHMOP9UuXIdYReLHn17qYsuuu8GqMYxPIxMvi 0LVMeighVk9Q6xm8f4HnO01U94i5W6zFalxZcnhqlyRwQycA6EHq/+kzazdCO6s/xAXw V8EqadVHw0xw04IwX+cLurOOkREZMdsDBHqGhn9oLLa3dOt0lJEghPonrnbX2CuXIz2B AgFIZYj1CNPseTh0hYbvaC05OiCyM+3KvL0xuCCtW90793yJXI2KqCf0H1dT45QhUORF B0rf3migv3w74fDzhsbEzFfT9WzBSdbPcbSVjaCyzVRLPyoSaklO2CEw77zFCpozsd55 Ij0w== X-Gm-Message-State: ABuFfoh/73lg/yoOGaz4jkxx5ZbIpfe9CudpGHaCC8/u+1jH7geZqsJw VTW5rh7LYKaNpwDiPtUw+qmnm78N5Po= X-Google-Smtp-Source: ACcGV62UOnpM0uIp6kQFfFpKGqvgWvQl82zV3mh6paZMstKmUkiYs/XPQr7RaXiqVz7voLHg5vhgRw== X-Received: by 2002:ac8:7287:: with SMTP id v7-v6mr34308002qto.126.1539965562653; Fri, 19 Oct 2018 09:12:42 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id l27-v6sm3666485qkj.79.2018.10.19.09.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 09:12:41 -0700 (PDT) From: Ben Peart To: git@vger.kernel.org Cc: gitster@pobox.com, benpeart@microsoft.com, peartben@gmail.com, peff@peff.net, sunshine@sunshineco.com Subject: [PATCH v2 3/3] reset: warn when refresh_index() takes more than 2 seconds Date: Fri, 19 Oct 2018 12:12:28 -0400 Message-Id: <20181019161228.17196-4-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181019161228.17196-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181019161228.17196-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 refresh_index() is done after a reset command as an optimization. Because it can be an expensive call, warn the user if it takes more than 2 seconds and tell them how to avoid it using the --quiet command line option or reset.quiet config setting. Signed-off-by: Ben Peart --- builtin/reset.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/builtin/reset.c b/builtin/reset.c index 3b43aee544..d95a27d52e 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -25,6 +25,8 @@ #include "submodule.h" #include "submodule-config.h" +#define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000) + static const char * const git_reset_usage[] = { N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] []"), N_("git reset [-q] [] [--] ..."), @@ -376,9 +378,19 @@ int cmd_reset(int argc, const char **argv, const char *prefix) int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; if (read_from_tree(&pathspec, &oid, intent_to_add)) return 1; - if (!quiet && get_git_work_tree()) + if (!quiet && get_git_work_tree()) { + uint64_t t_begin, t_delta_in_ms; + + t_begin = getnanotime(); refresh_index(&the_index, flags, NULL, NULL, _("Unstaged changes after reset:")); + t_delta_in_ms = (getnanotime() - t_begin) / 1000000; + if (t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) { + printf(_("\nIt took %.2f seconds to enumerate unstaged changes after reset. You can\n" + "use '--quiet' to avoid this. Set the config setting reset.quiet to true\n" + "to make this the default."), t_delta_in_ms / 1000.0); + } + } } else { int err = reset_index(&oid, reset_type, quiet); if (reset_type == KEEP && !err)