[go: up one dir, main page]

Skip to content

Prevent LFS pushes if some files should be LFS pointers but are not

What

We will already prevent LFS pushes if the pointers are not valid to fix https://gitlab.com/gitlab-org/gitlab-ce/issues/24564, but it will still be possible to have files which match filter=lfs but are not LFS pointers.

We could choose to either prevent this, or could show a warning on such a push.

Why

Users without LFS installed can accidentally commit large files bypassing LFS, which can be problematic. We could add a check to prevent this

@heiko_boettger suggested in https://gitlab.com/gitlab-org/gitlab-ce/issues/24564#note_39460083:

Hi, I hit another variant of an error. If you don't add lfs with pattern "*.png" to .gitattributes, all matching files must be in lfs otherwise git will complain about files not being pointer-files. Even worse the current version of git lfs tries starts to convert the files to lfs which result in a working copy where you have modification directly after checkout. In our case this isn't expected since some script expect that you can always switch to another branch after cloning without having to force the checkout. Would be nice if you could catch that case as well and prevent committing if not all matching files are pointer-files.

@ben.boeckel commented on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13837#note_45650898

anything which has been included with filter=lfs will have transformed into an LFS pointer Not if they didn't have LFS installed/enabled when they created the commit.

How

The challenge would be doing this efficiently. Changes to .gitattributes files, or additions which match a filter in any relevant .gitattributes might need to be checked. See https://gitlab.com/gitlab-org/gitlab-ce/issues/24564 for discussion of such an approach

Edited by James Edwards-Jones