UseLibGit2 Setting

90 views
Skip to first unread message

Tom Huibregtse

unread,
Jan 18, 2021, 5:39:47 PM1/18/21
to tortoisegit-users
Hello,

We are managing a git repository that uses UTF-16-LE-BOM files with extension .uni. It is critical for us to be able to use git's working-tree-encoding feature for these files. My understanding is that this feature works in git version v2.21.0 at the earliest. Unfortunately, this feature is not in libgit2, so we need to disable libgit2.

I was under the impression that by setting TortoiseGit's "UseLibGit2" setting to false that we would fall back to using the git.exe that is installed on the Windows system external to TortoiseGit. However, after looking at the release notes and then cloning and looking through the source, it looks like TortoiseGit maintains its own version of git as a submodule, calling it "libgit" in the release notes.

When setting "UseLibGit2" to "false", does TortoiseGit use its own internal version of git.exe, or does it fall back to using what is installed on the system?


Thank you,
Tom

Sven Strickroth

unread,
Jan 20, 2021, 2:35:21 PM1/20/21
to tortoise...@googlegroups.com, Tom Huibregtse
Hi Tom,

TortoiseGit uses (self-compiled, partly integrated) libgit, libgit2 and
git.exe. We try to keep all dependencies as up2date as possible.

Disabling libgit2 makes TortoiseGit, depending on the specific function,
fall back to libgit (sometimes referred to as gitdll in TortoiseGit;
only used for very specific functions for performance reasons so that we
don't need to fork lots of git.exe processes; e.g. for diffing
commits/files for the log dialog) or git.exe.

I suppose for your use case you could disable libgit2, but you could
also just try to disable specific libgit2 calls that might be dangerous
in your scenario (using libgit2_mask): I suppose leaving out GIT_CMD_ADD
should be sufficient (cf.
<https://gitlab.com/tortoisegit/tortoisegit/-/blob/32f7cbfe27a15159c01fc6771de15fe23ecdc52f/src/Git/Git.cpp#L220-222>
and
<https://gitlab.com/tortoisegit/tortoisegit/-/blob/32f7cbfe27a15159c01fc6771de15fe23ecdc52f/src/Git/Git.h#L33>).
maybe you also need to disable the usage of libgit (we use that for
updating the index when refreshing the commit dialog).

I hope this helps.

Best,
Sven

PS: Please open an issue in the libgit2 issue tracker, so that they
priorize implementing working_tree_encoding (cf.
<https://github.com/libgit2/libgit2/issues>).

Am 18.01.2021 um 23:39 schrieb Tom Huibregtse:
> Hello,
>
> We are managing a git repository that uses UTF-16-LE-BOM files with
> extension .uni. It is critical for us to be able to use git's
> working-tree-encoding
> <https://git-scm.com/docs/gitattributes#_working_tree_encoding> feature
> for these files. My understanding is that this feature works in git
> version v2.21.0 at the earliest. Unfortunately, this feature is not in
> libgit2, so we need to disable libgit2.
>
> I was under the impression that by setting TortoiseGit's "UseLibGit2"
> setting to false that we would fall back to using the git.exe that is
> installed on the Windows system external to TortoiseGit. However, after
> looking at the release notes
> <https://tortoisegit.org/docs/releasenotes/> and then cloning and

Tom Huibregtse

unread,
Jan 20, 2021, 3:18:50 PM1/20/21
to tortoisegit-users
Hi Sven,

Thank you for your time. I haven't found any documentation about why libgit2 is preferred, so I suggested that we just set UseLibGit2 to false. I think that you've partially answered it. With libgit2 preferred, fewer git.exe process forks are created in the cases where git.exe is the fallback and not libgit. I was unaware of libit2_mask though.

I've linked this conversation to an existing libgit2 issue here: https://github.com/libgit2/libgit2/issues/5332


Thank you,
Tom

Sven Strickroth

unread,
Jan 21, 2021, 4:39:24 AM1/21/21
to Tom Huibregtse, tortoisegit-users
Hi Tom,

Am 20.01.2021 um 21:18 schrieb Tom Huibregtse:
> Thank you for your time. I haven't found any documentation about why
> libgit2 is preferred

For performance reasons. However, as libgit2 is rather new, not all
functions are implemented and we always try to have a fallback and a
kill-switch (global UseLibgit2 and more fine-grained libgit2_mask).
libgit (on which Git.exe is based) is not developed with thread-safety
and linking from other tools as a goal. Therefore, we use it where
necessary and possible (e.g., to get config values, get the log, diff
commits, refreshing the index or checking whether a file is ignored).
The goal is to move away from using libgit.

A special case is GitWCRev that exclusively uses libgit2 as this is
intended to be used in other multi-threaded tools.

> I've linked this conversation to an existing libgit2 issue
> here: https://github.com/libgit2/libgit2/issues/5332

Thanks! Please a a Thumbs up to the libgit2 issue.

Sven

Reply all
Reply to author
Forward
0 new messages