From aaab877f626af18c0d59467de37fa6a9c5eaea66 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Mon, 16 Mar 2020 14:44:17 -0500 Subject: [PATCH] Support git config credential resetting (#35064) --- stdlib/LibGit2/src/gitcredential.jl | 16 +++------------- stdlib/LibGit2/test/libgit2.jl | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/stdlib/LibGit2/src/gitcredential.jl b/stdlib/LibGit2/src/gitcredential.jl index f01da3a7ab37e..246ce075d24bd 100644 --- a/stdlib/LibGit2/src/gitcredential.jl +++ b/stdlib/LibGit2/src/gitcredential.jl @@ -222,21 +222,11 @@ function credential_helpers(cfg::GitConfig, cred::GitCredential) ismatch(url, cred) || continue # An empty credential.helper resets the list to empty - isempty(value) && empty!(helpers) - - # Due to a bug in libgit2 iteration we may read credential helpers out of order. - # See: https://github.com/libgit2/libgit2/issues/4361 - # - # Typically the ordering doesn't matter but does in this particular case. Disabling - # credential helpers avoids potential issues with using the wrong credentials or - # writing credentials to the wrong helper. if isempty(value) - @warn """Resetting the helper list is currently unsupported: - ignoring all git credential helpers""" maxlog=1 - return GitCredentialHelper[] + empty!(helpers) + else + Base.push!(helpers, parse(GitCredentialHelper, value)) end - - Base.push!(helpers, parse(GitCredentialHelper, value)) end return helpers diff --git a/stdlib/LibGit2/test/libgit2.jl b/stdlib/LibGit2/test/libgit2.jl index 0b3d61c9fe1e7..b7ecd31d5f0a1 100644 --- a/stdlib/LibGit2/test/libgit2.jl +++ b/stdlib/LibGit2/test/libgit2.jl @@ -1980,9 +1980,7 @@ mktempdir() do dir mygit_cred = GitCredential("https", "mygithost") @test LibGit2.credential_helpers(cfg, github_cred) == expected - - println(stderr, "The following 'Resetting the helper list...' warning is expected:") - @test_broken LibGit2.credential_helpers(cfg, mygit_cred) == expected[2] + @test LibGit2.credential_helpers(cfg, mygit_cred) == expected[2:2] Base.shred!(github_cred) Base.shred!(mygit_cred)