gpt4 book ai didi

emacs - 如何同步运行magit

转载 作者:行者123 更新时间:2023-12-02 22:38:11 25 4
gpt4 key购买 nike

(let ((default-directory "/home/vision/"))
(magit-pull)
(magit-fetch "upstream")
(magit-merge "upstream/master")
(magit-push))

我得到:

Running git fetch upstream
Git is already running

如何等待获取完成?

最佳答案

Magit 旨在作为 git 的交互式前端,所以像 magit-fetch 这样的东西并不是真的要从你的代码中运行......但是如果你真的坚持,快速浏览一下代码向您展示了 magit-process 是一个变量,它在进程运行时保存它,并在它完成时被清除。因此,您可以将它与等待直到发生的循环一起使用:

(progn
(magit-fetch "upstream")
(while magit-process (sleep-for 0.25))
(magit-fetch "upstream"))

但这确实插入了它——例如,当获取失败时会发生什么?

顺便说一句,您可以做的另一件事是查看源代码,它是 magit-fetch 案例中的单行函数:

(apply 'magit-run-git-async "fetch" remote magit-custom-options)

并编写使用非异步版本的代码:

(progn
(apply 'magit-run-git "fetch" "upstream" magit-custom-options)
(apply 'magit-run-git "fetch" "upstream" magit-custom-options))

(并且您可以建议一个补丁来添加一个可选的标志参数,但这对于交互式工具来说似乎是一个不确定的功能......)

关于emacs - 如何同步运行magit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11131749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com