schdiff via git doesn't show any components

Bug #904633 reported by Peter TB Brett
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
gEDA
Confirmed
Undecided
Alan Somers

Bug Description

When running schdiff on a schematic that doesn't use embedded symbols, gschem reports not being able to find symbols and the resulting difference image does not contain any components. For example, in the gEDA git tree:

  git difftool schdiff 0e506ebd5d5c..11f91c04a33e -- examples/TwoStageAmp/TwoStageAmp.sch

This is because git stores the diff candidate files in /tmp/, away from the project configuration files that set up the component library.

Peter TB Brett (peter-b)
tags: added: utilities
removed: utils
Changed in geda:
status: New → Confirmed
Revision history for this message
John Ottesen (f-johno) wrote :

I hacked around with the schdiff file and found that /tmp was not the real problem. Instead, it turns out that git does not respect the cwd (search for this on the web). It moves it's cwd to the top of the git tree and then opens the schematics form that cwd. The schematics files can be in /tmp.

If you make links to your gafrc and any local symbol directory at the top of the git tree, then it should work. Worked for me.

There might be a better solution using git...

Revision history for this message
Alan Somers (asomers) wrote :

I haven't found any good solutions, but here's another workaround: set TMPDIR to the directory where your schematic is. Then git will put the temporary files in the same place.

export TMPDIR=$PWD/examples/TwoStageAmp; git difftool -x schdiff 0e506ebd5d5c..11f91c04a33e -- examples/TwoStageAmp/TwoStageAmp.sch

Revision history for this message
Abhijit (abhijit86k) wrote :

Found a better solution, I think (?). I used an entry in the .gitattributes, which tells git to diff schematic files (*.sch) using a custom wrapper. The wrapper basically copies the file from the /tmp directory into the working directory, and applies schdiff to it.

Revision history for this message
Alan Somers (asomers) wrote :

So simple! Can you integrate this into the existing schdiff script instead of adding a separate script?

Revision history for this message
Abhijit (abhijit86k) wrote :

Technically there should be no problem. My feeling is that there will be an issue of backward compatibility and ensuring that existing workflows (especially with tools other than git) are not broken.

It might also become an issue for people who *want* to compare schematics in different directories/projects in some instances, and therefore would want the default behaviour to be available.

One way around this might be to tell schdiff to do this or that depending on the number of parameters passed to it. (Git will pass 7, normal calls only 2) but I don't know how reliable this would be. Also, I have no clue how it would affect people using gEDA on windows.

Lastly, I (personally) want git to automatically use the graphical diff when i say <git diff ... -- schematicname.sch> rather than having to specify difftool, so I still need to make an entry in the attributes and config file, so having a wrapper keeps things cleaner IMO.

Revision history for this message
Abhijit (abhijit86k) wrote :

Caveat for my patch: it works only when diff is comparing some old revision with the current file (in the working directory). When comparing two arbitrary revisions, the same old problem returns (symbols not found).
This is because both files reside in /tmp, and my script has no idea where the working directory is.
Any ideas to fix this?

Revision history for this message
Abhijit (abhijit86k) wrote :

Here's a fix for the last caveat I mentioned. I use the "path" provided as the first argument to determine where to copy the files. It should now work for comparing across arbitrary revisions. I've also added a fallback case - in case the directory for the file being compared does not exist (has been deleted, or is in a different revision etc) it falls back to the standard schdiff.

This should work independent of where git generates the temporary files (usually /tmp, but can be changed)
All other config and gitattribute settings same as comment #3

Revision history for this message
Abhijit (abhijit86k) wrote :

Adding the updated script again - forgot some debugging print statements last time around.

Revision history for this message
Jonatan Åkerlind (natanoj) wrote :

I made a modification to Abhijit's nice gschemdiff wrapper which makes it check for the existence of gafrc och gschemrc in each directory in the sub path in the PROJECTDIRECTORY. This fixes my use case where I structure different parts of a larger project under different sub directories all under a common "schem" directory containing the gafrc and gschemrc. This common schem dir is where I start gschem to edit any schematic under any of the sub directories within, i.e. I can share symbols which are placed under a common sym dir within the git repository.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.