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
d39fff36
Commit
d39fff36
authored
Jun 23, 2013
by
Russell Belfer
Committed by
Vicent Marti
Jul 10, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic framework for log command
parent
bf3ee3cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletions
+59
-1
examples/Makefile
+1
-1
examples/log.c
+58
-0
No files found.
examples/Makefile
View file @
d39fff36
...
...
@@ -3,7 +3,7 @@
CC
=
gcc
CFLAGS
=
-g
-I
../include
-I
../src
-Wall
-Wextra
-Wmissing-prototypes
-Wno-missing-field-initializers
LFLAGS
=
-L
../build
-lgit2
-lz
APPS
=
general showindex diff rev-list cat-file status
APPS
=
general showindex diff rev-list cat-file status
log
all
:
$(APPS)
...
...
examples/log.c
0 → 100644
View file @
d39fff36
#include <stdio.h>
#include <git2.h>
#include <stdlib.h>
#include <string.h>
static
void
check
(
int
error
,
const
char
*
message
)
{
if
(
error
)
{
fprintf
(
stderr
,
"%s (%d)
\n
"
,
message
,
error
);
exit
(
1
);
}
}
static
int
check_str_param
(
const
char
*
arg
,
const
char
*
pat
,
const
char
**
val
)
{
size_t
len
=
strlen
(
pat
);
if
(
strncmp
(
arg
,
pat
,
len
))
return
0
;
*
val
=
(
const
char
*
)(
arg
+
len
);
return
1
;
}
static
void
usage
(
const
char
*
message
,
const
char
*
arg
)
{
if
(
message
&&
arg
)
fprintf
(
stderr
,
"%s: %s
\n
"
,
message
,
arg
);
else
if
(
message
)
fprintf
(
stderr
,
"%s
\n
"
,
message
);
fprintf
(
stderr
,
"usage: log [<options>]
\n
"
);
exit
(
1
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
;
char
*
a
;
const
char
*
dir
=
"."
;
git_repository
*
repo
;
git_threads_init
();
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
a
=
argv
[
i
];
if
(
a
[
0
]
!=
'-'
)
{
}
else
if
(
!
check_str_param
(
a
,
"--git-dir="
,
&
dir
))
usage
(
"Unknown argument"
,
a
);
}
check
(
git_repository_open_ext
(
&
repo
,
dir
,
0
,
NULL
),
"Could not open repository"
);
git_repository_free
(
repo
);
git_threads_shutdown
();
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