threads / rfc / 25874

RFC patchgit-gui: disable (un)staging for files with typechange flags

Subject: [PATCH/RFC] git-gui: disable (un)staging for files with typechange flags

## tl;dr

5 messages between Nov 30, 2010 and Dec 6, 2010. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Bert Wesarg· Nov 30, 2010, 22:21 UTC · lore
This covers also the case for newly added files in the index. Like this:
    echo bar >foo
    git add foo
    rm foo
    ln -s bar foo

This will result in an state of AT. And for cases where the type change is staged, and the new type was modified after the staging. Like this (cont.):

    git add foo
    git commit -mfoo
    rm foo
    echo bar >foo
    git add foo
    echo baz >foo
Will result in an state of TM for foo.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 git-gui.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to git-gui.sh +4 −2
diff --git a/git-gui.sh b/git-gui.sh
index 38362fa..1bebcf1 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1993,7 +1993,9 @@ foreach i {
 		{MD {mc "Staged for commit, missing"}}
 
 		{_T {mc "File type changed, not staged"}}
+		{AT {mc "File type changed, old type staged for commit"}}
 		{T_ {mc "File type changed, staged"}}
+		{TM {mc "Staged file type change, modification not staged"}}
 
 		{_O {mc "Untracked, not staged"}}
 		{A_ {mc "Staged for commit"}}
@@ -3533,8 +3535,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
 			|| $current_diff_path eq {}
 			|| {__} eq $state
 			|| {_O} eq $state
-			|| {_T} eq $state
-			|| {T_} eq $state
+			|| [string match {?T} $state]
+			|| [string match {T?} $state]
 			|| [has_textconv $current_diff_path]} {
 			set s disabled
 		} else {
-- 
1.7.3.2.1200.ge4bf6
Bert Wesarg· Dec 3, 2010, 13:34 UTC · re: Bert Wesarg · lore

Re: [PATCH/RFC] git-gui: disable (un)staging for files with typechange flags

[ Adding Gustaf Hendeby, the author of the first patch to support type changes ]
On Tue, Nov 30, 2010 at 23:21, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 53 quoted lines
> This covers also the case for newly added files in the index. Like this:
>
>    echo bar >foo
>    git add foo
>    rm foo
>    ln -s bar foo
>
> This will result in an state of AT. And for cases where the type change is
> staged, and the new type was modified after the staging. Like this (cont.):
>
>    git add foo
>    git commit -mfoo
>    rm foo
>    echo bar >foo
>    git add foo
>    echo baz >foo
>
> Will result in an state of TM for foo.
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
>  git-gui.sh |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 38362fa..1bebcf1 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -1993,7 +1993,9 @@ foreach i {
>                {MD {mc "Staged for commit, missing"}}
>
>                {_T {mc "File type changed, not staged"}}
> +               {AT {mc "File type changed, old type staged for commit"}}
>                {T_ {mc "File type changed, staged"}}
> +               {TM {mc "Staged file type change, modification not staged"}}
>
>                {_O {mc "Untracked, not staged"}}
>                {A_ {mc "Staged for commit"}}
> @@ -3533,8 +3535,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
>                        || $current_diff_path eq {}
>                        || {__} eq $state
>                        || {_O} eq $state
> -                       || {_T} eq $state
> -                       || {T_} eq $state
> +                       || [string match {?T} $state]
> +                       || [string match {T?} $state]
>                        || [has_textconv $current_diff_path]} {
>                        set s disabled
>                } else {
> --
> 1.7.3.2.1200.ge4bf6
>
>
Bert Wesarg· Dec 6, 2010, 21:28 UTC · re: Bert Wesarg · lore

Re: [PATCH/RFC] git-gui: disable (un)staging for files with typechange flags

On Fri, Dec 3, 2010 at 14:34, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 21 quoted lines
> [ Adding Gustaf Hendeby, the author of the first patch to support type changes ]
>
> On Tue, Nov 30, 2010 at 23:21, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>> This covers also the case for newly added files in the index. Like this:
>>
>>    echo bar >foo
>>    git add foo
>>    rm foo
>>    ln -s bar foo
>>
>> This will result in an state of AT. And for cases where the type change is
>> staged, and the new type was modified after the staging. Like this (cont.):
>>
>>    git add foo
>>    git commit -mfoo
>>    rm foo
>>    echo bar >foo
>>    git add foo
>>    echo baz >foo
>>
>> Will result in an state of TM for foo.

This patch is incomplete. There are more places where the new AT and TM states needs to be handled. Please wait for a re-roll.

Bert
Pat Thoyts· Dec 6, 2010, 21:48 UTC · re: Bert Wesarg · lore

Re: [PATCH/RFC] git-gui: disable (un)staging for files with typechange flags

Bert Wesarg <bert.wesarg@googlemail.com> writes:
Show 49 quoted lines
>This covers also the case for newly added files in the index. Like this:
>
>    echo bar >foo
>    git add foo
>    rm foo
>    ln -s bar foo
>
>This will result in an state of AT. And for cases where the type change is
>staged, and the new type was modified after the staging. Like this (cont.):
>
>    git add foo
>    git commit -mfoo
>    rm foo
>    echo bar >foo
>    git add foo
>    echo baz >foo
>
>Will result in an state of TM for foo.
>
>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>---
> git-gui.sh |    6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/git-gui.sh b/git-gui.sh
>index 38362fa..1bebcf1 100755
>--- a/git-gui.sh
>+++ b/git-gui.sh
>@@ -1993,7 +1993,9 @@ foreach i {
> 		{MD {mc "Staged for commit, missing"}}
> 
> 		{_T {mc "File type changed, not staged"}}
>+		{AT {mc "File type changed, old type staged for commit"}}
> 		{T_ {mc "File type changed, staged"}}
>+		{TM {mc "Staged file type change, modification not staged"}}
> 
> 		{_O {mc "Untracked, not staged"}}
> 		{A_ {mc "Staged for commit"}}
>@@ -3533,8 +3535,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
> 			|| $current_diff_path eq {}
> 			|| {__} eq $state
> 			|| {_O} eq $state
>-			|| {_T} eq $state
>-			|| {T_} eq $state
>+			|| [string match {?T} $state]
>+			|| [string match {T?} $state]
> 			|| [has_textconv $current_diff_path]} {
> 			set s disabled
> 		} else {

This seems fine. We do get a warning about an 'unhandled 2 way diff marker' when it bumps into the second 'diff --git a/foo b/foo' section but I'm not sure anything can be safely done about that.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
Bert Wesarg· Dec 6, 2010, 22:17 UTC · re: Pat Thoyts · lore

Re: [PATCH/RFC] git-gui: disable (un)staging for files with typechange flags

On Mon, Dec 6, 2010 at 22:48, Pat Thoyts <patthoyts@users.sourceforge.net> wrote:

Show 55 quoted lines
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>>This covers also the case for newly added files in the index. Like this:
>>
>>    echo bar >foo
>>    git add foo
>>    rm foo
>>    ln -s bar foo
>>
>>This will result in an state of AT. And for cases where the type change is
>>staged, and the new type was modified after the staging. Like this (cont.):
>>
>>    git add foo
>>    git commit -mfoo
>>    rm foo
>>    echo bar >foo
>>    git add foo
>>    echo baz >foo
>>
>>Will result in an state of TM for foo.
>>
>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>>---
>> git-gui.sh |    6 ++++--
>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>
>>diff --git a/git-gui.sh b/git-gui.sh
>>index 38362fa..1bebcf1 100755
>>--- a/git-gui.sh
>>+++ b/git-gui.sh
>>@@ -1993,7 +1993,9 @@ foreach i {
>>               {MD {mc "Staged for commit, missing"}}
>>
>>               {_T {mc "File type changed, not staged"}}
>>+              {AT {mc "File type changed, old type staged for commit"}}
>>               {T_ {mc "File type changed, staged"}}
>>+              {TM {mc "Staged file type change, modification not staged"}}
>>
>>               {_O {mc "Untracked, not staged"}}
>>               {A_ {mc "Staged for commit"}}
>>@@ -3533,8 +3535,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
>>                       || $current_diff_path eq {}
>>                       || {__} eq $state
>>                       || {_O} eq $state
>>-                      || {_T} eq $state
>>-                      || {T_} eq $state
>>+                      || [string match {?T} $state]
>>+                      || [string match {T?} $state]
>>                       || [has_textconv $current_diff_path]} {
>>                       set s disabled
>>               } else {
>
> This seems fine. We do get a warning about an 'unhandled 2 way diff
> marker' when it bumps into the second 'diff --git a/foo b/foo' section
> but I'm not sure anything can be safely done about that.

We had this before, and you have proposed a fix for that ("git-gui: handle symlink replaced by file"). But as I wrote I have a better and nicer solution to that specific problem.

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

← back to recent threads