all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Cc: 23076@debbugs.gnu.org
Subject: bug#23076: 24.5; vc-git: add a new variable for log output coding system
Date: Mon, 04 Apr 2016 18:22:30 +0300	[thread overview]
Message-ID: <83pou5o0uh.fsf@gnu.org> (raw)
In-Reply-To: <57017E45.7050605@gmail.com> (message from Nikolay Kudryavtsev on Sun, 3 Apr 2016 23:34:13 +0300)

> From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
> Cc: 23076@debbugs.gnu.org
> Date: Sun, 3 Apr 2016 23:34:13 +0300
> 
> Hello Eli.
> 
> Just to explain the underlying issue.

Thanks.

> With emacs -Q try committing to the same repository by copy-pasting the previous commit message. Then do git log from shell. Your commit message would get broken.
> 
> This happens because git on Windows expects the commit message to be in your Windows "language for non-Unicode programs" encoding. Then it recodes from it to utf-8.

I think this conclusion is wrong.  The real reason for the problem is
that Emacs on Windows invokes subordinate programs in a way that
non-ASCII characters in the command-line arguments can only be encoded
in the system codepage.  And Emacs uses the -m command-line argument
to pass the commit log message to Git.  IOW, the problem is not with
Git, the problem is with how Emacs on Windows invokes it.  (For
complicated reasons I won't go into, this general problem cannot be
easily fixed in Emacs.)

So any non-ASCII text encoded in some encoding other than the current
system codepage will become garbled even before it gets to Git.

> So, to be able to commit in russian we:
> 1. Change language for non-Unicode programs to russian.
> 2. (setq vc-git-commits-coding-system 'windows-1251)

This solution doesn't really work for the reasons explained above.

> After doing this, commiting in russian would work. But now our C-x v l is broken.

"C-x v l" is broken because it uses the same value of
vc-git-commits-coding-system to read what Gt outputs, whereas Git
outputs in UTF-8.

> We can either fix it by setting logoutputencoding in git, but this would break git log outside of emacs, or add a new variable to vc, and that's what I want.

I don't think this is the right solution, see below.

> That's a relatively recent change in git, from 2013 or 2014, so if you're using some really old version, everything might just work out of box. 

I have Git 2.8.0, the latest official release.

Since the problem is (a) specific to MS-Windows, and (b) related to
encoding the command-line arguments, the solution should target the
root cause and nothing else, IMO.  Introducing a separate variable
that users should need to configure sounds therefore as not the best
idea.  Moreover, on MS-Windows any value of that additional variable
that is not exactly equal to the current system codepage will simply
fail to work.

So instead, I can suggest one of the following alternatives, to be
done only when invoking Git to commit on MS-Windows:

 1) ignore vc-git-commits-coding-system and always encode the
    command-line arguments using the system locale (in your case,
    codepage 1251); or

 2) put the log message in a temporary file, encoded in
    vc-git-commits-coding-system, then use -F instead of -m; the rest
    of command-line arguments will be encoded in the system locale's
    codepage

The 1st solution is essentially what you wanted, but without the need
to introduce an additional variable or ask the users to configure it.

The 2nd solution is somewhat slower, but it is better, because it will
allow to write log messages using any characters, not just those
representable in the current codepage.  Note that it still doesn't
solve all the problems with non-ASCII characters, because those could
be in the "author" or any of the other arguments with which we call
Git, such as the names of the files whose changes are to be committed
(as Emacs does support arbitrary characters in file names).

Comments?





  reply	other threads:[~2016-04-04 15:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 11:51 bug#23076: 24.5; vc-git: add a new variable for log output coding system Nikolay Kudryavtsev
2016-03-21 19:01 ` Nikolay Kudryavtsev
2016-04-02 10:16   ` Eli Zaretskii
2016-04-03 20:34     ` Nikolay Kudryavtsev
2016-04-04 15:22       ` Eli Zaretskii [this message]
2016-04-08  8:23         ` Eli Zaretskii
2016-04-09 12:30         ` Nikolay Kudryavtsev
2016-04-09 12:50           ` Eli Zaretskii
2016-04-09 14:14             ` Nikolay Kudryavtsev
2016-04-09 14:48               ` Eli Zaretskii
2016-04-10 16:10                 ` Eli Zaretskii
2016-04-11 22:12                   ` Nikolay Kudryavtsev
2016-04-12 15:07                   ` Nikolay Kudryavtsev
2016-04-12 15:22                     ` Eli Zaretskii
     [not found] <acdfa136-1d37-a920-b572-fdd0f6e11257@gmail.com>
     [not found] ` <837fch1vmw.fsf@gnu.org>
2016-07-25 18:46   ` Nikolay Kudryavtsev
2016-07-25 19:10     ` Eli Zaretskii
2016-07-26 19:01       ` Michael Albinus
2016-07-27  2:36         ` Eli Zaretskii
2016-08-07 12:08     ` Michael Albinus

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=83pou5o0uh.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=23076@debbugs.gnu.org \
    --cc=nikolay.kudryavtsev@gmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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.