LoginSignup
1
1

More than 5 years have passed since last update.

Msys2 で導入した git で NTEmacs の magit が動かない問題をどうにかしてみる

Last updated at Posted at 2015-09-15

Magit version 20151019.443 現在、シンボリックリンク以外の問題は修正されている模様

先日、Msys2 の git が version 2.5.1 にアップデートされて以降、NTEmacs で magit (https://github.com/magit/magit) が動かなくなってしまったので、どうにか動くようにしてみた。

以下の環境で検証

  • Windows 7、NTEmacs 24.5.1、msys/git 2.5.1、magit melpa の最新版
  • NTEmacs と msys/bash は連携済み

init.el あたりに以下の advice を設定するといいらしい
注) NTEmacs 24.3 以前を使用している場合 新 advice は動作しないので 旧 advice に書き直しが必要。

init.el
;; read repository する際, シンボリックリンクが含まれると
;; うまく読み込めない問題を修正
(defun ad-magit-read-repository (orig-fun &rest args)
  (let ((ret_val (apply orig-fun args)))
    (if (file-directory-p ret_val) (file-truename ret_val))))
(advice-add 'magit-read-repository :around 'ad-magit-read-repository)

;; Magit version 20150925.821 現在 以下の問題は修正された模様
;; process-file で実行するコマンド中に quote されていない "{" "}" が
;; 含まれていると, それが勝手に削除されて,エラーになる問題を修正
;;(defun ad-magit-process-git-arguments (orig-fun &rest args)
;;  (mapcar (lambda (x) (replace-regexp-in-string "\\^\\({.*}\\)" "^'\\1'" x))
;;   (apply orig-fun args)))
;;(advice-add 'magit-process-git-arguments :around 'ad-magit-process-git-arguments)

;; Magit version 20151019.443 現在 以下の問題は修正された模様
;; "git --rev-parse --show-toplevel" で出力される
;; パスが unix 形式のため, NTEmacs で読み込めない問題を修正
;; (defun ad-magit-git-string (orig-fun &rest args)
;;  (if (and (string= (nth 1 args) "--show-toplevel") ret_val)
;;      (with-temp-buffer
;;        (call-process "cygpath" nil '(t nil) nil "-am" (apply orig-fun args)
;;        (unless (bobp)
;;          (goto-char (point-min))
;;          (buffer-substring-no-properties (point) (line-end-position))))
;;    (apply orig-fun args))))
;;(advice-add 'magit-git-str :around 'ad-magit-git-string)
;;(advice-add 'magit-git-string :around 'ad-magit-git-string)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1