From: "Karl Hasselström" <kha@treskal.com>
To: Clifford Caoile <piyo@users.sourceforge.net>
Cc: "David Kågedal" <davidk@lysator.liu.se>,
git@vger.kernel.org, "Junio C. Hamano" <gitster@pobox.com>
Subject: Re: encoding bug in git.el
Date: Sun, 25 May 2008 15:42:00 +0200 [thread overview]
Message-ID: <20080525134200.GA31990@diana.vm.bytemark.co.uk> (raw)
In-Reply-To: <1f748ec60805210708q34a26bebh915037713caa9a87@mail.gmail.com>
On 2008-05-21 23:08:09 +0900, Clifford Caoile wrote:
> Here is a proposed fix. I suggest that process-environment should be
> given these envvars already encoded as shown in this code sample:
>
> ------------------ git.el ------------------
> [not a proper git-diff]
> @@ -216,6 +216,11 @@ and `git-diff-setup-hook'."
> "Build a list of NAME=VALUE strings from a list of environment strings."
> (mapcar (lambda (entry) (concat (car entry) "=" (cdr entry))) env))
>
> +(defun git-get-env-strings-encoded (env encoding)
> + "Build a list of NAME=VALUE strings from a list of environment strings,
> +converting from mule-encoding to ENCODING (e.g. mule-utf-8, latin-1, etc)."
> + (mapcar (lambda (entry) (concat (car entry) "="
> (encode-coding-string (cdr entry) encoding))) env))
> +
> (defun git-call-process-env (buffer env &rest args)
> "Wrapper for call-process that sets environment strings."
> (let ((process-environment (append (git-get-env-strings env)
> @@ -265,7 +270,7 @@ and returns the process output as a string, or nil
> if the git failed."
>
> (defun git-run-command-region (buffer start end env &rest args)
> "Run a git command with specified buffer region as input."
> - (unless (eq 0 (let ((process-environment (append (git-get-env-strings env)
> + (unless (eq 0 (let ((process-environment (append
> (git-get-env-strings-encoded env coding-system-for-write)
> process-environment)))
> (git-run-process-region
> buffer start end "git" args)))
>
> The buffer text is saved with the encoding coding-system-for-write,
> while the GIT_* envvars were not encoded, so when appending to
> process-environment variable, use the same encoding.
I don't claim to understand any of the design issues around this, but
your patch certainly fixes my problem (once I managed to apply it,
which involved working around the lack of headers, non-matching
offsets, and whitespace damage -- luckily it was just two hunks). So:
Tested-by: Karl Hasselström <kha@treskal.com>
Thanks for taking the time.
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
next prev parent reply other threads:[~2008-05-25 13:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 22:09 encoding bug in git.el Karl Hasselström
[not found] ` <87mymkbo9x.fsf@lysator.liu.se>
2008-05-21 14:08 ` Clifford Caoile
2008-05-21 14:54 ` Karl Hasselström
2008-05-21 21:31 ` Clifford Caoile
2008-05-23 7:09 ` Karl Hasselström
2008-05-25 13:42 ` Karl Hasselström [this message]
2008-05-30 12:28 ` Karl Hasselström
2008-05-30 20:27 ` Junio C Hamano
2008-06-02 22:41 ` [PATCH] Revert "git.el: Set process-environment instead of invoking env" Karl Hasselström
2008-06-03 15:54 ` David Christensen
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=20080525134200.GA31990@diana.vm.bytemark.co.uk \
--to=kha@treskal.com \
--cc=davidk@lysator.liu.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=piyo@users.sourceforge.net \
/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 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 NNTP newsgroup(s).