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
79cfa20d
Commit
79cfa20d
authored
Nov 29, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy GIT_STATUS_OPTIONS_INIT
parent
b4d13652
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
24 deletions
+23
-24
src/stash.c
+1
-2
src/status.c
+18
-6
tests-clar/status/ignore.c
+0
-8
tests-clar/status/worktree.c
+4
-8
No files found.
src/stash.c
View file @
79cfa20d
...
...
@@ -471,9 +471,8 @@ static int ensure_there_are_changes_to_stash(
bool
include_ignored_files
)
{
int
error
;
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
if
(
include_untracked_files
)
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
...
...
src/status.c
View file @
79cfa20d
...
...
@@ -101,6 +101,18 @@ static int status_invoke_cb(
return
usercb
->
cb
(
path
,
status
,
usercb
->
payload
);
}
static
bool
options_have_valid_version
(
const
git_status_options
*
opts
)
{
if
(
!
opts
)
return
true
;
if
(
opts
->
version
>
0
&&
opts
->
version
<=
GIT_REMOTE_CALLBACKS_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d for git_repository_init_options"
,
opts
->
version
);
return
false
;
}
int
git_status_foreach_ext
(
git_repository
*
repo
,
const
git_status_options
*
opts
,
...
...
@@ -117,6 +129,9 @@ int git_status_foreach_ext(
assert
(
show
<=
GIT_STATUS_SHOW_INDEX_THEN_WORKDIR
);
if
(
!
options_have_valid_version
(
opts
))
return
-
1
;
if
(
show
!=
GIT_STATUS_SHOW_INDEX_ONLY
&&
(
err
=
git_repository__ensure_not_bare
(
repo
,
"status"
))
<
0
)
return
err
;
...
...
@@ -180,9 +195,8 @@ int git_status_foreach(
git_status_cb
callback
,
void
*
payload
)
{
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_IGNORED
|
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
...
...
@@ -223,16 +237,14 @@ int git_status_file(
const
char
*
path
)
{
int
error
;
git_status_options
opts
;
struct
status_file_info
sfi
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
struct
status_file_info
sfi
=
{
0
}
;
assert
(
status_flags
&&
repo
&&
path
);
memset
(
&
sfi
,
0
,
sizeof
(
sfi
));
if
((
sfi
.
expected
=
git__strdup
(
path
))
==
NULL
)
return
-
1
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_IGNORED
|
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
...
...
tests-clar/status/ignore.c
View file @
79cfa20d
...
...
@@ -180,9 +180,6 @@ void test_status_ignore__subdirectories(void)
{
status_entry_single
st
;
int
ignored
;
git_status_options
opts
;
GIT_UNUSED
(
opts
);
g_repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
...
...
@@ -216,11 +213,6 @@ void test_status_ignore__subdirectories(void)
cl_git_mkfile
(
"empty_standard_repo/test/ignore_me/file"
,
"I'm going to be ignored!"
);
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_IGNORED
|
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
;
memset
(
&
st
,
0
,
sizeof
(
st
));
cl_git_pass
(
git_status_foreach
(
g_repo
,
cb_status__single
,
&
st
));
cl_assert_equal_i
(
2
,
st
.
count
);
...
...
tests-clar/status/worktree.c
View file @
79cfa20d
...
...
@@ -111,7 +111,7 @@ void test_status_worktree__swap_subdir_and_file(void)
status_entry_counts
counts
;
git_repository
*
repo
=
cl_git_sandbox_init
(
"status"
);
git_index
*
index
;
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
bool
ignore_case
;
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
...
...
@@ -133,7 +133,6 @@ void test_status_worktree__swap_subdir_and_file(void)
counts
.
expected_paths
=
ignore_case
?
entry_paths3_icase
:
entry_paths3
;
counts
.
expected_statuses
=
ignore_case
?
entry_statuses3_icase
:
entry_statuses3
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_INCLUDE_IGNORED
;
...
...
@@ -150,7 +149,7 @@ void test_status_worktree__swap_subdir_with_recurse_and_pathspec(void)
{
status_entry_counts
counts
;
git_repository
*
repo
=
cl_git_sandbox_init
(
"status"
);
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
/* first alter the contents of the worktree */
cl_git_pass
(
p_rename
(
"status/current_file"
,
"status/swap"
));
...
...
@@ -167,7 +166,6 @@ void test_status_worktree__swap_subdir_with_recurse_and_pathspec(void)
counts
.
expected_paths
=
entry_paths4
;
counts
.
expected_statuses
=
entry_statuses4
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
;
/* TODO: set pathspec to "current_file" eventually */
...
...
@@ -691,7 +689,7 @@ void test_status_worktree__filemode_changes(void)
{
git_repository
*
repo
=
cl_git_sandbox_init
(
"filemodes"
);
status_entry_counts
counts
;
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
git_config
*
cfg
;
/* overwrite stored filemode with platform appropriate value */
...
...
@@ -708,7 +706,6 @@ void test_status_worktree__filemode_changes(void)
filemode_statuses
[
i
]
=
GIT_STATUS_CURRENT
;
}
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_INCLUDE_IGNORED
|
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
;
...
...
@@ -746,7 +743,7 @@ static int cb_status__expected_path(const char *p, unsigned int s, void *payload
void
test_status_worktree__disable_pathspec_match
(
void
)
{
git_repository
*
repo
;
git_status_options
opts
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
char
*
file_with_bracket
=
"LICENSE[1].md"
,
*
imaginary_file_with_bracket
=
"LICENSE[1-2].md"
;
...
...
@@ -754,7 +751,6 @@ void test_status_worktree__disable_pathspec_match(void)
cl_git_mkfile
(
"pathspec/LICENSE[1].md"
,
"screaming bracket
\n
"
);
cl_git_mkfile
(
"pathspec/LICENSE1.md"
,
"no bracket
\n
"
);
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH
;
opts
.
pathspec
.
count
=
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