git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Pratyush Yadav <me@yadavpratyush.com>
To: <git@vger.kernel.org>
Cc: Pratyush Yadav <me@yadavpratyush.com>,
	Junio C Hamano <gitster@pobox.com>, Johannes Sixt <j6t@kdbg.org>,
	Bert Wesarg <bert.wesarg@googlemail.com>
Subject: [PATCH v2 2/4] git-gui: Add option to disable the revert confirmation prompt
Date: Fri, 23 Aug 2019 03:31:05 +0530	[thread overview]
Message-ID: <20190822220107.4153-3-me@yadavpratyush.com> (raw)
In-Reply-To: <20190822220107.4153-1-me@yadavpratyush.com>

When reverting files (or hunks or lines that future commits will add), a
confirmation dialog is shown to make sure the user actually wanted to
revert, and did not accidentally click revert.

But for some people's workflow this is an hindrance. So add an option to
disable this behaviour for people who are comfortable risking accidental
reverts.

The default behaviour is to ask for confirmation.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
---
 git-gui.sh     |  1 +
 lib/index.tcl  | 22 +++++++++++++---------
 lib/option.tcl |  1 +
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b8..b7811d8 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -903,6 +903,7 @@ set font_descs {
 }
 set default_config(gui.stageuntracked) ask
 set default_config(gui.displayuntracked) true
+set default_config(gui.revertaskconfirmation) true
 
 ######################################################################
 ##
diff --git a/lib/index.tcl b/lib/index.tcl
index cb7f74a..dd694d1 100644
--- a/lib/index.tcl
+++ b/lib/index.tcl
@@ -389,15 +389,19 @@ proc do_add_all {} {
 }
 
 proc revert_dialog {query} {
-	return [tk_dialog \
-		.confirm_revert \
-		"[appname] ([reponame])" \
-		"$query" \
-		question \
-		1 \
-		[mc "Do Nothing"] \
-		[mc "Revert Changes"] \
-		]
+	if {[is_config_true gui.revertaskconfirmation]} {
+		return [tk_dialog \
+			.confirm_revert \
+			"[appname] ([reponame])" \
+			"$query" \
+			question \
+			1 \
+			[mc "Do Nothing"] \
+			[mc "Revert Changes"] \
+			]
+	} else {
+		return 1
+	}
 }
 
 proc revert_helper {txt paths} {
diff --git a/lib/option.tcl b/lib/option.tcl
index e43971b..cb62d5d 100644
--- a/lib/option.tcl
+++ b/lib/option.tcl
@@ -162,6 +162,7 @@ proc do_options {} {
 		{s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}}
 		{b gui.displayuntracked {mc "Show untracked files"}}
 		{i-1..99 gui.tabsize {mc "Tab spacing"}}
+		{b gui.revertaskconfirmation {mc "Ask for confirmation when reverting changes"}}
 		} {
 		set type [lindex $option 0]
 		set name [lindex $option 1]
-- 
2.21.0


  parent reply	other threads:[~2019-08-22 22:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 21:41 [PATCH 0/3] git-gui: Add ability to revert selected hunks and lines Pratyush Yadav
2019-08-19 21:41 ` [PATCH 1/3] git-gui: Move revert confirmation dialog creation to separate function Pratyush Yadav
2019-08-19 21:41 ` [PATCH 2/3] git-gui: Add the ability to revert selected lines Pratyush Yadav
2019-08-20 19:21   ` Johannes Sixt
2019-08-20 19:29     ` Pratyush Yadav
2019-08-20 21:19       ` Johannes Sixt
2019-08-21 21:48         ` Pratyush Yadav
2019-08-23 13:01           ` Johannes Schindelin
2019-08-23 16:28             ` Junio C Hamano
2019-08-23 17:03               ` Pratyush Yadav
2019-08-23 19:17                 ` Johannes Sixt
2019-08-19 21:41 ` [PATCH 3/3] git-gui: Add the ability to revert selected hunk Pratyush Yadav
2019-08-20 18:47 ` [PATCH 0/3] git-gui: Add ability to revert selected hunks and lines Junio C Hamano
2019-08-20 19:49   ` Pratyush Yadav
2019-08-21  7:06 ` Bert Wesarg
2019-08-21 21:30   ` Pratyush Yadav
2019-08-22 22:01 ` [PATCH v2 0/4] " Pratyush Yadav
2019-08-22 22:01   ` [PATCH v2 1/4] git-gui: Move revert confirmation dialog creation to separate function Pratyush Yadav
2019-08-22 22:01   ` Pratyush Yadav [this message]
2019-08-22 22:01   ` [PATCH v2 3/4] git-gui: Add the ability to revert selected lines Pratyush Yadav
2019-08-23  6:29     ` Bert Wesarg
2019-08-23 16:51       ` Pratyush Yadav
2019-08-22 22:01   ` [PATCH v2 4/4] git-gui: Add the ability to revert selected hunk Pratyush Yadav
2019-08-22 22:34   ` [PATCH v2 0/4] git-gui: Add ability to revert selected hunks and lines Junio C Hamano
2019-08-22 22:51     ` Pratyush Yadav
2019-08-23  6:04       ` Bert Wesarg
2019-08-23 16:04         ` Junio C Hamano
2019-08-23 16:44         ` Pratyush Yadav
     [not found]           ` <CAKPyHN0QbCDzcG8=zPP4-WHKqMk3R0sJ0BjXDR=zak3OfEa2bg@mail.gmail.com>
2019-08-25 11:57             ` Pratyush Yadav
2019-08-23 23:43   ` David Aguilar
2019-08-24  6:54     ` Bert Wesarg
2019-08-24  6:57     ` Bert Wesarg
2019-08-24  7:26       ` David Aguilar
2019-08-24  8:09       ` Johannes Sixt
2019-08-28 21:57 ` [PATCH v3 " Pratyush Yadav
2019-08-28 21:57   ` [PATCH v3 1/4] git-gui: allow reverting selected lines Pratyush Yadav
2019-08-28 21:57   ` [PATCH v3 2/4] git-gui: allow reverting selected hunk Pratyush Yadav
2019-08-28 21:57   ` [PATCH v3 3/4] git-gui: return early when patch fails to apply Pratyush Yadav
2019-08-28 21:57   ` [PATCH v3 4/4] git-gui: allow undoing last revert Pratyush Yadav
2019-10-21  9:16     ` Bert Wesarg
2019-10-21 19:04       ` Pratyush Yadav
2019-10-22  8:17         ` Bert Wesarg
2019-10-23 18:57           ` Pratyush Yadav
2019-10-21 19:35       ` Johannes Sixt
2019-10-22  7:46         ` Bert Wesarg
2019-10-23 19:00           ` Pratyush Yadav
2019-09-10 19:21   ` [PATCH v3 0/4] git-gui: Add ability to revert selected hunks and lines Pratyush Yadav
2019-09-10 20:26     ` Johannes Sixt
2019-09-12 18:59       ` Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190822220107.4153-3-me@yadavpratyush.com \
    --to=me@yadavpratyush.com \
    --cc=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).