From 6220fada2d87f1a67f465410305f434f8d813d12 Mon Sep 17 00:00:00 2001 From: Dante Catalfamo Date: Tue, 23 Mar 2021 01:25:42 -0400 Subject: create new freecad and git post --- content/posts/WIP-freecad-and-git/index.org | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 content/posts/WIP-freecad-and-git/index.org (limited to 'content/posts/WIP-freecad-and-git') diff --git a/content/posts/WIP-freecad-and-git/index.org b/content/posts/WIP-freecad-and-git/index.org new file mode 100644 index 0000000..7847857 --- /dev/null +++ b/content/posts/WIP-freecad-and-git/index.org @@ -0,0 +1,75 @@ +#+TITLE: Freecad and Git +#+DATE: 2021-03-23T01:23:58-04:00 +#+DRAFT: true +#+DESCRIPTION: +#+TAGS[]: +#+KEYWORDS[]: +#+SLUG: +#+SUMMARY: + +I've been working a lot with [[https://freecadweb.org/][FreeCAD]] recently since I got my 3D +printer, and have run into some issues. + +Between the MacOS version and Linux version of FreeCAD (both 0.19, +maybe different builds?), a project that I've been working on for a +couple days has become broken to the point where I can no longer +edit the sketches, rendering it useless. + +This has led me on a quest to find out how I can manage these files +through version control like =git=. + +It would seem that FreeCAD saves are nothing more than zip files +containing text documents, which should make this rather easy. + +Unfortunately there isn't a standard process to git control a +zipped folder, though I have come across a couple methods which +when used together, result in an adequate solution. + +The main component of this workaround is a great little script +called [[https://bitbucket.org/sippey/zippey/src/master/][zippey]], which allows git to handle and diff zip files in a +way that makes storing them much more efficient. + +The second isn't as much a tool as it is a snippet from a [[https://tante.cc/2010/06/23/managing-zip-based-file-formats-in-git/][blog post]] +about diffing zip files with git. By combining both these methods +we can arrive at a pretty good method of handling FreeCAD save +data. + +The first step is to download the zippy python program. Since I +keep all source repositories under =~/src= in directories based on +the website and user who created them, I'll be cloning it to +=~/src/bitbucket.org/sippey/zippey=. + +Then I configure my =~/.gitconfig= to so that the =diff= and +=filter= settings are how I want them. + +I'll also setup a global git [[https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes][attributes]] file so that I don't need +to set the association with =.FCStd= files in each repo individually. + +I add the following lines to my =~/.gitconfig=. + +#+begin_src conf +[diff "zip"] +textconv = unzip -c -a +[core] + attributesfile = ~/.gitattributes +[filter "zippey"] + smudge = /home/dante/src/bitbucket.org/sippey/zippey/zippey.py d + clean = /home/dante/src/bitbucket.org/sippey/zippey/zippey.py e +#+end_src + +Then I create a =~/.gitattributes= file with the following content. + +#+begin_src conf +,*.FCStd filter=zippey +,*.FCStd diff=zip +#+end_src + +With this =git= should be now be able to effectively diff and store +proper deltas when FreeCAD files are modified. + +Keep in mind you need to redo this process on each computer you +plan on using this with, otherwise the files git produces won't +make any sense. + +Also despite having diffs, these files cannot be merged or rebased, +the use of diffs is just do that =git= can store the file more efficiently. -- cgit v1.2.3