< Back to IRCAM Forum

Making OM more git friendly

Hi,

Is it possible to make OM more git friendly? Currently all files in OM workspace are single line files. This makes it impossible to see what changed in diffs. Some of them also include a timestamp of last saved date, so even if you don’t change anything those files are seen as completely changed by git diff. Currently I make a copy of my workspace and number it but after a while it becomes difficult to keep track of which workspace has which feature. Also sometimes I am forced to invent something twice, because sometimes later in the project a previous approach seems more suitable and by the time I have realized that it has already disappeared among backups, copies of my workspaces.

Hi Sahin. Sorry for the late reply.

Patches are saved using the standard lisp i/o (write, prin*), so a quick fix is to (setf print-pretty t) before saving. Depending on your patches this will increase sizes by a factor of 4-6. This could be optimized more. Perhaps this should be made configurable…

Vs. time stamp, they won’t get updated unless you save your patch. I don’t think it’s a good idea to rid OM of these. Better perhaps to set up a filter to isolate these in your vc of choice.

Thanks for the reply. Can I set that as a global preference? Else, if I set that at the beginning of my session will it save all my patches pretty-printed? And finally, what purpose those timestamps serve?

By the way, (setf print-pretty t) destroys my omp files. It prettifies the commented out OM File Header and External resources lines, this results in a broken file.

Right, the header-comments are broken across lines using the pretty-printer.

There might be further flaws as well using print-pretty, in particular print-object gets bypassed, this will need a bit more look into.

What about “git diff --word-diff” with a suitable regex?

Turns out automatically formatting lisp code like that is not trivial. Thakfully there is an Emacs package called semantic-refactor. Using that, my solution for now is this:

  1. open the .omp file in emacs
  2. insert newline before (load-lib-for
  3. insert newline before (setf
  4. run srefactor-lisp-format-sexp command at (setf
  5. save and exit

If I can find a way to script emacs and make this action into a bash script or something like that then I can add this as a git hook and all my problems would be solved.

But I still wonder what you do with the timestamp in the header.

The OS already provides “created” and “last modified” dates.

I have written the Emacs script. It reformats the omp files, leaving out commented header lines. However, OM changes lots of things all around inside the files, even when they are not modified at all. So it seems like git and OM are not reconcilable for now.

Hi there. Yes OM file format is not really git friendly unfortunately (will probably be in a not-so-close-future)
In principle however, no much should be changed if the patch is not modified. The save process is pretty deterministic…

Maybe it is due to semantic-refactor but lots of things change on save, even if I don’t modify anything. I guess I won’t be able to use git. I hope SCM will be taken into consideration when developing newer versions of OM. Thanks for your help.