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
fcc7dcb1
Commit
fcc7dcb1
authored
Jan 10, 2019
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
errors: remove giterr usage in examples
parent
115a6c50
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
examples/checkout.c
+5
-5
examples/common.c
+1
-1
examples/general.c
+1
-1
examples/merge.c
+2
-2
examples/network/clone.c
+1
-1
examples/network/git2.c
+2
-2
No files found.
examples/checkout.c
View file @
fcc7dcb1
...
...
@@ -132,7 +132,7 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
/** Grab the commit we're interested to move to */
err
=
git_commit_lookup
(
&
target_commit
,
repo
,
git_annotated_commit_id
(
target
));
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"failed to lookup commit: %s
\n
"
,
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"failed to lookup commit: %s
\n
"
,
git
_erro
r_last
()
->
message
);
goto
cleanup
;
}
...
...
@@ -140,12 +140,12 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
* Perform the checkout so the workdir corresponds to what target_commit
* contains.
*
* Note that it's okay to pass a git_commit here, because it will be
* Note that it's okay to pass a git_commit here, because it will be
* peeled to a tree.
*/
err
=
git_checkout_tree
(
repo
,
(
const
git_object
*
)
target_commit
,
&
checkout_opts
);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"failed to checkout tree: %s
\n
"
,
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"failed to checkout tree: %s
\n
"
,
git
_erro
r_last
()
->
message
);
goto
cleanup
;
}
...
...
@@ -161,7 +161,7 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
err
=
git_repository_set_head_detached_from_annotated
(
repo
,
target
);
}
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"failed to update HEAD reference: %s
\n
"
,
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"failed to update HEAD reference: %s
\n
"
,
git
_erro
r_last
()
->
message
);
goto
cleanup
;
}
...
...
@@ -219,7 +219,7 @@ int main(int argc, char **argv)
*/
err
=
resolve_refish
(
&
checkout_target
,
repo
,
args
.
argv
[
args
.
pos
]);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"failed to resolve %s: %s
\n
"
,
args
.
argv
[
args
.
pos
],
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"failed to resolve %s: %s
\n
"
,
args
.
argv
[
args
.
pos
],
git
_erro
r_last
()
->
message
);
goto
cleanup
;
}
err
=
perform_checkout_ref
(
repo
,
checkout_target
,
&
opts
);
...
...
examples/common.c
View file @
fcc7dcb1
...
...
@@ -24,7 +24,7 @@ void check_lg2(int error, const char *message, const char *extra)
if
(
!
error
)
return
;
if
((
lg2err
=
git
er
r_last
())
!=
NULL
&&
lg2err
->
message
!=
NULL
)
{
if
((
lg2err
=
git
_erro
r_last
())
!=
NULL
&&
lg2err
->
message
!=
NULL
)
{
lg2msg
=
lg2err
->
message
;
lg2spacer
=
" - "
;
}
...
...
examples/general.c
View file @
fcc7dcb1
...
...
@@ -66,7 +66,7 @@ static void config_files(const char *repo_path, git_repository *repo);
*/
static
void
check_error
(
int
error_code
,
const
char
*
action
)
{
const
git_error
*
error
=
git
er
r_last
();
const
git_error
*
error
=
git
_erro
r_last
();
if
(
!
error_code
)
return
;
...
...
examples/merge.c
View file @
fcc7dcb1
...
...
@@ -96,7 +96,7 @@ static int resolve_heads(git_repository *repo, merge_options *opts)
for
(
i
=
0
;
i
<
opts
->
heads_count
;
i
++
)
{
err
=
resolve_refish
(
&
annotated
[
annotated_count
++
],
repo
,
opts
->
heads
[
i
]);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"failed to resolve refish %s: %s
\n
"
,
opts
->
heads
[
i
],
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"failed to resolve refish %s: %s
\n
"
,
opts
->
heads
[
i
],
git
_erro
r_last
()
->
message
);
annotated_count
--
;
continue
;
}
...
...
@@ -229,7 +229,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, merge_opt
/* Maybe that's a ref, so DWIM it */
err
=
git_reference_dwim
(
&
merge_ref
,
repo
,
opts
->
heads
[
0
]);
check_lg2
(
err
,
"failed to DWIM reference"
,
git
er
r_last
()
->
message
);
check_lg2
(
err
,
"failed to DWIM reference"
,
git
_erro
r_last
()
->
message
);
/* Grab a signature */
check_lg2
(
git_signature_now
(
&
sign
,
"Me"
,
"me@example.com"
),
"failed to create signature"
,
NULL
);
...
...
examples/network/clone.c
View file @
fcc7dcb1
...
...
@@ -104,7 +104,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
error
=
git_clone
(
&
cloned_repo
,
url
,
path
,
&
clone_opts
);
printf
(
"
\n
"
);
if
(
error
!=
0
)
{
const
git_error
*
err
=
git
er
r_last
();
const
git_error
*
err
=
git
_erro
r_last
();
if
(
err
)
printf
(
"ERROR %d: %s
\n
"
,
err
->
klass
,
err
->
message
);
else
printf
(
"ERROR %d: no detailed info
\n
"
,
error
);
}
...
...
examples/network/git2.c
View file @
fcc7dcb1
...
...
@@ -26,10 +26,10 @@ static int run_command(git_cb fn, git_repository *repo, struct args_info args)
/* Run the command. If something goes wrong, print the error message to stderr */
error
=
fn
(
repo
,
args
.
argc
-
args
.
pos
,
&
args
.
argv
[
args
.
pos
]);
if
(
error
<
0
)
{
if
(
git
er
r_last
()
==
NULL
)
if
(
git
_erro
r_last
()
==
NULL
)
fprintf
(
stderr
,
"Error without message"
);
else
fprintf
(
stderr
,
"Bad news:
\n
%s
\n
"
,
git
er
r_last
()
->
message
);
fprintf
(
stderr
,
"Bad news:
\n
%s
\n
"
,
git
_erro
r_last
()
->
message
);
}
return
!!
error
;
...
...
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