From patchwork Tue Oct 23 19:04: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: 10653543 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 48FEA1747 for ; Tue, 23 Oct 2018 19:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382BA29EDE for ; Tue, 23 Oct 2018 19:04:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C7AE29F43; Tue, 23 Oct 2018 19:04:39 +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 1D3EB29F0B for ; Tue, 23 Oct 2018 19:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbeJXD3P (ORCPT ); Tue, 23 Oct 2018 23:29:15 -0400 Received: from mail-vk1-f196.google.com ([209.85.221.196]:38986 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbeJXD3P (ORCPT ); Tue, 23 Oct 2018 23:29:15 -0400 Received: by mail-vk1-f196.google.com with SMTP id y69so621707vkd.6 for ; Tue, 23 Oct 2018 12:04:35 -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=MHcaqR+ft/9mL3nDuUgXmOvhGxQB759K4PLzts0umBI=; b=DUWwLKd8Az7e3rARppjSFhX4dTmck6IDsfErpLMW7bpw/m0RU8l+YNwMU5CBHtLoRI n5iimBCRVEOGlP+bNz+ykamJvWihM0acK8BAVjP+kG1Q00JkJBuPLMTatPpPHrdpe5D7 YlGDkQaWRzpViX1CmT10V1CaVaXZGnevpOSmkE0E6bz/re5pk17lyM3nZyD5TKrHPh3/ w/Hnqt1b3mWfVfranCtHzH3bx6urnvy6bBYt4rbynobV6hby/yoz3IvQzd+VK0iOUxB+ /QmX7dY0i7haP2AmOyNY/ekJaKjXooNSaqTPfYtv0ytJelmPIzT5enhAZubZip72zIAM CmeA== 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=MHcaqR+ft/9mL3nDuUgXmOvhGxQB759K4PLzts0umBI=; b=MnT7YEuljWtI4NbicUuk5bqSDplIbmImr20IWcXl3X3Qd9f0dQYOOLhgqy/omZ/Dfp q6ESbkqxnf/YiqSZk4sfyXxf3gaqlEkLjfCFpWOhDJfrksvAIEPjBMIa9bHbF3063WOD 1vwYvlQi70RbRJIQHsuqS5Mz1BHkPV0YunjtP805RoNKio3FAEpM30qGHgaMF7JN+923 VjC9b+YX8BSS3kBWF9zHzL+dMsJyaa0kStWG/HYuwUuuRZgqOUM9hdqRALLrhmf5eVlW Htnj5Zhgky9JzRhV78VNiioTHZL+Dft/TWPkWOKUmp4TsdQu3P2WZRojhXjrQUFiA4Ff QbCQ== X-Gm-Message-State: AGRZ1gKLX0R/Iz+iVImkjx7OwmPsv8jF2Tx9jkLqX1ZXTmwsNZtH2QeO pqTGvpXQaPCJF/9BM9vJXiHCy3mLHJY= X-Google-Smtp-Source: AJdET5c+V6B3WjUkE/HkqM65kYw5HjOUMAvywX0Xl2yIOSCO1eVK5mL+sJZqP5pLFj4er4oopCW18g== X-Received: by 2002:a1f:d803:: with SMTP id p3mr1503975vkg.9.1540321474203; Tue, 23 Oct 2018 12:04:34 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id e79sm473284vsd.1.2018.10.23.12.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 12:04:33 -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 v4 1/3] reset: don't compute unstaged changes after reset when --quiet Date: Tue, 23 Oct 2018 15:04:21 -0400 Message-Id: <20181023190423.5772-2-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181023190423.5772-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181023190423.5772-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 on Windows 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 Tue Oct 23 19:04:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10653539 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 AC69614BD for ; Tue, 23 Oct 2018 19:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B58C29EDE for ; Tue, 23 Oct 2018 19:04:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FCFB29F43; Tue, 23 Oct 2018 19:04: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 3E4B029F4B for ; Tue, 23 Oct 2018 19:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728830AbeJXD3Q (ORCPT ); Tue, 23 Oct 2018 23:29:16 -0400 Received: from mail-vk1-f195.google.com ([209.85.221.195]:41788 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbeJXD3Q (ORCPT ); Tue, 23 Oct 2018 23:29:16 -0400 Received: by mail-vk1-f195.google.com with SMTP id c82so622138vke.8 for ; Tue, 23 Oct 2018 12:04:36 -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=iYQ7WC5GgyrF/7tf7L4/hn553p2vcpxNHwyugM8Z+L4=; b=Rva82Q1JeXzRWpzzmvwhyTmqJ5lTg0Z5iGV3r7Ik16zv35Ngoey3elhVbkBmJJ5xQ3 qjV96sPkXyjpPi6sM+KR+r+0cRz1yBuCOiwdBMGJHQCPwA3aRbYFjy6We54+COY5X/ZO uLI4L0aBhKevYQfA0tQjC2KELNCN9x8H1nV76LH72yRlLoJ33HS2siTrkQ2e8UiRLZz2 vf7kXYSZqpkMxdKiMeHTDcz2TxMnOXGwZULsD5bOwvitIVbeov7sgpg+2uI9eCrQfEgD Uh5JAE1HRCLnETblufS16jywxN84obNjLXv1uVguURX5CLrfalhPHIn04uUrhE4j+ub2 wiEg== 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=iYQ7WC5GgyrF/7tf7L4/hn553p2vcpxNHwyugM8Z+L4=; b=a5Wb8RapM1BJoogL/P3iA/zqyyD0QzS7PRhObwqzTLfRbRQpdNS9Ug5CFCi+hZ4K+/ ka+YFyXjILmsb6ifimO7D5w/rHexac4PpeAzpebsOLw5VA3BuCIDzmRJG+TBfYpGilfu M3Ld/+2BrGCYmlOspD1AKtg4/8Y31aSm67sL8OY8EO+72fwTyAiLMJG9XiEJpu1U8ns/ 4ugbO7893jBhq58QBM5ZtwcVU1ApmXmtab2i5+GPj/xHWbrzlCA7reHhv4nmURdFVtz8 gzlgKCseq+4GFcPSvjn/O0bBtfIwYRczeTGfqdBR48Ps1FZ+Qp9G/reRBTIHzWDWbQvl JI9Q== X-Gm-Message-State: ABuFfog53HunSeI1WfS1BGX/Nhwx2aWR90Oi84GeW2/9sKEm/uh6BKqN ZdSHFP1m7VLNO/YIv/IAaRdJNZTAj3k= X-Google-Smtp-Source: ACcGV61hAyA0SHkIpiiGSM75vMINrbITZsXKwkLSuhQWz6uPusdGDZ+/Zcqa6HkVunmbO7lHSH9Ihw== X-Received: by 2002:a1f:cfc7:: with SMTP id f190-v6mr21884181vkg.11.1540321475412; Tue, 23 Oct 2018 12:04:35 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id e79sm473284vsd.1.2018.10.23.12.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 12:04:34 -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 v4 2/3] reset: add new reset.quiet config setting Date: Tue, 23 Oct 2018 15:04:22 -0400 Message-Id: <20181023190423.5772-3-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181023190423.5772-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181023190423.5772-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 +++ Documentation/git-reset.txt | 5 ++++- builtin/reset.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) 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/Documentation/git-reset.txt b/Documentation/git-reset.txt index 1d697d9962..2dac95c71a 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -95,7 +95,10 @@ OPTIONS -q:: --quiet:: - Be quiet, only report errors. +--no-quiet:: + Be quiet, only report errors. The default behavior is set by the + `reset.quiet` config option. `--quiet` and `--no-quiet` will + override the default behavior. EXAMPLES 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 Tue Oct 23 19:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10653545 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 8CCF713BF for ; Tue, 23 Oct 2018 19:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A5B229EDE for ; Tue, 23 Oct 2018 19:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E95429F43; Tue, 23 Oct 2018 19:04:42 +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 4EA8A29EDE for ; Tue, 23 Oct 2018 19:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728851AbeJXD3S (ORCPT ); Tue, 23 Oct 2018 23:29:18 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:42516 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbeJXD3R (ORCPT ); Tue, 23 Oct 2018 23:29:17 -0400 Received: by mail-vs1-f65.google.com with SMTP id e126so1575197vsc.9 for ; Tue, 23 Oct 2018 12:04:37 -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=7RdQgjGqr6GRmzkGt1gaarS6qqA/xxmaBTO5WaTZrOw=; b=Fr5uD10mmyNdAQRYvToMSvetOZRm+ccLLFA3c1S7V3XEqEud4Iq8vJigUKxi99HQxx r/sCdkL9Y401DG8LtVxFCZ/ILvvZlJ23nTVI7Azz8IzYq/+93zRxpjgN8E97seLzXWgO z8U7YljRA7eHKkUHKZhbFi6WKUXt3/EJ7wpqxoaRo+/MmoSyjXj5sIJvXWtrmafSxqD0 NDpdJSqGhgf/HqaXKyEAKyNTgzVDpxn7YrYfOKU3soqbe7NdNrahO4/Zp4wMCdHuPI+b QIonOl+MS0hPfMb7M1cGsVXbLuAXnX7iRipOMcSzCKV7KxuRi4k1kw5yNEjIJX9HAqgy fO6A== 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=7RdQgjGqr6GRmzkGt1gaarS6qqA/xxmaBTO5WaTZrOw=; b=to14J4XqF3JcclBM5CIXMz06c6AGnbJjZI0HznXnGCoX3VGEz+z/LEQbsN5eYCHKBc 3Bd4BwKYcvirUQGZWrA737I1lUlWJdy3tyVcuZhq+9lshPwR2Moh1Aon0n1COa7K3Ivv fWtVj0QhrLlcGhX2yDaLZcpqWOpd8K4HWdstz9ZH6PyneR03A9FI+pNrguAx0GKkSW4+ 5WH49tO0YQCBwlMUWjuyuf2fn5J0MibS3qfgzes9q9M4muvb+MWKp9zu8YgWhXe9JjnI CmCHppYrDRS9gm1pRqNAQm3pJm+fR/nz3moBJTohILLoYUV1yij2o56f6uTechUdchAa Z1+w== X-Gm-Message-State: ABuFfogwEXspY4NwLuR1Gv1x7L4hvSPxRrCCL5lIx87wKUeiFDxDOQ7u bCZZcK1PNHCAkLg1XMuDIC4XYvkMzcU= X-Google-Smtp-Source: ACcGV61+bfKUK3n8qq5phiUgttxkH8g2zawhdM6utsGyFQJosJ0xCwQkJ3HVFaDjWY1aJ2zD1jfRMw== X-Received: by 2002:a67:f04e:: with SMTP id q14mr2172160vsm.173.1540321476553; Tue, 23 Oct 2018 12:04:36 -0700 (PDT) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id e79sm473284vsd.1.2018.10.23.12.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 12:04:35 -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 v4 3/3] reset: warn when refresh_index() takes more than 2 seconds Date: Tue, 23 Oct 2018 15:04:23 -0400 Message-Id: <20181023190423.5772-4-peartben@gmail.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181023190423.5772-1-peartben@gmail.com> References: <20181017164021.15204-1-peartben@gmail.com> <20181023190423.5772-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 --- Documentation/config.txt | 4 ++++ advice.c | 2 ++ advice.h | 1 + builtin/reset.c | 14 +++++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index a2d1b8b116..415db31def 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -333,6 +333,10 @@ advice.*:: commitBeforeMerge:: Advice shown when linkgit:git-merge[1] refuses to merge to avoid overwriting local changes. + resetQuiet:: + Advice to consider using the `--quiet` option to linkgit:git-reset[1] + when the command takes more than 2 seconds to enumerate unstaged + changes after reset. resolveConflict:: Advice shown by various commands when conflicts prevent the operation from being performed. diff --git a/advice.c b/advice.c index 3561cd64e9..5f35656409 100644 --- a/advice.c +++ b/advice.c @@ -12,6 +12,7 @@ int advice_push_needs_force = 1; int advice_status_hints = 1; int advice_status_u_option = 1; int advice_commit_before_merge = 1; +int advice_reset_quiet_warning = 1; int advice_resolve_conflict = 1; int advice_implicit_identity = 1; int advice_detached_head = 1; @@ -65,6 +66,7 @@ static struct { { "statusHints", &advice_status_hints }, { "statusUoption", &advice_status_u_option }, { "commitBeforeMerge", &advice_commit_before_merge }, + { "resetQuiet", &advice_reset_quiet_warning }, { "resolveConflict", &advice_resolve_conflict }, { "implicitIdentity", &advice_implicit_identity }, { "detachedHead", &advice_detached_head }, diff --git a/advice.h b/advice.h index ab24df0fd0..696bf0e7d2 100644 --- a/advice.h +++ b/advice.h @@ -12,6 +12,7 @@ extern int advice_push_needs_force; extern int advice_status_hints; extern int advice_status_u_option; extern int advice_commit_before_merge; +extern int advice_reset_quiet_warning; extern int advice_resolve_conflict; extern int advice_implicit_identity; extern int advice_detached_head; diff --git a/builtin/reset.c b/builtin/reset.c index 3b43aee544..b31a0eae8a 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 (advice_reset_quiet_warning && 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.\n"), t_delta_in_ms / 1000.0); + } + } } else { int err = reset_index(&oid, reset_type, quiet); if (reset_type == KEEP && !err)