forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
credential-cache: handle ECONNREFUSED gracefully #5329
Open
rimrul
wants to merge
4
commits into
git-for-windows:main
Choose a base branch
from
rimrul:credential-cache-unknown-error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−11
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "unit-test.h" | ||
|
||
#if defined(GIT_WINDOWS_NATIVE) && !defined(_UCRT) | ||
#undef strerror | ||
int errnos_contains(int); | ||
static int errnos [53]={ | ||
/* errnos in err_win_to_posix */ | ||
EACCES, EBUSY, EEXIST, ERANGE, EIO, ENODEV, ENXIO, ENOEXEC, EINVAL, ENOENT, | ||
EPIPE, ENAMETOOLONG, ENOSYS, ENOTEMPTY, ENOSPC, EFAULT, EBADF, EPERM, EINTR, | ||
E2BIG, ESPIPE, ENOMEM, EXDEV, EAGAIN, ENFILE, EMFILE, ECHILD, EROFS, | ||
/* errnos only in winsock_error_to_errno */ | ||
EWOULDBLOCK, EINPROGRESS, EALREADY, ENOTSOCK, EDESTADDRREQ, EMSGSIZE, | ||
EPROTOTYPE, ENOPROTOOPT, EPROTONOSUPPORT, EOPNOTSUPP, EAFNOSUPPORT, | ||
EADDRINUSE, EADDRNOTAVAIL, ENETDOWN, ENETUNREACH, ENETRESET, ECONNABORTED, | ||
ECONNRESET, ENOBUFS, EISCONN, ENOTCONN, ETIMEDOUT, ECONNREFUSED, ELOOP, | ||
EHOSTUNREACH | ||
}; | ||
|
||
int errnos_contains(int errnum) | ||
{ | ||
for(int i=0;i<53;i++) | ||
if(errnos[i]==errnum) | ||
return 1; | ||
return 0; | ||
} | ||
#endif | ||
|
||
void test_mingw__no_strerror_shim_on_ucrt(void) | ||
{ | ||
#if defined(GIT_WINDOWS_NATIVE) && defined(_UCRT) | ||
cl_assert_(strerror != mingw_strerror, | ||
"mingw_strerror is unnescessary when building against UCRT"); | ||
#else | ||
cl_skip(); | ||
#endif | ||
} | ||
|
||
void test_mingw__strerror(void) | ||
{ | ||
#if defined(GIT_WINDOWS_NATIVE) && !defined(_UCRT) | ||
for(int i=0;i<53;i++) | ||
{ | ||
char *crt; | ||
char *mingw; | ||
mingw = mingw_strerror(errnos[i]); | ||
crt = strerror(errnos[i]); | ||
cl_assert_(!strcasestr(mingw, "unknown error"), | ||
"mingw_strerror should know all errno values we care about"); | ||
if(!strcasestr(crt, "unknown error")) | ||
cl_assert_equal_s(crt,mingw); | ||
} | ||
#else | ||
cl_skip(); | ||
#endif | ||
} | ||
|
||
void test_mingw__errno_translation(void) | ||
{ | ||
#if defined(GIT_WINDOWS_NATIVE) && !defined(_UCRT) | ||
/* GetLastError() return values are currently defined from 0 to 15841, | ||
testing up to 20000 covers some room for future expansion */ | ||
for (int i=0;i<20000;i++) | ||
{ | ||
if(i!=ERROR_SUCCESS) | ||
cl_assert_(errnos_contains(err_win_to_posix(i)), | ||
"all err_win_to_posix return values should be tested against mingw_strerror"); | ||
/* ideally we'd test the same for winsock_error_to_errno, but it's static */ | ||
} | ||
#else | ||
cl_skip(); | ||
#endif | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To distinguish the two identical error messages "unable to connect to cache daemon", consider changing the second to “unable to connect to spawned cache daemon”