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
784b3abb
Commit
784b3abb
authored
Oct 30, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rev-list.c example: use common utils, reorganize
parent
9d83d368
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
34 deletions
+28
-34
examples/rev-list.c
+28
-34
No files found.
examples/rev-list.c
View file @
784b3abb
#include <stdio.h>
#include <string.h>
/*
* 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.h>
#include
"common.h"
static
void
check_error
(
int
error_code
,
const
char
*
action
)
static
int
revwalk_parseopts
(
git_repository
*
repo
,
git_revwalk
*
walk
,
int
nopts
,
char
**
opts
);
int
main
(
int
argc
,
char
**
argv
)
{
if
(
!
error_code
)
return
;
git_repository
*
repo
;
git_revwalk
*
walk
;
git_oid
oid
;
char
buf
[
41
];
git_threads_init
();
const
git_error
*
error
=
giterr_last
();
fprintf
(
stderr
,
"Error %d %s: %s
\n
"
,
-
error_code
,
action
,
(
error
&&
error
->
message
)
?
error
->
message
:
"???"
);
exit
(
1
);
check_lg2
(
git_repository_open_ext
(
&
repo
,
"."
,
0
,
NULL
),
"opening repository"
,
NULL
);
check_lg2
(
git_revwalk_new
(
&
walk
,
repo
),
"allocating revwalk"
,
NULL
);
check_lg2
(
revwalk_parseopts
(
repo
,
walk
,
argc
-
1
,
argv
+
1
),
"parsing options"
,
NULL
);
while
(
!
git_revwalk_next
(
&
oid
,
walk
))
{
git_oid_fmt
(
buf
,
&
oid
);
buf
[
40
]
=
'\0'
;
printf
(
"%s
\n
"
,
buf
);
}
git_threads_shutdown
();
return
0
;
}
static
int
push_commit
(
git_revwalk
*
walk
,
const
git_oid
*
oid
,
int
hide
)
...
...
@@ -93,27 +111,3 @@ static int revwalk_parseopts(git_repository *repo, git_revwalk *walk, int nopts,
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
error
;
git_repository
*
repo
;
git_revwalk
*
walk
;
git_oid
oid
;
char
buf
[
41
];
error
=
git_repository_open_ext
(
&
repo
,
"."
,
0
,
NULL
);
check_error
(
error
,
"opening repository"
);
error
=
git_revwalk_new
(
&
walk
,
repo
);
check_error
(
error
,
"allocating revwalk"
);
error
=
revwalk_parseopts
(
repo
,
walk
,
argc
-
1
,
argv
+
1
);
check_error
(
error
,
"parsing options"
);
while
(
!
git_revwalk_next
(
&
oid
,
walk
))
{
git_oid_fmt
(
buf
,
&
oid
);
buf
[
40
]
=
'\0'
;
printf
(
"%s
\n
"
,
buf
);
}
return
0
;
}
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