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
722c08af
Commit
722c08af
authored
May 07, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
status: Prevent git_status_file() from returning ENOTFOUND when not applicable
parent
464cf248
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
src/status.c
+4
-4
tests-clar/status/worktree.c
+17
-0
No files found.
src/status.c
View file @
722c08af
...
@@ -340,17 +340,17 @@ int git_status_file(
...
@@ -340,17 +340,17 @@ int git_status_file(
assert
(
status_flags
&&
repo
&&
path
);
assert
(
status_flags
&&
repo
&&
path
);
if
((
workdir
=
git_repository_workdir
(
repo
))
==
NULL
)
{
if
((
workdir
=
git_repository_workdir
(
repo
))
==
NULL
)
{
giterr_set
(
GITERR_
OS
,
"Cannot get file status from bare repo"
);
giterr_set
(
GITERR_
INVALID
,
"Cannot get file status from bare repo"
);
return
GIT_ENOTFOUND
;
return
-
1
;
}
}
if
(
git_buf_joinpath
(
&
temp_path
,
workdir
,
path
)
<
0
)
if
(
git_buf_joinpath
(
&
temp_path
,
workdir
,
path
)
<
0
)
return
-
1
;
return
-
1
;
if
(
git_path_isdir
(
temp_path
.
ptr
))
{
if
(
git_path_isdir
(
temp_path
.
ptr
))
{
giterr_set
(
GITERR_
OS
,
"Cannot get file status for directory '%s'"
,
temp_path
.
ptr
);
giterr_set
(
GITERR_
INVALID
,
"Cannot get file status for directory '%s'"
,
temp_path
.
ptr
);
git_buf_free
(
&
temp_path
);
git_buf_free
(
&
temp_path
);
return
GIT_ENOTFOUND
;
return
-
1
;
}
}
e
=
status_entry_new
(
NULL
,
path
);
e
=
status_entry_new
(
NULL
,
path
);
...
...
tests-clar/status/worktree.c
View file @
722c08af
...
@@ -275,6 +275,7 @@ void test_status_worktree__single_folder(void)
...
@@ -275,6 +275,7 @@ void test_status_worktree__single_folder(void)
error
=
git_status_file
(
&
status_flags
,
repo
,
"subdir"
);
error
=
git_status_file
(
&
status_flags
,
repo
,
"subdir"
);
cl_git_fail
(
error
);
cl_git_fail
(
error
);
cl_assert
(
error
!=
GIT_ENOTFOUND
);
}
}
...
@@ -384,3 +385,18 @@ void test_status_worktree__issue_592_5(void)
...
@@ -384,3 +385,18 @@ void test_status_worktree__issue_592_5(void)
git_buf_free
(
&
path
);
git_buf_free
(
&
path
);
}
}
void
test_status_worktree__cannot_retrieve_the_status_of_a_bare_repository
(
void
)
{
git_repository
*
repo
;
int
error
,
status
=
0
;
cl_git_pass
(
git_repository_open
(
&
repo
,
cl_fixture
(
"testrepo.git"
)));
error
=
git_status_file
(
&
status
,
repo
,
"dummy"
);
cl_git_fail
(
error
);
cl_assert
(
error
!=
GIT_ENOTFOUND
);
git_repository_free
(
repo
);
}
\ No newline at end of file
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