cloc

--diff doesn’t appear to compute deltas properly when comparing directories


We are using cloc.pl for analysis purpose. And cloc was proved very useful so far when we were just counting lines of code. But now we are trying to get diff between two branches.

Using the documentation mentioned in the link above, I am trying to get the diff:

    perl cloc.pl --diff branch-1.0/ExampleClass.java branch-2.0/ExampleClass.java

This produces perfect result for a single file and reports modified lines correctly. The same is true for other values like removed, added and so on.

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Java
 same                            0              0            209            294
 modified                        1              0            170             12
 added                           0              0            647              1
 removed                         0              5             64             46
-------------------------------------------------------------------------------
SUM:
 same                            0              0            209            294
 modified                        1              0            170             12
 added                           0              0            647              1
 removed                         0              5             64             46
-------------------------------------------------------------------------------

But now when I’m trying to accomplish same result for complete branch, i.e., all the files under folder, by issuing something like this:

   perl cloc.pl --diff branch-1.0\ branch-2.0\

Now comes the problem.

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Java
same                            0              0              0              0
modified                        0              0              0              0
added                           0            110           2408            789
removed                         1             32            443            352
-------------------------------------------------------------------------------
SUM:
same                            0              0              0              0
modified                        0              0              0              0
added                           0            110           2408            789
removed                         1             32            443            352
-------------------------------------------------------------------------------

As you can see that when I am trying to issue the command at folder level, all modified number of comments shows 0. All we have is added or removed lines of code or files.

Not sure if I am missing something silly or any issue with cloc tool. I am using version 1.56.


Solution

  • This issue got resolved version 1.6. Which helped me to move ahead. Apparently its a bug with version 1.56. Also I moved to use prebuilt "cloc-1.6.exe"

    Another thing I found in this regard is one can find more help/support related blog/discussion on http://sourceforge.net/p/cloc/bugs/ which actually helped in my case.