Prefer .netrc on windows if present by johanvdw · Pull Request #6055 · git-lfs/git-lfs · GitHub
Skip to content

Prefer .netrc on windows if present - #6055

Merged
chrisd8088 merged 5 commits into
git-lfs:mainfrom
johanvdw:windows.netrc
May 21, 2025
Merged

chrisd8088 merged 5 commits into
git-lfs:mainfrom
johanvdw:windows.netrc

Conversation

@johanvdw

Copy link
Copy Markdown
Contributor

Closes #5182

Aligns the project with curl and git.

@johanvdw
johanvdw requested a review from a team as a code owner May 19, 2025 13:38
Support for reading and parsing ".netrc" files (or "_netrc" files on
Windows) was first added to the Git LFS client in PR git-lfs#715, and the
parsing code was later moved into our "config" package in PR git-lfs#1226.

Subsequently, almost identical parsing code was also added to our
"lfsapi" package in commit 2275188
of PR git-lfs#1839, which was later moved to its current location in our
"creds" package in PR git-lfs#3307.

Meanwhile, the only caller of the original ".netrc" parser, which
was implemented in the parseNetrc() method of the Configuration structure
in our "config" package, was removed in commit
afcd211 PR git-lfs#1846.

As a consequence, since PR git-lfs#1846 the parseNetrc() method in the "config"
package has remained unused, along with the related "netrcfinder"
interface and associated structure and method in the same source file,
so we can simply delete that file now.
In previous commits in this PR we revised the ParseNetrc() function
in our "creds" package to support both ".netrc" and "_netrc" files
on Windows, whereas it has previously only supported "_netrc" files.

This change will align the behaviour of the Git LFS client with that
of contemporary versions of curl and Git, as they now support both
filenames on Windows.  Specifically, this support was added in commit
curl/curl@f9c7ba9, which was included
in curl v7.66.0.

To validate these changes, we also update our t/t-credentials.sh test
script so it runs the key "credentials from netrc" test twice on Windows,
once with a ".netrc" file and once with a legacy "_netrc" file.

As well, we adjust the other tests which previously used a "_netrc"
file on Windows to simply use a ".netrc" file, as this should work
on all systems now.
@chrisd8088

chrisd8088 commented May 21, 2025 •

Copy link
Copy Markdown
Member

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this great improvement, and welcome to the Git LFS project!

I think if we add some test changes like the ones I drafted, that should cover the main thing we'll want to include in this PR.

We might as well also just drop the config/netrc.go file, too, I think; there's no point in keeping it around. I also drafted a commit to do that, with some notes on the tangled history of these files.

Thanks again very much for working on this!

Comment thread creds/netrc.go Outdated
Co-authored-by: Chris Darroch <chrisd@apache.org>
@johanvdw

Copy link
Copy Markdown
Contributor Author

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

I usually try to solicit a second opinion from another @git-lfs/core member when I've contributed to a PR, but in this case I think my changes are sufficiently minimal (just deleting an unused file and tweaking the test cases) that I can approve this PR as it stands.

Thanks again very much!

@chrisd8088
chrisd8088 merged commit 684449b into git-lfs:main May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.netrc files ignored by Git LFS on Windows but used by Git via cURL

2 participants