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
677d393c
Commit
677d393c
authored
Dec 18, 2017
by
Carson Howard
Committed by
Carson Howard
Mar 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: submodule: insert index entries directly into index
parent
ef9a7749
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
tests/submodule/add.c
+22
-18
No files found.
tests/submodule/add.c
View file @
677d393c
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "repository.h"
#include "repository.h"
static
git_repository
*
g_repo
=
NULL
;
static
git_repository
*
g_repo
=
NULL
;
static
const
char
*
valid_blob_id
=
"fa49b077972391ad58037050f2a75f74e3671e92"
;
void
test_submodule_add__cleanup
(
void
)
void
test_submodule_add__cleanup
(
void
)
{
{
...
@@ -129,31 +130,39 @@ void test_submodule_add__url_relative_to_workdir(void)
...
@@ -129,31 +130,39 @@ void test_submodule_add__url_relative_to_workdir(void)
assert_submodule_url
(
"TestGitRepository"
,
git_repository_workdir
(
g_repo
));
assert_submodule_url
(
"TestGitRepository"
,
git_repository_workdir
(
g_repo
));
}
}
static
void
test_add_entry
(
git_index
*
index
,
const
char
*
idstr
,
const
char
*
path
,
git_filemode_t
mode
)
{
git_index_entry
entry
=
{{
0
}};
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
idstr
));
entry
.
path
=
path
;
entry
.
mode
=
mode
;
cl_git_pass
(
git_index_add
(
index
,
&
entry
));
}
void
test_submodule_add__path_exists_in_index
(
void
)
void
test_submodule_add__path_exists_in_index
(
void
)
{
{
git_index
*
index
;
git_index
*
index
;
git_submodule
*
sm
;
git_submodule
*
sm
;
git_buf
dirname
=
GIT_BUF_INIT
;
git_buf
filename
=
GIT_BUF_INIT
;
git_buf
filename
=
GIT_BUF_INIT
;
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
cl_git_pass
(
git_buf_joinpath
(
&
dirname
,
git_repository_workdir
(
g_repo
),
"subdirectory"
));
cl_git_pass
(
git_buf_joinpath
(
&
filename
,
"subdirectory"
,
"test.txt"
));
cl_git_pass
(
git_buf_joinpath
(
&
filename
,
dirname
.
ptr
,
"test.txt"
));
cl_git_pass
(
p_mkdir
(
dirname
.
ptr
,
0700
));
cl_git_mkfile
(
filename
.
ptr
,
"This is some content"
);
cl_git_pass
(
git_repository_index__weakptr
(
&
index
,
g_repo
));
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"subdirectory/test.txt"
));
cl_git_pass
(
p_unlink
(
filename
.
ptr
));
test_add_entry
(
index
,
valid_blob_id
,
filename
.
ptr
,
GIT_FILEMODE_BLOB
);
cl_git_pass
(
p_rmdir
(
dirname
.
ptr
));
cl_git_fail_with
(
git_submodule_add_setup
(
&
sm
,
g_repo
,
"./"
,
"subdirectory"
,
1
),
GIT_EEXISTS
);
cl_git_fail_with
(
git_submodule_add_setup
(
&
sm
,
g_repo
,
"./"
,
"subdirectory"
,
1
),
GIT_EEXISTS
);
git_submodule_free
(
sm
);
git_submodule_free
(
sm
);
git_buf_free
(
&
dirname
);
git_buf_free
(
&
filename
);
git_buf_free
(
&
filename
);
}
}
...
@@ -165,14 +174,9 @@ void test_submodule_add__file_exists_in_index(void)
...
@@ -165,14 +174,9 @@ void test_submodule_add__file_exists_in_index(void)
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
cl_git_pass
(
git_buf_joinpath
(
&
name
,
git_repository_workdir
(
g_repo
),
"subdirectory"
));
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_mkfile
(
name
.
ptr
,
"Test content"
);
cl_git_pass
(
git_repository_index__weakptr
(
&
index
,
g_repo
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"subdirectory"
));
cl_git_pass
(
p_unlink
(
name
.
ptr
)
);
test_add_entry
(
index
,
valid_blob_id
,
"subdirectory"
,
GIT_FILEMODE_BLOB
);
cl_git_fail_with
(
git_submodule_add_setup
(
&
sm
,
g_repo
,
"./"
,
"subdirectory"
,
1
),
GIT_EEXISTS
);
cl_git_fail_with
(
git_submodule_add_setup
(
&
sm
,
g_repo
,
"./"
,
"subdirectory"
,
1
),
GIT_EEXISTS
);
...
...
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