Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
42bacbc6
Unverified
Commit
42bacbc6
authored
Aug 11, 2019
by
Edward Thomson
Committed by
GitHub
Aug 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5121 from pks-t/pks/variadic-errors
Variadic macros
parents
b0692d6b
1721ab04
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
16 deletions
+39
-16
src/apply.c
+12
-3
src/errors.c
+12
-7
src/errors.h
+2
-2
src/parse.h
+0
-3
src/patch_parse.c
+12
-0
src/unix/posix.h
+1
-1
No files found.
src/apply.c
View file @
42bacbc6
...
...
@@ -24,9 +24,6 @@
#include "reader.h"
#include "index.h"
#define apply_err(...) \
( git_error_set(GIT_ERROR_PATCH, __VA_ARGS__), GIT_EAPPLYFAIL )
typedef
struct
{
/* The lines that we allocate ourself are allocated out of the pool.
* (Lines may have been allocated out of the diff.)
...
...
@@ -35,6 +32,18 @@ typedef struct {
git_vector
lines
;
}
patch_image
;
static
int
apply_err
(
const
char
*
fmt
,
...)
GIT_FORMAT_PRINTF
(
1
,
2
);
static
int
apply_err
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
git_error_vset
(
GIT_ERROR_PATCH
,
fmt
,
ap
);
va_end
(
ap
);
return
GIT_EAPPLYFAIL
;
}
static
void
patch_line_init
(
git_diff_line
*
out
,
const
char
*
in
,
...
...
src/errors.c
View file @
42bacbc6
...
...
@@ -49,9 +49,17 @@ void git_error_set_oom(void)
GIT_GLOBAL
->
last_error
=
&
g_git_oom_error
;
}
void
git_error_set
(
int
error_class
,
const
char
*
string
,
...)
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
)
{
va_list
arglist
;
#ifdef GIT_WIN32
DWORD
win32_error_code
=
(
error_class
==
GIT_ERROR_OS
)
?
GetLastError
()
:
0
;
#endif
...
...
@@ -59,11 +67,8 @@ void git_error_set(int error_class, const char *string, ...)
git_buf
*
buf
=
&
GIT_GLOBAL
->
error_buf
;
git_buf_clear
(
buf
);
if
(
string
)
{
va_start
(
arglist
,
string
);
git_buf_vprintf
(
buf
,
string
,
arglist
);
va_end
(
arglist
);
if
(
fmt
)
{
git_buf_vprintf
(
buf
,
fmt
,
ap
);
if
(
error_class
==
GIT_ERROR_OS
)
git_buf_PUTS
(
buf
,
": "
);
}
...
...
src/errors.h
View file @
42bacbc6
...
...
@@ -14,8 +14,8 @@
/*
* Set the error message for this thread, formatting as needed.
*/
void
git_error_
set
(
int
error_class
,
const
char
*
string
,
...)
GIT_FORMAT_PRINTF
(
2
,
3
);
void
git_error_set
(
int
error_class
,
const
char
*
fmt
,
...)
GIT_FORMAT_PRINTF
(
2
,
3
);
void
git_error_
vset
(
int
error_class
,
const
char
*
fmt
,
va_list
ap
);
/**
* Set the error message for a regex failure, using the internal regex
...
...
src/parse.h
View file @
42bacbc6
...
...
@@ -28,9 +28,6 @@ typedef struct {
int
git_parse_ctx_init
(
git_parse_ctx
*
ctx
,
const
char
*
content
,
size_t
content_len
);
void
git_parse_ctx_clear
(
git_parse_ctx
*
ctx
);
#define git_parse_err(...) \
( git_error_set(GIT_ERROR_PATCH, __VA_ARGS__), -1 )
#define git_parse_ctx_contains_s(ctx, str) \
git_parse_ctx_contains(ctx, str, sizeof(str) - 1)
...
...
src/patch_parse.c
View file @
42bacbc6
...
...
@@ -33,6 +33,18 @@ typedef struct {
char
*
old_prefix
,
*
new_prefix
;
}
git_patch_parsed
;
static
int
git_parse_err
(
const
char
*
fmt
,
...)
GIT_FORMAT_PRINTF
(
1
,
2
);
static
int
git_parse_err
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
git_error_vset
(
GIT_ERROR_PATCH
,
fmt
,
ap
);
va_end
(
ap
);
return
-
1
;
}
static
size_t
header_path_len
(
git_patch_parse_ctx
*
ctx
)
{
bool
inquote
=
0
;
...
...
src/unix/posix.h
View file @
42bacbc6
...
...
@@ -59,7 +59,7 @@ GIT_INLINE(int) p_fsync(int fd)
#define p_strcasecmp(s1, s2) strcasecmp(s1, s2)
#define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c)
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
#define p_snprintf
(b, c, ...) snprintf(b, c, __VA_ARGS__)
#define p_snprintf
snprintf
#define p_mkstemp(p) mkstemp(p)
#define p_chdir(p) chdir(p)
#define p_chmod(p,m) chmod(p, m)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment