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
813937ce
Commit
813937ce
authored
Sep 04, 2013
by
Krzysztof Adamski
Committed by
Russell Belfer
Sep 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better usage info in add example.
parent
24d23220
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
examples/add.c
+20
-7
No files found.
examples/add.c
View file @
813937ce
...
...
@@ -58,6 +58,15 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
return
ret
;
}
void
print_usage
(
void
)
{
fprintf
(
stderr
,
"usage: add [options] [--] file-spec [file-spec] [...]
\n\n
"
);
fprintf
(
stderr
,
"
\t
-n, --dry-run dry run
\n
"
);
fprintf
(
stderr
,
"
\t
-v, --verbose be verbose
\n
"
);
fprintf
(
stderr
,
"
\t
-u, --update update tracked files
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
git_index_matched_path_cb
matched_cb
=
NULL
;
...
...
@@ -67,11 +76,6 @@ int main (int argc, char** argv)
int
i
,
options
=
0
;
struct
print_payload
payload
=
{
0
};
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"usage: add [-n|--dry-run] [-v|--verbose] [-u|--update] file-spec [file-spec] [...]
\n
"
);
return
1
;
}
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
argv
[
i
][
0
]
!=
'-'
)
{
break
;
...
...
@@ -85,22 +89,31 @@ int main (int argc, char** argv)
else
if
(
!
strcmp
(
argv
[
i
],
"--update"
)
||
!
strcmp
(
argv
[
i
],
"-u"
))
{
options
|=
UPDATE
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-h"
))
{
print_usage
();
break
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"--"
))
{
i
++
;
break
;
}
else
{
fprintf
(
stderr
,
"Unsupported option %s.
\n
"
,
argv
[
i
]);
print_usage
();
return
1
;
}
}
init_array
(
&
array
,
argc
-
i
,
argv
+
i
);
printf
(
"args:
\n
"
);
for
(
i
=
0
;
i
<
array
.
count
;
i
++
)
{
printf
(
" - %s
\n
"
,
array
.
strings
[
i
]);
if
(
argc
<=
i
)
{
print_usage
();
return
1
;
}
init_array
(
&
array
,
argc
-
i
,
argv
+
i
);
if
(
git_repository_open
(
&
repo
,
"."
)
<
0
)
{
fprintf
(
stderr
,
"No git repository
\n
"
);
return
1
;
...
...
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