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
e8993455
Commit
e8993455
authored
Aug 15, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diff: Enhance tree-to-tree diff test coverage
These tests are related to issue libgit2/libgit2sharp#196
parent
7e858045
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
0 deletions
+109
-0
tests-clar/diff/tree.c
+109
-0
No files found.
tests-clar/diff/tree.c
View file @
e8993455
...
...
@@ -25,6 +25,7 @@ void test_diff_tree__cleanup(void)
git_tree_free
(
b
);
cl_git_sandbox_cleanup
();
}
void
test_diff_tree__0
(
void
)
...
...
@@ -320,3 +321,111 @@ void test_diff_tree__checks_options_version(void)
cl_git_fail
(
git_diff_tree_to_tree
(
&
diff
,
g_repo
,
a
,
b
,
&
opts
));
err
=
giterr_last
();
}
void
process_tree_to_tree_diffing
(
const
char
*
old_commit
,
const
char
*
new_commit
)
{
g_repo
=
cl_git_sandbox_init
(
"unsymlinked.git"
);
cl_assert
((
a
=
resolve_commit_oid_to_tree
(
g_repo
,
old_commit
))
!=
NULL
);
cl_assert
((
b
=
resolve_commit_oid_to_tree
(
g_repo
,
new_commit
))
!=
NULL
);
cl_git_pass
(
git_diff_tree_to_tree
(
&
diff
,
g_repo
,
a
,
b
,
&
opts
));
cl_git_pass
(
git_diff_foreach
(
diff
,
diff_file_cb
,
NULL
,
NULL
,
&
exp
));
}
void
test_diff_tree__symlink_blob_mode_changed_to_regular_file
(
void
)
{
/*
* $ git diff 7fccd7..806999
* diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
* deleted file mode 120000
* index 19bf568..0000000
* --- a/include/Nu/Nu.h
* +++ /dev/null
* @@ -1 +0,0 @@
* -../../objc/Nu.h
* \ No newline at end of file
* diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
* new file mode 100644
* index 0000000..f9e6561
* --- /dev/null
* +++ b/include/Nu/Nu.h
* @@ -0,0 +1 @@
* +awesome content
* diff --git a/objc/Nu.h b/objc/Nu.h
* deleted file mode 100644
* index f9e6561..0000000
* --- a/objc/Nu.h
* +++ /dev/null
* @@ -1 +0,0 @@
* -awesome content
*/
process_tree_to_tree_diffing
(
"7fccd7"
,
"806999"
);
cl_assert_equal_i
(
3
,
exp
.
files
);
cl_assert_equal_i
(
2
,
exp
.
file_status
[
GIT_DELTA_DELETED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_MODIFIED
]);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_ADDED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_TYPECHANGE
]);
}
void
test_diff_tree__symlink_blob_mode_changed_to_regular_file_as_typechange
(
void
)
{
/*
* $ git diff 7fccd7..a8595c
* diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
* deleted file mode 120000
* index 19bf568..0000000
* --- a/include/Nu/Nu.h
* +++ /dev/null
* @@ -1 +0,0 @@
* -../../objc/Nu.h
* \ No newline at end of file
* diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
* new file mode 100755
* index 0000000..f9e6561
* --- /dev/null
* +++ b/include/Nu/Nu.h
* @@ -0,0 +1 @@
* +awesome content
* diff --git a/objc/Nu.h b/objc/Nu.h
* deleted file mode 100644
* index f9e6561..0000000
* --- a/objc/Nu.h
* +++ /dev/null
* @@ -1 +0,0 @@
* -awesome content
*/
opts
.
flags
=
GIT_DIFF_INCLUDE_TYPECHANGE
;
process_tree_to_tree_diffing
(
"7fccd7"
,
"a8595c"
);
cl_assert_equal_i
(
2
,
exp
.
files
);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_DELETED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_MODIFIED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_ADDED
]);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_TYPECHANGE
]);
}
void
test_diff_tree__regular_blob_mode_changed_to_executable_file
(
void
)
{
/*
* $ git diff 806999..a8595c
* diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
* old mode 100644
* new mode 100755
*/
process_tree_to_tree_diffing
(
"806999"
,
"a8595c"
);
cl_assert_equal_i
(
1
,
exp
.
files
);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_DELETED
]);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_MODIFIED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_ADDED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_TYPECHANGE
]);
}
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