Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Git 2.37 Brings Built-in File Monitor, Improved Pruning, and More

Git 2.37 Brings Built-in File Monitor, Improved Pruning, and More

Git 2.37 brings many new and improved features, including a built-in file system monitor on Windows and macOS, better unreachable objects management, improved external diff, faster git add, and more.

Git's new built-in file monitor aims to improve performance when accessing the file system to detect file changes. This may reduce the time required to execute git status and other commands. Git has supported the possibility of hooking tools like Watchman since version 2.16. This option was not easy to configure, though, and not frequently used. Instead, you can now enable the built-in file monitor by using the following configuration option:

git config core.fsmonitor true

According to 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 OS-native features, i.e. FSEvents on macOS and ReadDirectoryChangesW on Windows. A Linux backend would probably use either inotify or fanotify, Hostetler says, but that work has not started yet.

To improve pruning performance, git 2.37 introduces cruft packs, aimed at reducing the chance of data races when removing unreachable objects.

Unreachable objects aren’t removed immediately, since doing so could race with an incoming push which may reference an object which is about to be deleted. Instead, those unreachable objects are stored as loose objects and stay that way until they are older than the expiration window, at which point they are removed by git-prune.

Unreachable objects that have not left their grace period tend to accumulate and enlarge .git/objects. This can lead to decreased performance and in extreme cases to inode starvation and performance degradation of the whole system.

Cruft packs eliminate the need to store unreachable objects in loose files and instead consolidate them in a single packfile between successive prune operations along with a timestamp file to track grace periods.

Another improvement in git 2.37 deals with diff temp files. Instead of using loose files, diffs are now generated inside a temporary directory under the same basename, using mks_tempfile_ts. This allows the files to have arbitrary names, each in their own separate directory. The main benefit this brings in is with graphical diff programs, that may display a nicer output.

As mentioned, git 2.37 also includes improved performance for select commands, such as git add -i, which was rewritten in C from Perl and been under testing for a while. The latest git version adopts the new C implementation as a default.

As a final note, many developers will welcome the new git -v and git -h options, which will be interpreted as git --version and git --help respectively. Interestingly, while apparently a no-brainer, this patch still required some discussion.

Git 2.37 includes many more changes than can be covered here, so do not miss the official release note for the full details. Additionally, you can also check out GitHub's and GitKraken's takes on what is most relevant in the new release.

About the Author

Rate this Article