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
c924f36a
Unverified
Commit
c924f36a
authored
Nov 06, 2019
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: keep track of whether we processed a "--" arg
parent
025a9357
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
10 deletions
+23
-10
examples/args.c
+13
-0
examples/args.h
+6
-0
examples/checkout.c
+2
-6
examples/lg2.c
+1
-2
examples/log.c
+1
-2
No files found.
examples/args.c
View file @
c924f36a
...
...
@@ -168,3 +168,16 @@ int match_int_arg(
return
0
;
return
match_int_internal
(
out
,
found
,
allow_negative
,
opt
);
}
int
match_arg_separator
(
struct
args_info
*
args
)
{
if
(
args
->
opts_done
)
return
1
;
if
(
strcmp
(
args
->
argv
[
args
->
pos
],
"--"
)
!=
0
)
return
0
;
args
->
opts_done
=
1
;
args
->
pos
++
;
return
1
;
}
examples/args.h
View file @
c924f36a
...
...
@@ -8,6 +8,7 @@ struct args_info {
int
argc
;
char
**
argv
;
int
pos
;
int
opts_done
:
1
;
/**< Did we see a -- separator */
};
#define ARGS_INFO_INIT { argc, argv, 0, 0 }
#define ARGS_CURRENT(args) args->argv[args->pos]
...
...
@@ -76,4 +77,9 @@ extern int match_int_arg(
*/
extern
int
match_bool_arg
(
int
*
out
,
struct
args_info
*
args
,
const
char
*
opt
);
/**
* Check if we're processing past the single -- separator
*/
extern
int
match_arg_separator
(
struct
args_info
*
args
);
#endif
examples/checkout.c
View file @
c924f36a
...
...
@@ -65,7 +65,7 @@ static void parse_options(const char **repo_path, checkout_options *opts, struct
const
char
*
curr
=
args
->
argv
[
args
->
pos
];
int
bool_arg
;
if
(
strcmp
(
curr
,
"--"
)
==
0
)
{
if
(
match_arg_separator
(
args
)
)
{
break
;
}
else
if
(
!
strcmp
(
curr
,
"--force"
))
{
opts
->
force
=
1
;
...
...
@@ -190,11 +190,7 @@ int lg2_checkout(git_repository *repo, int argc, char **argv)
goto
cleanup
;
}
if
(
args
.
pos
>=
args
.
argc
)
{
fprintf
(
stderr
,
"unhandled
\n
"
);
err
=
-
1
;
goto
cleanup
;
}
else
if
(
!
strcmp
(
"--"
,
args
.
argv
[
args
.
pos
]))
{
if
(
match_arg_separator
(
&
args
))
{
/**
* Try to checkout the given path
*/
...
...
examples/lg2.c
View file @
c924f36a
...
...
@@ -84,8 +84,7 @@ int main(int argc, char **argv)
break
;
}
else
if
(
optional_str_arg
(
&
git_dir
,
&
args
,
"--git-dir"
,
".git"
))
{
continue
;
}
else
if
(
!
strcmp
(
a
,
"--"
))
{
/* arg separator */
}
else
if
(
match_arg_separator
(
&
args
))
{
break
;
}
}
...
...
examples/log.c
View file @
c924f36a
...
...
@@ -424,8 +424,7 @@ static int parse_options(
else
/** Try failed revision parse as filename. */
break
;
}
else
if
(
!
strcmp
(
a
,
"--"
))
{
++
args
.
pos
;
}
else
if
(
!
match_arg_separator
(
&
args
))
{
break
;
}
else
if
(
!
strcmp
(
a
,
"--date-order"
))
...
...
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