• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37535

pending completion
#37535

push

local

web-flow
irinterp: Fix accidentally introduced deletion of effectful statement (#49750)

I moved around some code in #49692 that broadened the replacement of
statements by their const results. This is fine for how we're currently
using irinterp in base, because we're requiring some fairly strong
effects, but some downstream pipelines (and potentially Base in the future)
want to use irinterp on code with arbitrary effects, so put in an
appropriate check.

2 of 2 new or added lines in 2 files covered. (100.0%)

71489 of 83224 relevant lines covered (85.9%)

32529585.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/stdlib/LibGit2/src/error.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
module Error
4

5
import ..LibGit2: ensure_initialized
6

7
export GitError
8

9
@enum(Code, GIT_OK          = Cint(0),   # no error
10
            ERROR           = Cint(-01), # generic error
11
            ENOTFOUND       = Cint(-03), # requested object could not be found
12
            EEXISTS         = Cint(-04), # object exits preventing op
13
            EAMBIGUOUS      = Cint(-05), # more than one object matches
14
            EBUFS           = Cint(-06), # output buffer too small to hold data
15
            EUSER           = Cint(-07), # user callback generated error
16
            EBAREREPO       = Cint(-08), # operation not allowed on bare repo
17
            EUNBORNBRANCH   = Cint(-09), # HEAD refers to branch with 0 commits
18
            EUNMERGED       = Cint(-10), # merge in progress prevented op
19
            ENONFASTFORWARD = Cint(-11), # ref not fast-forwardable
20
            EINVALIDSPEC    = Cint(-12), # name / ref not in valid format
21
            EMERGECONFLICT  = Cint(-13), # merge conflict prevented op
22
            ELOCKED         = Cint(-14), # lock file prevented op
23
            EMODIFIED       = Cint(-15), # ref value does not match expected
24
            EAUTH           = Cint(-16), # authentication error
25
            ECERTIFICATE    = Cint(-17), # server certificate is invalid
26
            EAPPLIED        = Cint(-18), # patch/merge has already been applied
27
            EPEEL           = Cint(-19), # the requested peel operation is not possible
28
            EEOF            = Cint(-20), # unexpected EOF
29
            PASSTHROUGH     = Cint(-30), # internal only
30
            ITEROVER        = Cint(-31), # signals end of iteration
31
            RETRY           = Cint(-32), # internal only
32
            EMISMATCH       = Cint(-33), # hashsum mismatch in object
33
            EINDEXDIRTY     = Cint(-34), # unsaved changes in the index would be overwritten
34
            EAPPLYFAIL      = Cint(-35), # patch application failed
35
            EOWNER          = Cint(-36)) # the object is not owned by the current user
36

37
@enum(Class, None,
38
             NoMemory,
39
             OS,
40
             Invalid,
41
             Reference,
42
             Zlib,
43
             Repository,
44
             Config,
45
             Regex,
46
             Odb,
47
             Index,
48
             Object,
49
             Net,
50
             Tag,
51
             Tree,
52
             Indexer,
53
             SSL,
54
             Submodule,
55
             Thread,
56
             Stash,
57
             Checkout,
58
             FetchHead,
59
             Merge,
60
             SSH,
61
             Filter,
62
             Revert,
63
             Callback,
64
             CherryPick,
65
             Describe,
66
             Rebase,
67
             Filesystem,
68
             Patch,
69
             WorkTree,
70
             SHA1,
71
             HTTP)
72

73
struct ErrorStruct
74
    message::Ptr{UInt8}
75
    class::Cint
76
end
77

78
struct GitError <: Exception
79
    class::Class
27✔
80
    code::Code
81
    msg::String
82
end
83
Base.show(io::IO, err::GitError) = print(io, "GitError(Code:$(err.code), Class:$(err.class), $(err.msg))")
×
84

85
function last_error()
×
86
    ensure_initialized()
27✔
87
    err = ccall((:giterr_last, :libgit2), Ptr{ErrorStruct}, ())
27✔
88
    if err != C_NULL
27✔
89
        err_obj   = unsafe_load(err)
27✔
90
        err_class = Class(err_obj.class)
27✔
91
        err_msg   = unsafe_string(err_obj.message)
27✔
92
    else
93
        err_class = Class(0)
×
94
        err_msg = "No errors"
×
95
    end
96
    return (err_class, err_msg)
27✔
97
end
98

99
GitError(err_code::Integer) = GitError(Code(err_code))
27✔
100
function GitError(err_code::Code)
×
101
    err_class, err_msg = last_error()
27✔
102
    return GitError(err_class, err_code, err_msg)
27✔
103
end
104

105
end # Error module
106

107
macro check(git_func)
108
    quote
109
        err = Cint($(esc(git_func::Expr)))
127✔
110
        if err < 0
127✔
111
            throw(Error.GitError(err))
24✔
112
        end
113
        err
18✔
114
    end
115
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc