https://github.com/git/git/commit/e488b7aba743d23b830d239dcc... Yes:
> we provide a compat version, so it's always available
> we provide a compat version, so it's always available
Furthermore, imagine "src" has 1Mb characters but we only want to copy the first 3 chars. The git implementation would traverse the entire 1Mb to find the length first, but a proper implementation only needs to look at the first 3 chars. So, they banned strncpy and provided a worse solution to that.
[1]: https://github.com/git/git/blob/master/compat/strlcpy.c
snprintf(buf, sizeof(buf), "%s", string);
strlcpy is on track for future standardization in POSIX, for Issue 8, but even as a de facto standard, it exists in libc on *BSD, macOS, Android, Solaris, QNX, and even Linux using musl.https://www.austingroupbugs.net/view.php?id=986#c5050
But you're correct in that it is not a replacement for strncpy because no code should be using strncpy.
I see this `strlcpy` recommanded everywhere.