8000 Regression, calls to !git_error_last() not updated after commit 3618a2a · Issue #6801 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content
Regression, calls to !git_error_last() not updated after commit 3618a2a #6801
@jdavid

Description

@jdavid

This is a regression in libgit2 v1.8.0
Error introduced in commit 3618a2a
It shows up with Windows (winhttp).
Found in pygit2's test suite, see https://ci.appveyor.com/project/jdavid/pygit2/builds/49513776
It currently blocks the release of pygit2, see libgit2/pygit2#1285

Commit 3618a2a introduces this change:

@@ -184,6 +189,9 @@ const git_error *git_error_last(void)
        if ((threadstate = git_threadstate_get()) == NULL)
                return &tlsdata_error;
 
+       if (!threadstate->last_error)
+               return &no_error;
+
        return threadstate->last_error;
 }

But winhttp.c is not updated:

static int certificate_check(winhttp_stream *s, int valid)
{
    [...]

    if (error < 0 && !git_error_last())    <----
        git_error_set(GIT_ERROR_HTTP, "user cancelled certificate check");

Here since commit 3618a2a !git_error_last() always evaluates to false.

To find out where the issue is I made my fork of libgit2 and reverted the change introduced in commit 3618a2a. The result is that the tests pass, see https://ci.appveyor.com/project/jdavid/pygit2/builds/49705963

Of course I think the proper fix would be to update winhttp.c

A git grep shows that this same error happens in other places in libgit2:

$ git --no-pager grep "\!git_error_last()"
src/libgit2/transports/ssh_libssh2.c:		if (!git_error_last())
src/libgit2/transports/winhttp.c:		if (!git_error_last())
src/libgit2/transports/winhttp.c:	if (error < 0 && !git_error_last())
src/libgit2/transports/winhttp.c:				if (!git_error_last())
src/util/fs_path.c:			if (!git_error_last())

Reproduction steps

Error found in pygit2 CI (AppVeyor), see https://ci.appveyor.com/project/jdavid/pygit2/builds/49513776/job/v4dw1jrduwk69k20

Expected behavior

The test should pass.

Actual behavior

The test fails.

Version of libgit2 (release number or SHA1)

Error introduced in commit 3618a2a

Operating system(s) tested

Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0