The logic for enabling BAM should consider *.min.js files


#1

Currently, BAM files are either selected manually when the file is initially checked in bk new -b FILE (man ). Or they are selected automatically when a file is larger than the size of the BAM config (64k by default) and contains nulls which can’t be represented in the bk weave.

For minified javascript files (like bootstrap.min.js) this results in use putting a file where the entire file is saved on a single line of the weave.

The change I have in mind is that in slib.c:binaryCheck() in addition to looking for nulls we also look at the average line size. (size / newlines). If a file is larger than the currently configured min BAM file size and the average line size is like 2k or more then we switch to considering the file as a binary.

It would be a fairly small change to just that file.


#2

You could also just check if there is just one line in the file. I’m a bit concerned about average line size because if you have a very large file with one very large line it might get bamified even thou diff would’ve still been useful. Diff with just one line is pretty much useless 100% of the time :wink:


#3

I considered that, but these searching around I found that many of these files have 3 or 4 lines because they include some headers and version information.

The thinking is that no normal file that is bigger than a couple kilobytes is going to have an average line size of 4k bytes. If your file was had just a single long line and then a bunch of normal looking code that line would have to be 90% of the file size to meet this critera.