Staging a file skips Git filter "clean" actions?

I have a Git filter set to do some tidy actions on XML files upon "clean" (meaning when added to the staged list of files to commit). If I do a "git add myfile.xml" from the command line, the "clean" filter fires, and the file that is staged is the tidied version. However, if I stage the file via Sourcetree's UI (in a "split view staging" mode), the file gets added to the staging area without being passed through the "clean" filter's setting.

How can I  get the git smudge/clean filters to fire when staging/checking out through the Sourcetree UI?

1 answer

0 votes
Mikael Sandberg Community Champion Nov 16, 2017

Is the file used for the filter in a directory that is in your PATH variable?

You mean the script that runs as part of the "clean" filter? The "clean" filter I have currently set to "./myscript.sh", and the script file is in the root folder of the repo itself. 

I tried changing the clean filter to "/absolute/path/to/my/repo/myscript.sh", but the same symptom remains; works when doing "git add" from the command line, but not when staging within SourceTree.

Mikael Sandberg Community Champion Nov 16, 2017

Have a look at SRCTREE-3583. Sourcetree is most likely not picking up your script because it is launched as a service and will not pick up your changes to the PATH. You need to extend the PATH that your apps see, checkout http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite (mentioned in the issue) or search on how to extend PATH in OS X.

But if this were PATH-related, wouldn't setting the "clean" filter to the absolute path to the script succeed? I did that and it still fails to do the filter through SourceTree.

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

259 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot