All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Pratyush Yadav <me@yadavpratyush.com>,
	Luke Bonanomi <lbonanomi@gmail.com>
Subject: [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows
Date: Wed, 11 Mar 2020 19:24:36 +0000	[thread overview]
Message-ID: <pull.578.git.1583954676691.gitgitgadget@gmail.com> (raw)

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

             reply	other threads:[~2020-03-11 19:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 19:24 Johannes Schindelin via GitGitGadget [this message]
2020-03-11 20:17 ` [PATCH] git-gui--askpass: coerce answers to UTF-8 on Windows 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

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

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

  git send-email \
    --in-reply-to=pull.578.git.1583954676691.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=lbonanomi@gmail.com \
    --cc=me@yadavpratyush.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.