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
79d5b5c9
Commit
79d5b5c9
authored
Jun 03, 2014
by
Alan Rogers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED
and a (failing) test for it.
parent
523553f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
17 deletions
+52
-17
include/git2/status.h
+16
-16
tests/status/worktree.c
+36
-1
No files found.
include/git2/status.h
View file @
79d5b5c9
...
...
@@ -134,28 +134,28 @@ typedef enum {
* together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline.
*/
typedef
enum
{
GIT_STATUS_OPT_INCLUDE_UNTRACKED
=
(
1u
<<
0
),
GIT_STATUS_OPT_INCLUDE_IGNORED
=
(
1u
<<
1
),
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
=
(
1u
<<
2
),
GIT_STATUS_OPT_EXCLUDE_SUBMODULES
=
(
1u
<<
3
),
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
=
(
1u
<<
4
),
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH
=
(
1u
<<
5
),
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS
=
(
1u
<<
6
),
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX
=
(
1u
<<
7
),
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR
=
(
1u
<<
8
),
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
=
(
1u
<<
9
),
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY
=
(
1u
<<
10
),
GIT_STATUS_OPT_RENAMES_FROM_REWRITES
=
(
1u
<<
11
),
GIT_STATUS_OPT_NO_REFRESH
=
(
1u
<<
12
),
GIT_STATUS_OPT_UPDATE_INDEX
=
(
1u
<<
13
),
GIT_STATUS_OPT_INCLUDE_UNREADABLE
=
(
1u
<<
14
),
GIT_STATUS_OPT_INCLUDE_UNTRACKED
=
(
1u
<<
0
),
GIT_STATUS_OPT_INCLUDE_IGNORED
=
(
1u
<<
1
),
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
=
(
1u
<<
2
),
GIT_STATUS_OPT_EXCLUDE_SUBMODULES
=
(
1u
<<
3
),
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
=
(
1u
<<
4
),
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH
=
(
1u
<<
5
),
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS
=
(
1u
<<
6
),
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX
=
(
1u
<<
7
),
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR
=
(
1u
<<
8
),
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
=
(
1u
<<
9
),
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY
=
(
1u
<<
10
),
GIT_STATUS_OPT_RENAMES_FROM_REWRITES
=
(
1u
<<
11
),
GIT_STATUS_OPT_NO_REFRESH
=
(
1u
<<
12
),
GIT_STATUS_OPT_UPDATE_INDEX
=
(
1u
<<
13
),
GIT_STATUS_OPT_INCLUDE_UNREADABLE
=
(
1u
<<
14
),
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED
=
(
1u
<<
15
),
}
git_status_opt_t
;
#define GIT_STATUS_OPT_DEFAULTS \
(GIT_STATUS_OPT_INCLUDE_IGNORED | \
GIT_STATUS_OPT_INCLUDE_UNTRACKED | \
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS)
/**
* Options to control how `git_status_foreach_ext()` will issue callbacks.
*
...
...
tests/status/worktree.c
View file @
79d5b5c9
...
...
@@ -936,7 +936,7 @@ void test_status_worktree__update_stat_cache_0(void)
git_status_list_free
(
status
);
}
void
test_status_worktree__
nopermissions
(
void
)
void
test_status_worktree__
unreadable
(
void
)
{
const
char
*
expected_paths
[]
=
{
"no_permission/foo"
};
const
unsigned
int
expected_statuses
[]
=
{
GIT_STATUS_WT_UNREADABLE
};
...
...
@@ -967,3 +967,38 @@ void test_status_worktree__nopermissions(void)
cl_assert_equal_i
(
0
,
counts
.
wrong_status_flags_count
);
cl_assert_equal_i
(
0
,
counts
.
wrong_sorted_path
);
}
void
test_status_worktree__unreadable_as_untracked
(
void
)
{
const
char
*
expected_paths
[]
=
{
"no_permission/foo"
};
const
unsigned
int
expected_statuses
[]
=
{
GIT_STATUS_WT_NEW
};
git_repository
*
repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
status_entry_counts
counts
=
{
0
};
/* Create directory with no read permission */
cl_git_pass
(
git_futils_mkdir_r
(
"empty_standard_repo/no_permission"
,
NULL
,
0777
));
cl_git_mkfile
(
"empty_standard_repo/no_permission/foo"
,
"dummy"
);
p_chmod
(
"empty_standard_repo/no_permission"
,
0644
);
counts
.
expected_entry_count
=
1
;
counts
.
expected_paths
=
expected_paths
;
counts
.
expected_statuses
=
expected_statuses
;
opts
.
show
=
GIT_STATUS_SHOW_WORKDIR_ONLY
;
opts
.
flags
=
GIT_STATUS_OPT_DEFAULTS
|
GIT_STATUS_OPT_INCLUDE_UNREADABLE
|
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED
;
cl_git_pass
(
git_status_foreach_ext
(
repo
,
&
opts
,
cb_status__normal
,
&
counts
)
);
/* Restore permissions so we can cleanup :) */
p_chmod
(
"empty_standard_repo/no_permission"
,
0777
);
cl_assert_equal_i
(
counts
.
expected_entry_count
,
counts
.
entry_count
);
cl_assert_equal_i
(
0
,
counts
.
wrong_status_flags_count
);
cl_assert_equal_i
(
0
,
counts
.
wrong_sorted_path
);
}
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