magit over tramp:重新使用 ssh 连接

magit over tramp: re-use ssh connection

magit 似乎为每个命令打开一个新的 ssh 连接。这变得非常烦人,尤其是在暂存更多块时,这需要花费大量时间来为每个块建立连接。

(来自 shell,我通过 ./ssh/config 启用了持久的 ssh 连接)

我不确定这是魔术还是流浪汉。

但我的问题是:

如何让 magit 重新使用 ssh 连接?

编辑:

客户是

    (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
    (setq tramp-default-method "ssh")
    (setq tramp-inline-compress-start-size 1000000)
  ## generally re-use existing connections
  Host *
      ControlMaster auto
      ControlPath ~/.ssh/sockets/%r@%h-%p
      ControlPersist 600

  Host myhost1
       HostName 111.11.11.1
       User myuser
       ForwardX11 yes
       ForwardX11Timeout 596h
       IdentityFile ~/.ssh/id_rsa
       IdentitiesOnly yes
       ForwardAgent yes
       SendEnv LC_*
       ServerAliveInterval 300

服务器为RHEL 7.6(麦婆)

默认情况下,Tramp 不使用 SSH 配置文件 (see the Tramp FAQ) 中定义的 ControlMaster 选项:

Tramp overwrites ControlPath settings when initiating ssh sessions. Tramp does this to fend off a stall if a master session opened outside the Emacs session is no longer open.

FAQ 还展示了如何为 TRAMP 配置 ControlMaster 选项:

(customize-set-variable
 'tramp-ssh-controlmaster-options
 (concat
   "-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
   "-o ControlMaster=auto -o ControlPersist=yes"))

或者,如果您想告诉 Tramp 使用您的 ~/.ssh/config 文件中的定制,您需要更改 tramp-use-ssh-controlmaster-options 变量:

(customize-set-variable 'tramp-use-ssh-controlmaster-options nil)