Skip to content

Commit

Permalink
Support git config credential resetting (#35064)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus authored Mar 16, 2020
1 parent 7c0608c commit 0f1b119
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
16 changes: 3 additions & 13 deletions stdlib/LibGit2/src/gitcredential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f1b119

Please sign in to comment.