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

4 messages from 2011-10-22 to 2011-11-05. Participants: Bert Wesarg, Pat Thoyts.
Thread: https://gitlist.dev/t/28749

## Bert Wesarg, 2011-10-22 19:39

Subject: [PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean
Message-ID: <0f4995b5df707782c73ec83171fb2f512ae887ef.1319312280.git.bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/0f4995b5df707782c73ec83171fb2f512ae887ef.1319312280.git.bert.wesarg%40googlemail.com

```
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 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

```

## Bert Wesarg, 2011-10-22 19:39

Subject: [PATCH 2/2] git-gui: don't warn for detached head when rebasing
Message-ID: <a9a6eb9e70a8d4a75f2061a51bf401469d1b0b7f.1319312280.git.bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/a9a6eb9e70a8d4a75f2061a51bf401469d1b0b7f.1319312280.git.bert.wesarg%40googlemail.com
In-Reply-To: <0f4995b5df707782c73ec83171fb2f512ae887ef.1319312280.git.bert.wesarg@googlemail.com>

```
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 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

```

## Bert Wesarg, 2011-11-03 11:27

Subject: Re: [PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean
Message-ID: <CAKPyHN24RwNjJanaMQ0AjXc2iorFw=taCmcS-iuNt0vQ46_TOg@mail.gmail.com>
URL: https://gitlist.dev/e/CAKPyHN24RwNjJanaMQ0AjXc2iorFw%3DtaCmcS-iuNt0vQ46_TOg%40mail.gmail.com
In-Reply-To: <0f4995b5df707782c73ec83171fb2f512ae887ef.1319312280.git.bert.wesarg@googlemail.com>

```
On Sat, Oct 22, 2011 at 21:39, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
>  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
>
>

```

## Pat Thoyts, 2011-11-05 00:48

Subject: Re: [PATCH 1/2] git-gui: make config gui.warndetachedcommit a boolean
Message-ID: <878vnvo0md.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/878vnvo0md.fsf%40fox.patthoyts.tk
In-Reply-To: <CAKPyHN24RwNjJanaMQ0AjXc2iorFw=taCmcS-iuNt0vQ46_TOg@mail.gmail.com>

```
Bert Wesarg <bert.wesarg@googlemail.com> writes:

>On Sat, Oct 22, 2011 at 21:39, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>> ---
>>  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

I've applied this with the spelling correction and also gitdir already
does [file join] on its args so squashed a slight modification there
too.

The flag is for warnings about commits. Calling 'warndetachedhead'
sounds like something that would warn you when you changed to a detached
head - not for when you are about to commit to one so I think the name
is fine.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```
