I would like to create a patch (git diff) with custom name -- e.g., hello-world.diff. Emacs doesn't seem to be able to handle git diff > hello-world.diff
, perhaps because of the greater-than sign that works in regular terminals.
I have tried using start-process
, but it fails:
(defun create-diff-patch ()
(interactive)
(let ((name-of-patch
(read-string "Name of Patch: " nil nil "patch.diff" nil)))
(start-process "process-name" "*output-buffer*"
"git" "diff" ">" name-of-patch)))
Here is the error message:
fatal: ambiguous argument '>': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Process process-name exited abnormally with code 128
The following two examples create automatic names, but I'd like to use my own name instead:
(apply #'magit-call-git
(magit-process-quote-arguments '("format-patch" "-1" "SHA1")))
(apply #'magit-call-git
(magit-process-quote-arguments '("format-patch" "HEAD~~")))
>
isn't an argument to the program, it's a shell's command. What you could've done instead is to collect program's output into a buffer and then write-region that buffer to whatever file you want./bin/sh
.