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
a3b9731f
Commit
a3b9731f
authored
9 years ago
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submodule: add a test for a renamed submdoule dir
parent
f17525b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
tests/submodule/lookup.c
+55
-0
No files found.
tests/submodule/lookup.c
View file @
a3b9731f
...
...
@@ -333,3 +333,58 @@ void test_submodule_lookup__prefix_name(void)
git_submodule_free
(
sm
);
}
void
test_submodule_lookup__renamed
(
void
)
{
const
char
*
newpath
=
"sm_actually_changed"
;
git_index
*
idx
;
sm_lookup_data
data
;
cl_git_pass
(
git_repository_index__weakptr
(
&
idx
,
g_repo
));
/* We're replicating 'git mv sm_unchanged sm_actually_changed' in this test */
cl_git_pass
(
p_rename
(
"submod2/sm_unchanged"
,
"submod2/sm_actually_changed"
));
/* Change the path in .gitmodules and stage it*/
{
git_config
*
cfg
;
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"submod2/.gitmodules"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"submodule.sm_unchanged.path"
,
newpath
));
git_config_free
(
cfg
);
cl_git_pass
(
git_index_add_bypath
(
idx
,
".gitmodules"
));
}
/* Change the worktree info in the the submodule's config */
{
git_config
*
cfg
;
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"submod2/.git/modules/sm_unchanged/config"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"core.worktree"
,
"../../../sm_actually_changed"
));
git_config_free
(
cfg
);
}
/* Rename the entry in the index */
{
const
git_index_entry
*
e
;
git_index_entry
entry
=
{
0
};
e
=
git_index_get_bypath
(
idx
,
"sm_unchanged"
,
0
);
cl_assert
(
e
);
cl_assert_equal_i
(
GIT_FILEMODE_COMMIT
,
e
->
mode
);
entry
.
path
=
newpath
;
entry
.
mode
=
GIT_FILEMODE_COMMIT
;
git_oid_cpy
(
&
entry
.
id
,
&
e
->
id
);
cl_git_pass
(
git_index_remove
(
idx
,
"sm_unchanged"
,
0
));
cl_git_pass
(
git_index_add
(
idx
,
&
entry
));
cl_git_pass
(
git_index_write
(
idx
));
}
memset
(
&
data
,
0
,
sizeof
(
data
));
cl_git_pass
(
git_submodule_foreach
(
g_repo
,
sm_lookup_cb
,
&
data
));
cl_assert_equal_i
(
8
,
data
.
count
);
}
This diff is collapsed.
Click to expand it.
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