AlDanial / cloc

cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
GNU General Public License v2.0
19.74k stars 1.02k forks source link

Git repositories are not correctly detected #772

Closed stefanobartoletti closed 1 year ago

stefanobartoletti commented 1 year ago

Describe the bug I'm unable to make cloc work correctly when passing the --vcs=git argument, of course when giving it the path of an actual local git repository.

In example, this is what I getas output by running on a specific folder (which is like I said a git repo) without arguments:

> cloc Personali/nuxt-storyblok-starter/
      50 text files.
      44 unique files.                              
      12 files ignored.

github.com/AlDanial/cloc v 1.98  T=0.04 s (1114.6 files/s, 47118.5 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Vuejs Component                 26            141             57           1080
JavaScript                       6             11             46            132
YAML                             4             12              3             95
TypeScript                       2             11              4             69
CSS                              2             16              2             68
JSON                             2              0              0             51
Markdown                         1             15              0             27
TOML                             1              3              1             16
-------------------------------------------------------------------------------
SUM:                            44            209            113           1538
-------------------------------------------------------------------------------

and with --vcs-git argument

> cloc --vcs=git Personali/nuxt-storyblok-starter/
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
       0 text files.
       0 unique files.                              
       0 files ignored.

cloc; OS; OS version

AlDanial commented 1 year ago

The problem was cloc wasn't cd'ing to the given directory so the git commands failed. Give 46655b4 a try.

stefanobartoletti commented 1 year ago

Thanks, the version from that commit seems to work fine.