Skip to content

Conversation

@chrisd8088
Copy link
Member

@chrisd8088 chrisd8088 commented May 5, 2025

This PR removes the CloneFile() stub function defined in our lfs package for non-Linux operating systems, as it is entirely unused.

With this change, we remove the last use of a cgo Go build constraint from our code base.

Background

This CloneFile() stub function is a remnant of the original support for Git LFS object file deduplication added in PR #952, at which time we only implemented this function for Linux systems with Btrfs filesystems, so we defined two versions of the new CloneFile() function in our lfs package, one for Linux, and one for all other types of systems.

The only caller of the CloneFile() function at the time was the CopyWithCallback() function. When that was moved into our tools package in PR #1265, the two implementations of CloneFile() function were also copied to the tools package at the same time, in commit 1ef2d43.

However, while the Linux version was completely moved to the tools package by renaming the lfs/util_linux.go source file to tools/util_linux.go, the generic version was only copied to a new tools/util_generic.go source file, leaving the original lfs/util_generic.go in place.

As the lfs/util_generic.go source file and the CloneFile() function it defines within the lfs package are no longer used, we can simply delete them now.

We added initial support for the deduplication of Git LFS object files
between the Git working tree and our internal Git LFS storage directories
in commit ea16fd5 of PR git-lfs#952, using
the copy-on-write reflink functionality provided by the Linux Btrfs
filesystem.

Since we didn't implement equivalent capabilities for any other operating
systems, we defined two versions of a new CloneFile() function in our
"lfs" package, one for Linux, and one for all other types of systems.

Later, in commit 1ef2d43 of PR git-lfs#1265,
we moved the CopyWithCallback() function from our "lfs" package into our
"tools" package, so it would be more widely available for use in our
code base.  In that same PR, for instance, the function was first used
outside of the "lfs" package, in the download() method of what is now
the basicDownloadAdapter in our "tq" package.

Because the only caller of the CloneFile() function at the time was the
CopyWithCallback() function, both versions of the function were copied
to the "tools" package in commit 1ef2d43.

However, while the Linux version was completely moved to the "tools"
package by renaming the lfs/util_linux.go source file, the generic
version was only copied to a new tools/util_generic.go source file,
leaving the original lfs/util_generic.go in place.

As the lfs/util_generic.go source file and the CloneFile() function it
defines within the "lfs" package are no longer used, we can simply
delete them now.
@chrisd8088 chrisd8088 marked this pull request as ready for review May 6, 2025 00:46
@chrisd8088 chrisd8088 requested a review from a team as a code owner May 6, 2025 00:46
@chrisd8088 chrisd8088 merged commit a920fbc into git-lfs:main May 22, 2025
10 checks passed
@chrisd8088 chrisd8088 deleted the drop-unused-clone-function branch May 22, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants