Skip to content

check-added-large-files regression when using git worktree #777

Closed
@skyj

Description

@skyj

Hello,

After upgrading from v3.4.0 to v4.2.0, the check-added-large-files hook is now failing when used inside a worktree:

check for added large files............................................................Failed
- hook id: check-added-large-files
- exit code: 1

fatal: '/home/.../main-repo/.git/worktrees/worktree-repo/COMMIT_EDITMSG' is outside repository at '/home/.../worktree-repo'
Traceback (most recent call last):
  File "/home/.../.cache/pre-commit/repo_kdm5un1/py_env-python3.10/bin/check-added-large-files", line 8, in <module>
    sys.exit(main())
  File "/home/.../.cache/pre-commit/repo_kdm5un1/py_env-python3.10/lib/python3.10/site-packages/pre_commit_hooks/check_added_large_files.py", line 73, in main
    return find_large_added_files(
  File "/home/.../.cache/pre-commit/repo_kdm5un1/py_env-python3.10/lib/python3.10/site-packages/pre_commit_hooks/check_added_large_files.py", line 43, in find_large_added_files
    filter_lfs_files(filenames_filtered)
  File "/home/.../.cache/pre-commit/repo_kdm5un1/py_env-python3.10/lib/python3.10/site-packages/pre_commit_hooks/check_added_large_files.py", line 18, in filter_lfs_files
    check_attr = subprocess.run(
  File "/home/.../.asdf/installs/python/3.10.4/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('git', 'check-attr', 'filter', '-z', '--stdin')' returned non-zero exit status 128.

I believe the regression comes from 03a65ca

Activity

asottile

asottile commented on Jun 6, 2022

@asottile
Member

can you try the patch in #778 -- you can use rev to select that commit and see if it works!

skyj

skyj commented on Jun 7, 2022

@skyj
Author

Works fine, thank you 🙏

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @asottile@skyj

      Issue actions

        check-added-large-files regression when using git worktree · Issue #777 · pre-commit/pre-commit-hooks