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
69a282da
Unverified
Commit
69a282da
authored
Mar 28, 2018
by
Carson Howard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submodule: add more robust error handling when a submodule path is found on add
parent
c07abd65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
src/submodule.c
+14
-11
tests/submodule/add.c
+2
-2
No files found.
src/submodule.c
View file @
69a282da
...
...
@@ -163,10 +163,12 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
if
((
error
=
git_repository_index__weakptr
(
&
index
,
repo
))
<
0
)
goto
out
;
if
((
error
=
git_index_find
(
NULL
,
index
,
path
))
==
0
)
{
giterr_set
(
GITERR_SUBMODULE
,
"File '%s' already exists in the index"
,
path
);
*
occupied
=
true
;
if
((
error
=
git_index_find
(
NULL
,
index
,
path
))
!=
GIT_ENOTFOUND
)
{
if
(
!
error
)
{
giterr_set
(
GITERR_SUBMODULE
,
"File '%s' already exists in the index"
,
path
);
*
occupied
=
true
;
}
goto
out
;
}
...
...
@@ -176,14 +178,15 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
if
((
error
=
git_path_to_dir
(
&
dir
))
<
0
)
goto
out
;
if
((
error
=
git_index_find_prefix
(
NULL
,
index
,
dir
.
ptr
))
<
0
&&
error
!=
GIT_ENOTFOUND
)
goto
out
;
if
(
!
error
)
{
giterr_set
(
GITERR_SUBMODULE
,
"Directory '%s' already exists in the index"
,
path
);
*
occupied
=
true
;
if
((
error
=
git_index_find_prefix
(
NULL
,
index
,
dir
.
ptr
))
!=
GIT_ENOTFOUND
)
{
if
(
!
error
)
{
giterr_set
(
GITERR_SUBMODULE
,
"Directory '%s' already exists in the index"
,
path
);
*
occupied
=
true
;
}
goto
out
;
}
error
=
0
;
out:
...
...
tests/submodule/add.c
View file @
69a282da
...
...
@@ -156,7 +156,7 @@ void test_submodule_add__path_exists_in_index(void)
cl_git_pass
(
git_buf_joinpath
(
&
filename
,
"subdirectory"
,
"test.txt"
));
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_repository_index
__weakptr
(
&
index
,
g_repo
));
test_add_entry
(
index
,
valid_blob_id
,
filename
.
ptr
,
GIT_FILEMODE_BLOB
);
...
...
@@ -174,7 +174,7 @@ void test_submodule_add__file_exists_in_index(void)
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_repository_index
__weakptr
(
&
index
,
g_repo
));
test_add_entry
(
index
,
valid_blob_id
,
"subdirectory"
,
GIT_FILEMODE_BLOB
);
...
...
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