git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows
@ 2020-03-11 19:24 Johannes Schindelin via GitGitGadget
  2020-03-11 20:17 ` Junio C Hamano
  2020-03-12 21:31 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-03-11 19:24 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Pratyush Yadav, Luke Bonanomi

From: Luke Bonanomi <lbonanomi@gmail.com>

This addresses the issue where Git for Windows asks the user for a
password, no credential helper is available, and then Git fails to pick
up non-ASCII characters from the Git GUI helper.

This can be verified e.g. via

	echo host=http://abc.com |
	git -c credential.helper= credential fill

and then pasting some umlauts.

The underlying reason is that Git for Windows tries to communicate using
the UTF-8 encoding no matter what the actual current code page is. So
let's indulge Git for Windows and do use that encoding.

This fixes https://github.com/git-for-windows/git/issues/2215

Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    Fix git-gui--askpass on Windows
    
    Windows has this odd thing where there is an active code page (somewhat
    like LC_CTYPE) and there is no real UTF-8 code page. So we need to help 
    git-gui--askpass along a bit to be of use when asking for credentials.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-578%2Fdscho%2Fgit-gui--askpass-utf-8-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-578/dscho/git-gui--askpass-utf-8-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/578

 git-gui--askpass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/git-gui--askpass b/git-gui--askpass
index 4277f30c411..b0704e6d91e 100755
--- a/git-gui--askpass
+++ b/git-gui--askpass
@@ -56,6 +56,11 @@ proc finish {} {
 		}
 	}
 
+	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
+		if {$::tcl_platform(platform) eq {windows}} {
+		set ::answer [encoding convertto utf-8 $::answer]
+	}
+
 	puts $::answer
 	set ::rc 0
 }

base-commit: 63a58457e094c9c9bbf562b872009d32f1f88133
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows
  2020-03-11 19:24 [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows Johannes Schindelin via GitGitGadget
@ 2020-03-11 20:17 ` Junio C Hamano
  2020-03-12 21:31 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2020-03-11 20:17 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Johannes Schindelin, Pratyush Yadav, Luke Bonanomi

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> diff --git a/git-gui--askpass b/git-gui--askpass
> index 4277f30c411..b0704e6d91e 100755
> --- a/git-gui--askpass
> +++ b/git-gui--askpass
> @@ -56,6 +56,11 @@ proc finish {} {
>  		}
>  	}
>  
> +	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
> +		if {$::tcl_platform(platform) eq {windows}} {

The indentation looks funny here.  Dedent one level?

> +		set ::answer [encoding convertto utf-8 $::answer]
> +	}

Looks correct (assuming that $::answer we got is Unicode "string",
and I think that is a sane assumpton as it came directly from a
textvariable bound to an entry widget).

>  	puts $::answer
>  	set ::rc 0
>  }
>
> base-commit: 63a58457e094c9c9bbf562b872009d32f1f88133

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] git-gui--askpass: coerce answers to UTF-8 on Windows
  2020-03-11 19:24 [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows Johannes Schindelin via GitGitGadget
  2020-03-11 20:17 ` Junio C Hamano
@ 2020-03-12 21:31 ` Johannes Schindelin via GitGitGadget
  2020-03-13  0:11   ` Junio C Hamano
  2020-03-14 17:26   ` Pratyush Yadav
  1 sibling, 2 replies; 5+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-03-12 21:31 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Pratyush Yadav, Luke Bonanomi

From: Luke Bonanomi <lbonanomi@gmail.com>

This addresses the issue where Git for Windows asks the user for a
password, no credential helper is available, and then Git fails to pick
up non-ASCII characters from the Git GUI helper.

This can be verified e.g. via

	echo host=http://abc.com |
	git -c credential.helper= credential fill

and then pasting some umlauts.

The underlying reason is that Git for Windows tries to communicate using
the UTF-8 encoding no matter what the actual current code page is. So
let's indulge Git for Windows and do use that encoding.

This fixes https://github.com/git-for-windows/git/issues/2215

Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    Fix git-gui--askpass on Windows
    
    Windows has this odd thing where there is an active code page (somewhat
    like LC_CTYPE) and there is no real UTF-8 code page. So we need to help 
    git-gui--askpass along a bit to be of use when asking for credentials.
    
    Changes since v1:
    
     * Fixed indentation

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-578%2Fdscho%2Fgit-gui--askpass-utf-8-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-578/dscho/git-gui--askpass-utf-8-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/578

Range-diff vs v1:

 1:  3beec773772 ! 1:  7891941486d git-gui--askpass: coerce answers to UTF-8 on Windows
     @@ -20,6 +20,7 @@
          This fixes https://github.com/git-for-windows/git/issues/2215
      
          Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
     +    Helped-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
       diff --git a/git-gui--askpass b/git-gui--askpass
     @@ -30,7 +31,7 @@
       	}
       
      +	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
     -+		if {$::tcl_platform(platform) eq {windows}} {
     ++	if {$::tcl_platform(platform) eq {windows}} {
      +		set ::answer [encoding convertto utf-8 $::answer]
      +	}
      +


 git-gui--askpass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/git-gui--askpass b/git-gui--askpass
index 4277f30c411..1c99ee8ca20 100755
--- a/git-gui--askpass
+++ b/git-gui--askpass
@@ -56,6 +56,11 @@ proc finish {} {
 		}
 	}
 
