Git 2.37 brings built-in file monitor, improved pruning, etc.

Cottage 2.37 brings many new and improved features, including a built-in filesystem monitor on Windows and macOS, better handling of inaccessible objects, improved, faster external diff git addand more.

Git’s new built-in file monitor aims to improve performance when accessing the file system to detect file changes. This can reduce the time it takes to run git status and other commands. Git supported the ability to hook tools like Watchman since version 2.16. However, this option was not easy to configure and was not frequently used. Instead, you can now enable the built-in file monitor using the following configuration option:

git config core.fsmonitor true

According for Jeff Hostetler, the author of the patches for git’s new file monitor, the implementation relies mostly on cross-platform code with custom backends leveraging native OS features, i.e. FSEvents on macOS and ReadDirectoryChangesW on Windows. A Linux backend would probably use either inotify Where fanotifysaid Hostetler, but that work has not yet begun.

To improve pruning performance, git 2.37 introduces raw packsaimed at reducing the risk of data breaches when deleting inaccessible objects.

Inaccessible objects are not deleted immediately, as this could result in an incoming push that may refer to an object that is about to be deleted. Instead, these inaccessible objects are stored as free objects and remain so until they are older than the expiration window, at which time they are deleted by git-prune.

Inaccessible items that have not left their grace period tend to accumulate and grow in size .git/objects. This can lead to decreased performance and, in extreme cases, inode starvation and overall system performance degradation.

Raw packets eliminate the need to store inaccessible objects in bulk files and instead consolidate them into a single packfile between successive pruning operations with a timestamp file to track grace periods.

Another improvement in git 2.37 concerns temporary diff files. Instead of using bulk files, diffs are now generated in a temporary directory under the same base name, using mks_tempfile_ts. This allows files to have arbitrary names, each in its own separate directory. The main benefit this brings is with graph comparison programs, which can show nicer output.

As mentioned, git 2.37 also includes performance improvements for select commands, such as git add -i, which was rewritten in C from Perl and tested for some time. The latest version of git adopts the new C implementation by default.

Finally, many developers will welcome the new git -v and git -h options, which will be interpreted as git --version and git --help respectively. Interestingly, although seemingly a no-brainer, this patch is still needed some talk.

Git 2.37 includes many more changes than can be covered here, so be sure to check out the official release note for all the details. Additionally, you can also check out from GitHub and by GitKraken takes what is most relevant in the new version.