[PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean

Subsystems: library code, the rest

STALE3742d

3 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:19

Signed-off-by: Bert Wesarg <redacted>
---
 lib/commit.tcl |    2 +-
 lib/option.tcl |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 372bed9..e27e148 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -263,7 +263,7 @@ proc commit_commitmsg {curHEAD msg_p} {
 	global is_detached repo_config
 	global pch_error
 
-	if {$is_detached && $repo_config(gui.warndetachedcommit)} {
+	if {$is_detached && [is_config_true gui.warndetachedcommit]} {
 		set msg [mc "You are about to commit on a detached head.\
 This is a potentially dangerous thing to do because if you switch\
 to another branch you will loose your changes and it can be difficult\
diff --git a/lib/option.tcl b/lib/option.tcl
index 719103a..f7f866b 100644
--- a/lib/option.tcl
+++ b/lib/option.tcl
@@ -156,6 +156,7 @@ proc do_options {} {
 		{i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
 		{t gui.newbranchtemplate {mc "New Branch Name Template"}}
 		{c gui.encoding {mc "Default File Contents Encoding"}}
+		{b gui.warndetachedcommit {mc "Warn before commiting to a detached head"}}
 		{s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}}
 		} {
 		set type [lindex $option 0]
-- 
1.7.7.908.g383b5

[PATCH 2/2] git-gui: don't warn for detached head when rebasing

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:19

Signed-off-by: Bert Wesarg <redacted>
---
 lib/commit.tcl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/commit.tcl b/lib/commit.tcl
index e27e148..d679db4 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -263,7 +263,9 @@ proc commit_commitmsg {curHEAD msg_p} {
 	global is_detached repo_config
 	global pch_error
 
-	if {$is_detached && [is_config_true gui.warndetachedcommit]} {
+	if {$is_detached
+	    && ![file exists [gitdir [file join rebase-merge head-name]]]
+	    && 	[is_config_true gui.warndetachedcommit]} {
 		set msg [mc "You are about to commit on a detached head.\
 This is a potentially dangerous thing to do because if you switch\
 to another branch you will loose your changes and it can be difficult\
-- 
1.7.7.908.g383b5

Re: [PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:22

On Sat, Oct 22, 2011 at 21:39, Bert Wesarg [off-list ref] wrote:
quoted hunk
Signed-off-by: Bert Wesarg <redacted>
---
 lib/commit.tcl |    2 +-
 lib/option.tcl |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 372bed9..e27e148 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -263,7 +263,7 @@ proc commit_commitmsg {curHEAD msg_p} {
       global is_detached repo_config
       global pch_error

-       if {$is_detached && $repo_config(gui.warndetachedcommit)} {
+       if {$is_detached && [is_config_true gui.warndetachedcommit]} {
               set msg [mc "You are about to commit on a detached head.\
 This is a potentially dangerous thing to do because if you switch\
 to another branch you will loose your changes and it can be difficult\
diff --git a/lib/option.tcl b/lib/option.tcl
index 719103a..f7f866b 100644
--- a/lib/option.tcl
+++ b/lib/option.tcl
@@ -156,6 +156,7 @@ proc do_options {} {
               {i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
               {t gui.newbranchtemplate {mc "New Branch Name Template"}}
               {c gui.encoding {mc "Default File Contents Encoding"}}
+               {b gui.warndetachedcommit {mc "Warn before commiting to a detached head"}}
               {s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}}
               } {
               set type [lindex $option 0]
Pat,

if you're interessted in this patch, please fix the typo in the second
hunk, mentioning 'commiting'.

Also shouldn't this variable be called gui.warndetachedhead?

Thanks.

Bert
--
1.7.7.908.g383b5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help