+	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
+	if {$::tcl_platform(platform) eq {windows}} {
+		set ::answer [encoding convertto utf-8 $::answer]
+	}
+
 	puts $::answer
 	set ::rc 0
 }

base-commit: 63a58457e094c9c9bbf562b872009d32f1f88133
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] git-gui--askpass: coerce answers to UTF-8 on Windows
  2020-03-12 21:31 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
@ 2020-03-13  0:11   ` Junio C Hamano
  2020-03-14 17:26   ` Pratyush Yadav
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2020-03-13  0:11 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Johannes Schindelin, Pratyush Yadav, Luke Bonanomi

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Luke Bonanomi <lbonanomi@gmail.com>
>
> This addresses the issue where Git for Windows asks the user for a
> password, no credential helper is available, and then Git fails to pick
> up non-ASCII characters from the Git GUI helper.
>
> This can be verified e.g. via
>
> 	echo host=http://abc.com |
> 	git -c credential.helper= credential fill
>
> and then pasting some umlauts.
>
> The underlying reason is that Git for Windows tries to communicate using
> the UTF-8 encoding no matter what the actual current code page is. So
> let's indulge Git for Windows and do use that encoding.
>
> This fixes https://github.com/git-for-windows/git/issues/2215
>
> Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---

Heh, that is over-crediting me.  I didn't do anything other than
just scan the code once.

>     Fix git-gui--askpass on Windows
>     
>     Windows has this odd thing where there is an active code page (somewhat
>     like LC_CTYPE) and there is no real UTF-8 code page. So we need to help 
>     git-gui--askpass along a bit to be of use when asking for credentials.
>     
>     Changes since v1:
>     
>      * Fixed indentation
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-578%2Fdscho%2Fgit-gui--askpass-utf-8-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-578/dscho/git-gui--askpass-utf-8-v2
> Pull-Request: https://github.com/gitgitgadget/git/pull/578
>
> Range-diff vs v1:
>
>  1:  3beec773772 ! 1:  7891941486d git-gui--askpass: coerce answers to UTF-8 on Windows
>      @@ -20,6 +20,7 @@
>           This fixes https://github.com/git-for-windows/git/issues/2215
>       
>           Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
>      +    Helped-by: Junio C Hamano <gitster@pobox.com>
>           Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>       
>        diff --git a/git-gui--askpass b/git-gui--askpass
>      @@ -30,7 +31,7 @@
>        	}
>        
>       +	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
>      -+		if {$::tcl_platform(platform) eq {windows}} {
>      ++	if {$::tcl_platform(platform) eq {windows}} {
>       +		set ::answer [encoding convertto utf-8 $::answer]
>       +	}
>       +
>
>
>  git-gui--askpass | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/git-gui--askpass b/git-gui--askpass
> index 4277f30c411..1c99ee8ca20 100755
> --- a/git-gui--askpass
> +++ b/git-gui--askpass
> @@ -56,6 +56,11 @@ proc finish {} {
>  		}
>  	}
>  
> +	# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
> +	if {$::tcl_platform(platform) eq {windows}} {
> +		set ::answer [encoding convertto utf-8 $::answer]
> +	}
> +
>  	puts $::answer
>  	set ::rc 0
>  }
>
> base-commit: 63a58457e094c9c9bbf562b872009d32f1f88133

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] git-gui--askpass: coerce answers to UTF-8 on Windows
  2020-03-12 21:31 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  2020-03-13  0:11   ` Junio C Hamano
@ 2020-03-14 17:26   ` Pratyush Yadav
  1 sibling, 0 replies; 5+ messages in thread
From: Pratyush Yadav @ 2020-03-14 17:26 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Johannes Schindelin, Luke Bonanomi, Junio C Hamano

On 12/03/20 09:31PM, Johannes Schindelin via GitGitGadget wrote:
> From: Luke Bonanomi <lbonanomi@gmail.com>
> 
> This addresses the issue where Git for Windows asks the user for a
> password, no credential helper is available, and then Git fails to pick
> up non-ASCII characters from the Git GUI helper.
> 
> This can be verified e.g. via
> 
> 	echo host=http://abc.com |
> 	git -c credential.helper= credential fill
> 
> and then pasting some umlauts.
> 
> The underlying reason is that Git for Windows tries to communicate using
> the UTF-8 encoding no matter what the actual current code page is. So
> let's indulge Git for Windows and do use that encoding.
> 
> This fixes https://github.com/git-for-windows/git/issues/2215
> 
> Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

Merged. Thanks all.

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-15  2:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 19:24 [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows Johannes Schindelin via GitGitGadget
2020-03-11 20:17 ` Junio C Hamano
2020-03-12 21:31 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
2020-03-13  0:11   ` Junio C Hamano
2020-03-14 17:26   ` Pratyush Yadav

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).