Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make SVN ADD ignore binaries

Binaries (under Linux) don't have an extension so I cannot exclude them using patterns. Thus when I use SVN add to add a directory I will get something like

$ svn add recursion_vector/
A         recursion_vector
A         recursion_vector/rec_vec.cxx
A         recursion_vector/rec_vec.h
A  (bin)  recursion_vector/rec_vec

Here rec_vec is the executable I would like to exclude. SVN obviously recognizes it as binary. Now can I tell Subversion to ignore all binary files?

like image 684
fuenfundachtzig Avatar asked Feb 03 '10 10:02

fuenfundachtzig


1 Answers

This is a bit verbose because it uses find:

find [TARGET-DIRECTORY] \( -executable -type f \) -prune -o -print | xargs svn add --depth empty

Passing the target-directory to find, find will recurse the directory printing out all the contents except for executable files (\( -executable -type f \) -prune). Without -type f find would also prune directories since these usually have the execute bit or "search bit" set.

The --depth empty option on add tells svn not to itself recurse a file object, since find is handling the recursion.

If you like the result, you can put this in a shell function that would allow you to pass in arguments for [TARGET-DIRECTORY].

Thank you,

Zachary

like image 83
Zach Young Avatar answered Oct 23 '22 15:10

Zach Young