mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 20:02:04 +00:00

This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
75 lines
1.3 KiB
C
75 lines
1.3 KiB
C
/*
|
|
* Copyright (C) 2009-2012 the libgit2 contributors
|
|
*
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
* a Linking Exception. For full terms see the included COPYING file.
|
|
*/
|
|
#ifndef INCLUDE_git_errors_h__
|
|
#define INCLUDE_git_errors_h__
|
|
|
|
#include "common.h"
|
|
|
|
/**
|
|
* @file git2/errors.h
|
|
* @brief Git error handling routines and variables
|
|
* @ingroup Git
|
|
* @{
|
|
*/
|
|
GIT_BEGIN_DECL
|
|
|
|
/** Generic return codes */
|
|
enum {
|
|
GIT_OK = 0,
|
|
GIT_ERROR = -1,
|
|
GIT_ENOTFOUND = -3,
|
|
GIT_EEXISTS = -4,
|
|
GIT_EAMBIGUOUS = -5,
|
|
GIT_EBUFS = -6,
|
|
GIT_EUSER = -7,
|
|
|
|
GIT_PASSTHROUGH = -30,
|
|
GIT_REVWALKOVER = -31,
|
|
};
|
|
|
|
typedef struct {
|
|
char *message;
|
|
int klass;
|
|
} git_error;
|
|
|
|
/** Error classes */
|
|
typedef enum {
|
|
GITERR_NOMEMORY,
|
|
GITERR_OS,
|
|
GITERR_INVALID,
|
|
GITERR_REFERENCE,
|
|
GITERR_ZLIB,
|
|
GITERR_REPOSITORY,
|
|
GITERR_CONFIG,
|
|
GITERR_REGEX,
|
|
GITERR_ODB,
|
|
GITERR_INDEX,
|
|
GITERR_OBJECT,
|
|
GITERR_NET,
|
|
GITERR_TAG,
|
|
GITERR_TREE,
|
|
GITERR_INDEXER,
|
|
GITERR_SSL,
|
|
} git_error_t;
|
|
|
|
/**
|
|
* Return the last `git_error` object that was generated for the
|
|
* current thread or NULL if no error has occurred.
|
|
*
|
|
* @return A git_error object.
|
|
*/
|
|
GIT_EXTERN(const git_error *) giterr_last(void);
|
|
|
|
/**
|
|
* Clear the last library error that occurred for this thread.
|
|
*/
|
|
GIT_EXTERN(void) giterr_clear(void);
|
|
|
|
/** @} */
|
|
GIT_END_DECL
|
|
#endif
|