cgag / loc

Count lines of code quickly.
MIT License
2.31k stars 126 forks source link

Git files include in lines of count #18

Closed mandeep closed 7 years ago

mandeep commented 7 years ago

First, I want to say that I'm really impressed with the speed of loc! Now on to the issue:

I noticed that when I run "loc ." in the project root that the directory's git directory is included in the results. I propose either disabling git directories or disabling hidden directories from the results. Thoughts?

defnull commented 7 years ago

It detects refs/remotes/origin/master as ASP.NET which is quite unexpected :)

cgag commented 7 years ago

Looks like "master" is an ASP.NET extension, and so is sitemap? Strange. When there's no extensions I just pretend the filename is an extension, which handles "Makefile" nicely. Not working out so cleanly in this case. Maybe I'll only do that in case of makefiles and just treat anything else without an extension as unrecognized? I'll have to think about it more.

defnull commented 7 years ago

I would simply add a flag to include 'hidden' files and folders (starting with a dot) and exclude them by default.

cgag commented 7 years ago

Fair point, the problem generalizes to any file without an extension, but .git/ is probably the biggest offender.

pvdb commented 7 years ago

Not an issue for pvdb/gloc :wink:

dwijnand commented 7 years ago

Here's a workaround, invoke it like this: loc $(git ls-files)

cgag commented 7 years ago

@mandeep @defnull: switched to using the same ignore crate and flags ripgrep uses (https://github.com/cgag/loc/commit/c8b20c9ec58d92026171f883ae103023d4298609)

-u to stop using .gitignore, -uu to also include hidden files/dirs.