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
106998fc
Commit
106998fc
authored
Jan 24, 2019
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: print available commands if no args are given
parent
ead10785
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
examples/lg2.c
+16
-4
No files found.
examples/lg2.c
View file @
106998fc
...
...
@@ -50,6 +50,17 @@ static int run_command(git_command_fn fn, git_repository *repo, struct args_info
return
!!
error
;
}
static
int
usage
(
const
char
*
prog
)
{
size_t
i
;
fprintf
(
stderr
,
"usage: %s <cmd>...
\n\n
Available commands:
\n\n
"
,
prog
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
commands
);
i
++
)
fprintf
(
stderr
,
"
\t
%s
\n
"
,
commands
[
i
].
name
);
exit
(
EXIT_FAILURE
);
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
args_info
args
=
ARGS_INFO_INIT
;
...
...
@@ -58,10 +69,8 @@ int main(int argc, char **argv)
int
return_code
=
1
;
size_t
i
;
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"usage: %s <cmd> [repo]
\n
"
,
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
if
(
argc
<
2
)
usage
(
argv
[
0
]);
git_libgit2_init
();
...
...
@@ -79,6 +88,9 @@ int main(int argc, char **argv)
}
}
if
(
args
.
pos
==
args
.
argc
)
usage
(
argv
[
0
]);
if
(
!
git_dir
)
git_dir
=
"."
;
...
...
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