Skip to content

Running cloc from inside a git repo may fail #699

Description

@olemd

Running cloc from inside a new-ish directory inside a git repo may fail with the somewhat confusing message

fatal: current working directory is untracked
Failed to create tarfile of files from git. at /usr/bin/cloc line 5201.

In my case this was caused by the following:

cd ~/src/git-repo/new_subdir
cloc --json --report=my-report.json --git abc234 ~/src/git-repo

This appears to be caused by cloc running git-archive from inside new_subdir with a git hash that refers to a source tree that doesn't contain new_subdir.

A working workaround is

cd ~/src/git-repo
cloc --json --report=my-report.json --git abc234 ~/src/git-repo

Setting the current working directory to the top of the git-repo before running git-archive in cloc would appear to be a fix for this.

Strictly speaking this is not a cloc bug, it might be considered a git-archive bug, but the result is nevertheless rather confusing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions