Skip to content

How large files are kept

How large files work underneath.

  • A large file is stored the way Git LFS stores it, and .gitattributes says which files are large, with filter=lfs. The line Saturn writes is filter=lfs diff=lfs merge=lfs -text, for *.ending when no other file in git has that ending, and for /the/file itself when one has.
  • Git reads a file it already holds whole as changed from the moment a line starts to cover it, without the file being touched. A line that took in such files would make every one of them a change of whichever work saved next in a new folder, and that work would hold them all. That is why the line names one file where others share its ending. A file that ends up whole under a line anyway, because it was saved with plain git or shipped while the line was on its way, is moved over by the next save that sees it.
  • The first time Saturn writes to .gitattributes, it adds /.gitattributes merge=union, so that two people who each add a line get both lines, not a clash.
  • Once a project has large files, every git command is given the filter.lfs.* settings that git lfs install would write. They are not written anywhere, and they are only given where the git-lfs program is found.
  • The git-lfs program puts four hooks of its own in the project’s .git folder the first time it handles a file there. Three of them make every file marked lockable read-only after a commit, a merge or a switch, unless it is locked with Git LFS’s own locks, which Saturn does not use. So Saturn’s line for a large file does not say lockable, and every git command Saturn runs is given lfs.setlockablereadonly=false. The fourth sends content before each push. Saturn runs git with GIT_LFS_SKIP_PUSH=1, which has that hook stand down, and sends the content itself.
  • Every git command is also run with merge.lfs.driver set to a command that fails. Git would otherwise combine two versions of a pointer as text and leave marker lines in it. This way it stops with both versions whole, as it does for any binary file.
  • Git is told not to fetch a file’s content while it checks files out (git-lfs filter-process --skip), so no merge can fail halfway through on a download. It writes the pointers. Afterwards Saturn fetches what the computer lacks, with git lfs fetch for the commit the folder is at, and copies each file’s content from .git/lfs/objects over its pointer. The copy shares its bytes with the original on disks that can do that.
  • While git lfs fetch runs, Saturn says how far it has got by looking at the disk four times a second: the content it is waiting for that is whole in .git/lfs/objects, and the parts of files still arriving in .git/lfs/incomplete, which Git LFS names by their ids. Saturn knows every id and size it asked for, so the figure is in bytes and needs nothing from Git LFS, which counts files and says little away from a terminal. An upload has no such place to look, so git lfs push is run with GIT_LFS_FORCE_PROGRESS=1 and what it prints is read: files done, and bytes sent, rounded as it rounds them.
  • Before a branch is pushed, and before a ship is, git lfs push sends the content its commits name. If that fails, nothing is pushed.