GIT - Cross platform smudge/clean filters?
I'm part of a fairly large organization with developers distributed geographically and using a mix of Windows, OSX, and Linux development environments.
I've asked a previous question that leads me to want to use clean/smudge filters: Mark a file in the GIT repo as temporarily ignored.
But... what's the best way to do cross-platform filter scripts? I'd prefer not to require developers to install extra scripting environments. Are there any best practices around this? Any way to make the filters run on the server side (we use github)?
It depends on what is installed by default.
In our Solaris/Linux/Windows environment, we are using perl scripts, but not one per OS: only one script able to recognize the Os in which it is executed and to run the appropriate code depending on the platform.
That allows to isolate the common function in a platform-independent part of the script, while dealing with the paths and other specific commands in Os-dedicated sub-routines, all in the same script, versioned once.
The key is not to introduce Os-branches, which would make some "meta-data leak": some informations (the Os) which have nothing to do with the data versioned (in branches "test" or "fix" or ...) would coexist in special branches. That is not practical: what is the branch fix you need a special version of those scripts? Would you then make a "fix-Windows" and "fix-Unix" branch just for them, or would you rather simply modify said script in the "fix" branch, commit it and be done with it?
There is an issue if you need to run a smudge/clean script on the server. Smudge/clean should only be used where there is a working folder. You can have different versions of these depending on the platform you are on.
The best way to do this is to have 1 version of a script per platform at most. Some can be reused - say if you have msysgit. Then you will be able to use the same script as you do on linux provided you use the same version of bash.