                 (push "-p" args)
                 (push (match-string 1) args))))
         (setq log-start (point-min)))
-      (setq log-end (point-max)))
+      (setq log-end (point-max))
+      (setq coding-system-for-write buffer-file-coding-system))
     (git-get-string-sha1
      (with-output-to-string
        (with-current-buffer standard-output
-         (let ((coding-system-for-write git-commits-coding-system)
-               (env `(("GIT_AUTHOR_NAME" . ,author-name)
+         (let ((env `(("GIT_AUTHOR_NAME" . ,author-name)
                       ("GIT_AUTHOR_EMAIL" . ,author-email)
                       ("GIT_COMMITTER_NAME" . ,(git-get-committer-name))
                       ("GIT_COMMITTER_EMAIL" . ,(git-get-committer-email)))))

                               (git-get-committer-name) (git-get-committer-email)))))))
    (log-edit #'git-do-commit nil #'git-log-edit-files buffer)
    (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))
    (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t)))

(defun git-find-file ()

  "Call git-commit-tree with buffer as input and return the resulting commit SHA1."
  (let ((author-name (git-get-committer-name))
        (author-email (git-get-committer-email))
        author-date log-start log-end args coding-system-for-write)
    (when head
      (push "-p" args)
      (push head args))
