I'd like to run a function before magit runs git, and another one after magit runs git. I see magit-pre-start-git-hook
but I don't see any post-finish-git hook. How can I run commands before and after magit runs git?
1 Answer
Magit runs git a lot. Doing something every time that happens probably isn't a good idea. What do you want to accomplish?
That being said you can make Magit do something before running git
by advising all or some of the functions that run git
. I strongly recommend you only advice some of these functions or even just the commands that you actually want to do something before running git
. I cannot tell you which functions you have to advice because you didn't say what you want to accomplish.
To find all functions that run git
grep for magit-git-executable
.
before
advice formagit-process-finish
(and to submit a feature request). Note alsomagit-pre-call-git-hook
for synchronous calls. Be careful though -- the "pre" hook for the async case has no process object, and async processes might not finish in the order you started them.git
a lot. Doing something every time that happens probably isn't a good idea. What do you want to accomplish?