I want to post process the output of git log
and have been playing with the --pretty
settings. When I e.g. do
--pretty=format:'{"sha":"%h","message":"%B","author":"%aN <%aE>","commit":"%cE","date":"%cD"}
I get some JSON-like output; when I put in a {
or }
or even a "
into the commit message this messes up my output.
Is there a way to tell git log
to escape those chars e.g. by prepending a \
?
There are two similar questions Git log output to XML, JSON or YAML and Git log output preferably as XML, but they both do not address the escaping of the special chars (e.g. if in the XML case I put <foo>
in my commit message, the resulting XML will be broken).