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
4a65aead
Commit
4a65aead
authored
May 10, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1571 from arrbee/what-if-ignorecase-lies
Improve ignore handling in git_status_file
parents
c3a51711
1f9e41ee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
16 deletions
+40
-16
src/status.c
+4
-16
tests-clar/clar_libgit2.c
+12
-0
tests-clar/clar_libgit2.h
+1
-0
tests-clar/status/worktree.c
+23
-0
No files found.
src/status.c
View file @
4a65aead
...
...
@@ -266,6 +266,7 @@ int git_status_file(
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts
.
flags
=
GIT_STATUS_OPT_INCLUDE_IGNORED
|
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS
|
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
|
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
;
...
...
@@ -281,22 +282,9 @@ int git_status_file(
}
if
(
!
error
&&
!
sfi
.
count
)
{
git_buf
full
=
GIT_BUF_INIT
;
/* if the file actually exists and we still did not get a callback
* for it, then it must be contained inside an ignored directory, so
* mark it as such instead of generating an error.
*/
if
(
!
git_buf_joinpath
(
&
full
,
git_repository_workdir
(
repo
),
path
)
&&
git_path_exists
(
full
.
ptr
))
sfi
.
status
=
GIT_STATUS_IGNORED
;
else
{
giterr_set
(
GITERR_INVALID
,
"Attempt to get status of nonexistent file '%s'"
,
path
);
error
=
GIT_ENOTFOUND
;
}
git_buf_free
(
&
full
);
giterr_set
(
GITERR_INVALID
,
"Attempt to get status of nonexistent file '%s'"
,
path
);
error
=
GIT_ENOTFOUND
;
}
*
status_flags
=
sfi
.
status
;
...
...
tests-clar/clar_libgit2.c
View file @
4a65aead
...
...
@@ -190,6 +190,18 @@ git_repository *cl_git_sandbox_init(const char *sandbox)
return
_cl_repo
;
}
git_repository
*
cl_git_sandbox_reopen
(
void
)
{
if
(
_cl_repo
)
{
git_repository_free
(
_cl_repo
);
_cl_repo
=
NULL
;
cl_git_pass
(
git_repository_open
(
&
_cl_repo
,
_cl_sandbox
));
}
return
_cl_repo
;
}
void
cl_git_sandbox_cleanup
(
void
)
{
if
(
_cl_repo
)
{
...
...
tests-clar/clar_libgit2.h
View file @
4a65aead
...
...
@@ -60,6 +60,7 @@ int cl_rename(const char *source, const char *dest);
git_repository
*
cl_git_sandbox_init
(
const
char
*
sandbox
);
void
cl_git_sandbox_cleanup
(
void
);
git_repository
*
cl_git_sandbox_reopen
(
void
);
/* Local-repo url helpers */
const
char
*
cl_git_fixture_url
(
const
char
*
fixturename
);
...
...
tests-clar/status/worktree.c
View file @
4a65aead
...
...
@@ -672,3 +672,26 @@ void test_status_worktree__file_status_honors_core_ignorecase_false(void)
{
assert_ignore_case
(
false
,
GIT_STATUS_WT_DELETED
,
GIT_STATUS_WT_NEW
);
}
void
test_status_worktree__file_status_honors_case_ignorecase_regarding_untracked_files
(
void
)
{
git_repository
*
repo
=
cl_git_sandbox_init
(
"status"
);
unsigned
int
status
;
git_index
*
index
;
cl_repo_set_bool
(
repo
,
"core.ignorecase"
,
false
);
repo
=
cl_git_sandbox_reopen
();
/* Actually returns GIT_STATUS_IGNORED on Windows */
cl_git_fail_with
(
git_status_file
(
&
status
,
repo
,
"NEW_FILE"
),
GIT_ENOTFOUND
);
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"new_file"
));
cl_git_pass
(
git_index_write
(
index
));
git_index_free
(
index
);
/* Actually returns GIT_STATUS_IGNORED on Windows */
cl_git_fail_with
(
git_status_file
(
&
status
,
repo
,
"NEW_FILE"
),
GIT_ENOTFOUND
);
}
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