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
dcd759b8
Commit
dcd759b8
authored
Oct 10, 2016
by
Patrick Steinhardt
Committed by
GitHub
Oct 10, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3897 from pks-t/pks/squelch-example-warnings
Squelch example warnings, enable CI
parents
610cff13
ec3f5a9c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
16 deletions
+43
-16
examples/add.c
+4
-5
examples/common.c
+19
-0
examples/common.h
+9
-0
examples/diff.c
+3
-3
examples/general.c
+0
-0
examples/network/fetch.c
+7
-7
script/cibuild.sh
+1
-1
No files found.
examples/add.c
View file @
dcd759b8
...
@@ -75,15 +75,14 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
...
@@ -75,15 +75,14 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
{
{
struct
print_payload
p
=
*
(
struct
print_payload
*
)(
payload
);
struct
print_payload
p
=
*
(
struct
print_payload
*
)(
payload
);
int
ret
;
int
ret
;
git_status_t
status
;
unsigned
status
;
(
void
)
matched_pathspec
;
(
void
)
matched_pathspec
;
if
(
git_status_file
(
(
unsigned
int
*
)(
&
status
)
,
p
.
repo
,
path
))
{
if
(
git_status_file
(
&
status
,
p
.
repo
,
path
))
{
return
-
1
;
//abort
return
-
1
;
}
}
if
(
status
&
GIT_STATUS_WT_MODIFIED
||
if
(
status
&
GIT_STATUS_WT_MODIFIED
||
status
&
GIT_STATUS_WT_NEW
)
{
status
&
GIT_STATUS_WT_NEW
)
{
printf
(
"add '%s'
\n
"
,
path
);
printf
(
"add '%s'
\n
"
,
path
);
ret
=
0
;
ret
=
0
;
}
else
{
}
else
{
...
...
examples/common.c
View file @
dcd759b8
...
@@ -146,6 +146,25 @@ int match_uint16_arg(
...
@@ -146,6 +146,25 @@ int match_uint16_arg(
return
1
;
return
1
;
}
}
int
match_uint32_arg
(
uint32_t
*
out
,
struct
args_info
*
args
,
const
char
*
opt
)
{
const
char
*
found
=
match_numeric_arg
(
args
,
opt
);
uint16_t
val
;
char
*
endptr
=
NULL
;
if
(
!
found
)
return
0
;
val
=
(
uint32_t
)
strtoul
(
found
,
&
endptr
,
0
);
if
(
!
endptr
||
*
endptr
!=
'\0'
)
fatal
(
"expected number after argument"
,
opt
);
if
(
out
)
*
out
=
val
;
return
1
;
}
static
int
match_int_internal
(
static
int
match_int_internal
(
int
*
out
,
const
char
*
str
,
int
allow_negative
,
const
char
*
opt
)
int
*
out
,
const
char
*
str
,
int
allow_negative
,
const
char
*
opt
)
{
{
...
...
examples/common.h
View file @
dcd759b8
...
@@ -73,6 +73,15 @@ extern int match_uint16_arg(
...
@@ -73,6 +73,15 @@ extern int match_uint16_arg(
uint16_t
*
out
,
struct
args_info
*
args
,
const
char
*
opt
);
uint16_t
*
out
,
struct
args_info
*
args
,
const
char
*
opt
);
/**
/**
* Check current `args` entry against `opt` string parsing as uint32. If
* `opt` matches exactly, take the next arg as a uint16_t value; if `opt`
* is a prefix (equal sign optional), take the remainder of the arg as a
* uint32_t value; otherwise return 0.
*/
extern
int
match_uint32_arg
(
uint32_t
*
out
,
struct
args_info
*
args
,
const
char
*
opt
);
/**
* Check current `args` entry against `opt` string parsing as int. If
* Check current `args` entry against `opt` string parsing as int. If
* `opt` matches exactly, take the next arg as an int value; if it matches
* `opt` matches exactly, take the next arg as an int value; if it matches
* as a prefix (equal sign optional), take the remainder of the arg as a
* as a prefix (equal sign optional), take the remainder of the arg as a
...
...
examples/diff.c
View file @
dcd759b8
...
@@ -293,11 +293,11 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
...
@@ -293,11 +293,11 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
else
if
(
is_prefixed
(
a
,
"-B"
)
||
is_prefixed
(
a
,
"--break-rewrites"
))
else
if
(
is_prefixed
(
a
,
"-B"
)
||
is_prefixed
(
a
,
"--break-rewrites"
))
/* TODO: parse thresholds */
/* TODO: parse thresholds */
o
->
findopts
.
flags
|=
GIT_DIFF_FIND_REWRITES
;
o
->
findopts
.
flags
|=
GIT_DIFF_FIND_REWRITES
;
else
if
(
!
match_uint
16
_arg
(
else
if
(
!
match_uint
32
_arg
(
&
o
->
diffopts
.
context_lines
,
&
args
,
"-U"
)
&&
&
o
->
diffopts
.
context_lines
,
&
args
,
"-U"
)
&&
!
match_uint
16
_arg
(
!
match_uint
32
_arg
(
&
o
->
diffopts
.
context_lines
,
&
args
,
"--unified"
)
&&
&
o
->
diffopts
.
context_lines
,
&
args
,
"--unified"
)
&&
!
match_uint
16
_arg
(
!
match_uint
32
_arg
(
&
o
->
diffopts
.
interhunk_lines
,
&
args
,
"--inter-hunk-context"
)
&&
&
o
->
diffopts
.
interhunk_lines
,
&
args
,
"--inter-hunk-context"
)
&&
!
match_uint16_arg
(
!
match_uint16_arg
(
&
o
->
diffopts
.
id_abbrev
,
&
args
,
"--abbrev"
)
&&
&
o
->
diffopts
.
id_abbrev
,
&
args
,
"--abbrev"
)
&&
...
...
examples/general.c
View file @
dcd759b8
This diff is collapsed.
Click to expand it.
examples/network/fetch.c
View file @
dcd759b8
...
@@ -55,6 +55,8 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
...
@@ -55,6 +55,8 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
*/
*/
static
int
transfer_progress_cb
(
const
git_transfer_progress
*
stats
,
void
*
payload
)
static
int
transfer_progress_cb
(
const
git_transfer_progress
*
stats
,
void
*
payload
)
{
{
(
void
)
payload
;
if
(
stats
->
received_objects
==
stats
->
total_objects
)
{
if
(
stats
->
received_objects
==
stats
->
total_objects
)
{
printf
(
"Resolving deltas %d/%d
\r
"
,
printf
(
"Resolving deltas %d/%d
\r
"
,
stats
->
indexed_deltas
,
stats
->
total_deltas
);
stats
->
indexed_deltas
,
stats
->
total_deltas
);
...
@@ -71,7 +73,6 @@ int fetch(git_repository *repo, int argc, char **argv)
...
@@ -71,7 +73,6 @@ int fetch(git_repository *repo, int argc, char **argv)
{
{
git_remote
*
remote
=
NULL
;
git_remote
*
remote
=
NULL
;
const
git_transfer_progress
*
stats
;
const
git_transfer_progress
*
stats
;
struct
dl_data
data
;
git_fetch_options
fetch_opts
=
GIT_FETCH_OPTIONS_INIT
;
git_fetch_options
fetch_opts
=
GIT_FETCH_OPTIONS_INIT
;
if
(
argc
<
2
)
{
if
(
argc
<
2
)
{
...
@@ -79,14 +80,13 @@ int fetch(git_repository *repo, int argc, char **argv)
...
@@ -79,14 +80,13 @@ int fetch(git_repository *repo, int argc, char **argv)
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
/
/ Figure out whether it's a named remote or a URL
/
* Figure out whether it's a named remote or a URL */
printf
(
"Fetching %s for repo %p
\n
"
,
argv
[
1
],
repo
);
printf
(
"Fetching %s for repo %p
\n
"
,
argv
[
1
],
repo
);
if
(
git_remote_lookup
(
&
remote
,
repo
,
argv
[
1
])
<
0
)
{
if
(
git_remote_lookup
(
&
remote
,
repo
,
argv
[
1
])
<
0
)
if
(
git_remote_create_anonymous
(
&
remote
,
repo
,
argv
[
1
])
<
0
)
if
(
git_remote_create_anonymous
(
&
remote
,
repo
,
argv
[
1
])
<
0
)
return
-
1
;
goto
on_error
;
}
/
/ Set up the callbacks (only update_tips for now)
/
* Set up the callbacks (only update_tips for now) */
fetch_opts
.
callbacks
.
update_tips
=
&
update_cb
;
fetch_opts
.
callbacks
.
update_tips
=
&
update_cb
;
fetch_opts
.
callbacks
.
sideband_progress
=
&
progress_cb
;
fetch_opts
.
callbacks
.
sideband_progress
=
&
progress_cb
;
fetch_opts
.
callbacks
.
transfer_progress
=
transfer_progress_cb
;
fetch_opts
.
callbacks
.
transfer_progress
=
transfer_progress_cb
;
...
@@ -98,7 +98,7 @@ int fetch(git_repository *repo, int argc, char **argv)
...
@@ -98,7 +98,7 @@ int fetch(git_repository *repo, int argc, char **argv)
* "fetch".
* "fetch".
*/
*/
if
(
git_remote_fetch
(
remote
,
NULL
,
&
fetch_opts
,
"fetch"
)
<
0
)
if
(
git_remote_fetch
(
remote
,
NULL
,
&
fetch_opts
,
"fetch"
)
<
0
)
return
-
1
;
goto
on_error
;
/**
/**
* If there are local objects (we got a thin pack), then tell
* If there are local objects (we got a thin pack), then tell
...
...
script/cibuild.sh
View file @
dcd759b8
...
@@ -20,7 +20,7 @@ java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar &
...
@@ -20,7 +20,7 @@ java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar &
mkdir _build
mkdir _build
cd
_build
cd
_build
# shellcheck disable=SC2086
# shellcheck disable=SC2086
cmake ..
-DCMAKE_INSTALL_PREFIX
=
../_install
$OPTIONS
||
exit
$?
cmake ..
-D
BUILD_EXAMPLES
=
ON
-D
CMAKE_INSTALL_PREFIX
=
../_install
$OPTIONS
||
exit
$?
make
-j2
install
||
exit
$?
make
-j2
install
||
exit
$?
# If this platform doesn't support test execution, bail out now
# If this platform doesn't support test execution, bail out now
...
...
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