Re: encoding bug in git.el

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>

Thanks for taking the time.

-- 
Karl Hasselström, kha@xxxxxxxxxxx
      www.treskal.com/kalle
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux