{"thread":{"id":"7022","subject":"[PATCH] git.el: Set the default commit coding system from the repository config.","startedAt":"2007-02-28T19:59:48Z","lastAt":"2007-02-28T19:59:48Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35882","messageId":"87bqjexdcb.fsf@wine.dyndns.org","threadId":"7022","inReplyTo":null,"subject":"[PATCH] git.el: Set the default commit coding system from the repository config.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-02-28T19:59:48Z","receivedAt":"2007-02-28T19:59:48Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"If not otherwise specified, take the default coding system for commits\nfrom the 'i18n.commitencoding' repository configuration value.\n\nAlso set the buffer-file-coding-system variable in the log buffer to\nmake the selected coding system visible on the modeline.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   24 ++++++++++++++++++------\n 1 files changed, 18 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 24629eb..13d1982 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -75,10 +75,11 @@ then to `add-log-mailing-address' and then to `user-mail-address'.\"\n   :type '(choice (const :tag \"Default\" nil)\n                  (string :tag \"Email\")))\n \n-(defcustom git-commits-coding-system 'utf-8\n+(defcustom git-commits-coding-system nil\n   \"Default coding system for the log message of git commits.\"\n   :group 'git\n-  :type 'coding-system)\n+  :type '(choice (const :tag \"From repository config\" nil)\n+                 (coding-system)))\n \n (defcustom git-append-signed-off-by nil\n   \"Whether to append a Signed-off-by line to the commit message before editing.\"\n@@ -236,6 +237,15 @@ and returns the process output as a string.\"\n       (and (fboundp 'user-mail-address) (user-mail-address))\n       (and (boundp 'user-mail-address) user-mail-address)))\n \n+(defun git-get-commits-coding-system ()\n+  \"Return the coding system to use for commits.\"\n+  (let ((repo-config (git-config \"i18n.commitencoding\")))\n+    (or git-commits-coding-system\n+        (and repo-config\n+             (fboundp 'locale-charset-to-coding-system)\n+             (locale-charset-to-coding-system repo-config))\n+      'utf-8)))\n+\n (defun git-escape-file-name (name)\n   \"Escape a file name if necessary.\"\n   (if (string-match \"[\\n\\t\\\"\\\\]\" name)\n@@ -327,7 +337,7 @@ and returns the process output as a string.\"\n   \"Call git-commit-tree with buffer as input and return the resulting commit SHA1.\"\n   (let ((author-name (git-get-committer-name))\n         (author-email (git-get-committer-email))\n-        author-date log-start log-end args)\n+        author-date log-start log-end args coding-system-for-write)\n     (when head\n       (push \"-p\" args)\n       (push head args))\n@@ -350,12 +360,12 @@ and returns the process output as a string.\"\n                 (push \"-p\" args)\n                 (push (match-string 1) args))))\n         (setq log-start (point-min)))\n-      (setq log-end (point-max)))\n+      (setq log-end (point-max))\n+      (setq coding-system-for-write buffer-file-coding-system))\n     (git-get-string-sha1\n      (with-output-to-string\n        (with-current-buffer standard-output\n-         (let ((coding-system-for-write git-commits-coding-system)\n-               (env `((\"GIT_AUTHOR_NAME\" . ,author-name)\n+         (let ((env `((\"GIT_AUTHOR_NAME\" . ,author-name)\n                       (\"GIT_AUTHOR_EMAIL\" . ,author-email)\n                       (\"GIT_COMMITTER_NAME\" . ,(git-get-committer-name))\n                       (\"GIT_COMMITTER_EMAIL\" . ,(git-get-committer-email)))))\n@@ -888,6 +898,7 @@ and returns the process output as a string.\"\n   (let ((buffer (get-buffer-create \"*git-commit*\"))\n         (merge-heads (git-get-merge-heads))\n         (dir default-directory)\n+        (coding-system (git-get-commits-coding-system))\n         (sign-off git-append-signed-off-by))\n     (with-current-buffer buffer\n       (when (eq 0 (buffer-size))\n@@ -912,6 +923,7 @@ and returns the process output as a string.\"\n                                (git-get-committer-name) (git-get-committer-email)))))))\n     (log-edit #'git-do-commit nil #'git-log-edit-files buffer)\n     (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))\n+    (setq buffer-file-coding-system coding-system)\n     (re-search-forward (regexp-quote (concat git-log-msg-separator \"\\n\")) nil t)))\n \n (defun git-find-file ()\n-- \n1.5.0.2.231.g02e3\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}