Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 9 hours, 8 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Making OM more git friendly

Author 3 Subscribed Users |
Profile photo of Sahin Kureta
Sahin Kureta

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.

November 9, 2016 at 15:48 #19636
Profile photo of anders
anders

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.

November 14, 2016 at 17:22 #19700
Profile photo of Sahin Kureta
Sahin Kureta

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?

November 14, 2016 at 17:58 #19702
Profile photo of Sahin Kureta
Sahin Kureta

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.

November 14, 2016 at 18:53 #19703
Profile photo of anders
anders

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.

November 15, 2016 at 10:15 #19714
Profile photo of anders
anders

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

November 15, 2016 at 10:17 #19715
Profile photo of Sahin Kureta
Sahin Kureta

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.

November 15, 2016 at 11:56 #19733
Profile photo of Sahin Kureta
Sahin Kureta

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

November 15, 2016 at 14:59 #19758
Profile photo of Sahin Kureta
Sahin Kureta

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.

November 15, 2016 at 18:41 #19773
Profile photo of Jean
Jean

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..

November 16, 2016 at 22:11 #19840
Profile photo of Sahin Kureta
Sahin Kureta

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.

November 26, 2016 at 13:56 #19927

You must be logged in to reply to this topic.

Log in now