开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
开源项目 > 开发工具 > 版本管理系统 &&
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
main
分支 (571)
标签 (119)
main
ethomson/docs-update
ethomson/debug_build
ethomson/sha256
ethomson/linked_tokens
ethomson/commits_with_empty_signatures
ethomson/blamefix
ethomson/7265
ethomson/cygwin
copilot/linker-failure-debugging
copilot/pcre2
ethomson/pcre2
ethomson/mingw
ethomson/ci
ethomson/commit
ethomson/regex
maint/v1.9
copilot/backport-v19-4
ethomson/build
ethomson/stat64
v1.9.4
v1.9.3
v1.8.5
v1.9.2
v1.9.1
v1.9.0
v1.8.4
v1.8.3
v1.8.2
v1.8.2-rc1
v1.8.1
v1.8.0
v1.7.2
v1.6.5
v1.7.1
v1.7.0
v1.6.4
v1.6.3
v1.6.2
v1.6.1
main
分支 (571)
标签 (119)
main
ethomson/docs-update
ethomson/debug_build
ethomson/sha256
ethomson/linked_tokens
ethomson/commits_with_empty_signatures
ethomson/blamefix
ethomson/7265
ethomson/cygwin
copilot/linker-failure-debugging
copilot/pcre2
ethomson/pcre2
ethomson/mingw
ethomson/ci
ethomson/commit
ethomson/regex
maint/v1.9
copilot/backport-v19-4
ethomson/build
ethomson/stat64
v1.9.4
v1.9.3
v1.8.5
v1.9.2
v1.9.1
v1.9.0
v1.8.4
v1.8.3
v1.8.2
v1.8.2-rc1
v1.8.1
v1.8.0
v1.7.2
v1.6.5
v1.7.1
v1.7.0
v1.6.4
v1.6.3
v1.6.2
v1.6.1
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
main
分支 (571)
标签 (119)
main
ethomson/docs-update
ethomson/debug_build
ethomson/sha256
ethomson/linked_tokens
ethomson/commits_with_empty_signatures
ethomson/blamefix
ethomson/7265
ethomson/cygwin
copilot/linker-failure-debugging
copilot/pcre2
ethomson/pcre2
ethomson/mingw
ethomson/ci
ethomson/commit
ethomson/regex
maint/v1.9
copilot/backport-v19-4
ethomson/build
ethomson/stat64
v1.9.4
v1.9.3
v1.8.5
v1.9.2
v1.9.1
v1.9.0
v1.8.4
v1.8.3
v1.8.2
v1.8.2-rc1
v1.8.1
v1.8.0
v1.7.2
v1.6.5
v1.7.1
v1.7.0
v1.6.4
v1.6.3
v1.6.2
v1.6.1
libgit2
/
src
/
util
/
errors.c
libgit2
/
src
/
util
/
errors.c
errors.c 7.22 KB
一键复制 编辑 原始数据 按行查看 历史
Peter Pettersson 提交于 2023年11月20日 17:42 +08:00 . util: include git2/deprecated.h in errors.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "git2_util.h"
#include "errors.h"
#include "posix.h"
#include "str.h"
#include "runtime.h"
/*
* Some static error data that is used when we're out of memory, TLS
* has not been setup, or TLS has failed.
*/
static git_error oom_error = {
"Out of memory",
GIT_ERROR_NOMEMORY
};
static git_error uninitialized_error = {
"library has not been initialized",
GIT_ERROR_INVALID
};
static git_error tlsdata_error = {
"thread-local data initialization failure",
GIT_ERROR_THREAD
};
static git_error no_error = {
"no error",
GIT_ERROR_NONE
};
#define IS_STATIC_ERROR(err) \
((err) == &oom_error || (err) == &uninitialized_error || \
(err) == &tlsdata_error || (err) == &no_error)
/* Per-thread error state (TLS) */
static git_tlsdata_key tls_key;
struct error_threadstate {
/* The error message buffer. */
git_str message;
/* Error information, set by `git_error_set` and friends. */
git_error error;
/*
* The last error to occur; points to the error member of this
* struct _or_ a static error.
*/
git_error *last;
};
static void threadstate_dispose(struct error_threadstate *threadstate)
{
if (!threadstate)
return;
git_str_dispose(&threadstate->message);
}
static struct error_threadstate *threadstate_get(void)
{
struct error_threadstate *threadstate;
if ((threadstate = git_tlsdata_get(tls_key)) != NULL)
return threadstate;
/*
* Avoid git__malloc here, since if it fails, it sets an error
* message, which requires thread state, which would allocate
* here, which would fail, which would set an error message...
*/
if ((threadstate = git__allocator.gmalloc(
sizeof(struct error_threadstate),
__FILE__, __LINE__)) == NULL)
return NULL;
memset(threadstate, 0, sizeof(struct error_threadstate));
if (git_str_init(&threadstate->message, 0) < 0) {
git__allocator.gfree(threadstate);
return NULL;
}
git_tlsdata_set(tls_key, threadstate);
return threadstate;
}
static void GIT_SYSTEM_CALL threadstate_free(void *threadstate)
{
threadstate_dispose(threadstate);
git__free(threadstate);
}
static void git_error_global_shutdown(void)
{
struct error_threadstate *threadstate;
threadstate = git_tlsdata_get(tls_key);
git_tlsdata_set(tls_key, NULL);
threadstate_dispose(threadstate);
git__free(threadstate);
git_tlsdata_dispose(tls_key);
}
int git_error_global_init(void)
{
if (git_tlsdata_init(&tls_key, &threadstate_free) != 0)
return -1;
return git_runtime_shutdown_register(git_error_global_shutdown);
}
static void set_error_from_buffer(int error_class)
{
struct error_threadstate *threadstate = threadstate_get();
git_error *error;
git_str *buf;
if (!threadstate)
return;
error = &threadstate->error;
buf = &threadstate->message;
error->message = buf->ptr;
error->klass = error_class;
threadstate->last = error;
}
static void set_error(int error_class, char *string)
{
struct error_threadstate *threadstate = threadstate_get();
git_str *buf;
if (!threadstate)
return;
buf = &threadstate->message;
git_str_clear(buf);
if (string)
git_str_puts(buf, string);
if (!git_str_oom(buf))
set_error_from_buffer(error_class);
}
void git_error_set_oom(void)
{
struct error_threadstate *threadstate = threadstate_get();
if (!threadstate)
return;
threadstate->last = &oom_error;
}
void git_error_set(int error_class, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
git_error_vset(error_class, fmt, ap);
va_end(ap);
}
void git_error_vset(int error_class, const char *fmt, va_list ap)
{
#ifdef GIT_WIN32
DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
#endif
struct error_threadstate *threadstate = threadstate_get();
int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
git_str *buf;
if (!threadstate)
return;
buf = &threadstate->message;
git_str_clear(buf);
if (fmt) {
git_str_vprintf(buf, fmt, ap);
if (error_class == GIT_ERROR_OS)
git_str_PUTS(buf, ": ");
}
if (error_class == GIT_ERROR_OS) {
#ifdef GIT_WIN32
char *win32_error = git_win32_get_error_message(win32_error_code);
if (win32_error) {
git_str_puts(buf, win32_error);
git__free(win32_error);
SetLastError(0);
}
else
#endif
if (error_code)
git_str_puts(buf, strerror(error_code));
if (error_code)
errno = 0;
}
if (!git_str_oom(buf))
set_error_from_buffer(error_class);
}
int git_error_set_str(int error_class, const char *string)
{
struct error_threadstate *threadstate = threadstate_get();
git_str *buf;
GIT_ASSERT_ARG(string);
if (!threadstate)
return -1;
buf = &threadstate->message;
git_str_clear(buf);
git_str_puts(buf, string);
if (git_str_oom(buf))
return -1;
set_error_from_buffer(error_class);
return 0;
}
void git_error_clear(void)
{
struct error_threadstate *threadstate = threadstate_get();
if (!threadstate)
return;
if (threadstate->last != NULL) {
set_error(0, NULL);
threadstate->last = NULL;
}
errno = 0;
#ifdef GIT_WIN32
SetLastError(0);
#endif
}
bool git_error_exists(void)
{
struct error_threadstate *threadstate;
if ((threadstate = threadstate_get()) == NULL)
return true;
return threadstate->last != NULL;
}
const git_error *git_error_last(void)
{
struct error_threadstate *threadstate;
/* If the library is not initialized, return a static error. */
if (!git_runtime_init_count())
return &uninitialized_error;
if ((threadstate = threadstate_get()) == NULL)
return &tlsdata_error;
if (!threadstate->last)
return &no_error;
return threadstate->last;
}
int git_error_save(git_error **out)
{
struct error_threadstate *threadstate = threadstate_get();
git_error *error, *dup;
if (!threadstate) {
*out = &tlsdata_error;
return -1;
}
error = threadstate->last;
if (!error || error == &no_error) {
*out = &no_error;
return 0;
} else if (IS_STATIC_ERROR(error)) {
*out = error;
return 0;
}
if ((dup = git__malloc(sizeof(git_error))) == NULL) {
*out = &oom_error;
return -1;
}
dup->klass = error->klass;
dup->message = git__strdup(error->message);
if (!dup->message) {
*out = &oom_error;
return -1;
}
*out = dup;
return 0;
}
int git_error_restore(git_error *error)
{
struct error_threadstate *threadstate = threadstate_get();
GIT_ASSERT_ARG(error);
if (IS_STATIC_ERROR(error) && threadstate)
threadstate->last = error;
else
set_error(error->klass, error->message);
git_error_free(error);
return 0;
}
void git_error_free(git_error *error)
{
if (!error)
return;
if (IS_STATIC_ERROR(error))
return;
git__free(error->message);
git__free(error);
}
int git_error_system_last(void)
{
#ifdef GIT_WIN32
return GetLastError();
#else
return errno;
#endif
}
void git_error_system_set(int code)
{
#ifdef GIT_WIN32
SetLastError(code);
#else
errno = code;
#endif
}
/* Deprecated error values and functions */
#ifndef GIT_DEPRECATE_HARD
#include "git2/deprecated.h"
const git_error *giterr_last(void)
{
return git_error_last();
}
void giterr_clear(void)
{
git_error_clear();
}
void giterr_set_str(int error_class, const char *string)
{
git_error_set_str(error_class, string);
}
void giterr_set_oom(void)
{
git_error_set_oom();
}
#endif
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

libgit2 is a portable, pure C implementation of the Git core methods provided as a linkable library with a solid API, allowing to build Git functionality into your application.
取消

发行版

暂无发行版

开源评估指数源自 OSS-Compass 评估体系,评估体系围绕以下三个维度对项目展开评估:

1. 开源生态

  • 生产力:来评估开源项目输出软件制品和开源价值的能力。
  • 创新力:用于评估开源软件及其生态系统的多样化程度。
  • 稳健性:用于评估开源项目面对多变的发展环境,抵御内外干扰并自我恢复的能力。

2. 协作、人、软件

  • 协作:代表了开源开发行为中协作的程度和深度。
  • 人:观察开源项目核心人员在开源项目中的影响力,并通过第三方视角考察用户和开发者对开源项目的评价。
  • 软件:从开源项目对外输出的制品评估其价值最终落脚点。也是开源评估最"古老"的主流方向之一"开源软件" 的具体表现。

3. 评估模型

    基于"开源生态"与"协作、人、软件"的维度,找到与该目标直接或间接相关的可量化指标,对开源项目健康与生态进行量化评估,最终形成开源评估指数。

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fibjs/libgit2.git
git@gitee.com:fibjs/libgit2.git
fibjs
libgit2
libgit2
main
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /