git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git with Lader logic

From
Martin Pettersson <martin@siamect.com>
Date
Mar 27, 2015, 16:32 UTC
Message-ID
<loom.20150327T170836-560@post.gmane.org>
In-Reply-To
<xmqqegoawiu0.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster <at> pobox.com> writes:
Show 45 quoted lines
> 
> Martin Pettersson <martin <at> siamect.com> writes:
> 
> > I use Git for versioning PLC program written for Beckhoff TwinCAT v2 that 
> > saves the files in binary format.  
> > You can probably do the same for most other systems as well.   
> >   
> > My way of doing it is... 
> > I have a batch file that starts TwinCAT including a file that tell Twincat to
> > open my PLC program and export it into a text based format. 
> > After that the script opens git gui and gitk.  
> >   
> > I have one script like this for each plc program. 
> > It is quite effcient, the whole procedure only takes a double click and 
> > less than 10 seconds and you have git gui up and you can see your 
> > changes in pure text, commit and push.   
> > I commit both the exported text files and the binary  because the binary
> > is the one I edit.   
> > This has been working very well for many years....
> 
> Let me check if I got your scheme correctly.
> 
>  - You need to track PLC program files, whose native format is
>    binary and is not very amenable to textual processing like diff
>    and merge
> 
>  - But you can tell TwinCat to export that binary file to text (and
>    presumably you can tell TwinCat to read that exported text file),
>    and the text format is human-readable.
> 
>  - You use a script that calls TwinCat to export the binary into
>    text as a clean filter, and what is checked into Git is the
>    exported text representation.
> 
>  - You use another script that calls TwinCat to convert the exported
>    text back to the binary as a smudge filter, and what is checked
>    out to the working tree is the native binary format file.
> 
> Is that what is going on?  I can imagine how that arrangement would
> work (after all, that is how clean/smudge filters are designed to be
> used).
> 
> Thanks.
> 
> 

Well you got it right, but I "almost" never convert the exported textfiles back into TwinCat.

The exported textfiles is not really suitable
for merging as they have a proprietary format, 
but they are human readable and it helps a lot 
to be able to see what changes I made at a certain commit.  
  
I do commit both the exported text files and the original binary files.
Recreating the binary by imprting the textfiles can be done.
I just don't do it because it is easier to commit the binary at 
the same time when I commit the exported text files. 
That way I can just checkout any version and rebuild the project 
and  reload it in the machine. 

My script is just a batch file that I double click on. It is not using any of the hooks that git comes with.

Here is an example, I hope it keeps the formatting  (windows batch file):

Set WorkingFolder="C:\Documents and Settings\Me\projectname\Beckhoff" Set CommandFile="do_.cmd" Set TwinCatFile="plc_program_name.prx" Set ExportFile="exports\intermediate_plate.exp" Set ExportFolder="exports\modules"

cd %WorkingFolder%

echo project expmul %ExportFolder% > %CommandFile% echo project export %ExportFile% >> %CommandFile% echo file quit >> %CommandFile%

del /f /q %ExportFile% del /f /q %ExportFolder%\*.* C:\TwinCAT\Plc\TCatPlcCtrl.exe %TwinCatFile% /cmd %CommandFile% del /f %CommandFile%

call git gui & call gitk --all &

Take care Martin

Previous: Junio C Hamano
Message 10 of 10 in “Git with Lader logic”
  1. Bharat SuvarnaMar 17, 2015
  2. Kevin DMar 18, 2015
  3. Randall S. BeckerMar 18, 2015
  4. Doug KellyMar 18, 2015
  5. Randall S. BeckerMar 18, 2015
  6. Bharat SuvarnaMar 19, 2015
  7. Kevin DMar 19, 2015
  8. Martin PetterssonMar 27, 2015
  9. Junio C HamanoMar 27, 2015
  10. Martin PetterssonMar 27, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.