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
9aade20b
Commit
9aade20b
authored
Feb 09, 2022
by
Iliyas Jorio
Committed by
Edward Thomson
Feb 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diff_file: test workdir file becomes empty after obtaining a diff
parent
3bac68ff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
tests/diff/externalmodifications.c
+29
-0
No files found.
tests/diff/externalmodifications.c
View file @
9aade20b
...
...
@@ -51,6 +51,35 @@ void test_diff_externalmodifications__file_becomes_smaller(void)
git_str_dispose
(
&
path
);
}
void
test_diff_externalmodifications__file_becomes_empty
(
void
)
{
git_index
*
index
;
git_diff
*
diff
;
git_patch
*
patch
;
git_str
path
=
GIT_STR_INIT
;
cl_git_pass
(
git_str_joinpath
(
&
path
,
git_repository_workdir
(
g_repo
),
"README"
));
/* Modify the file */
cl_git_mkfile
(
path
.
ptr
,
"hello"
);
/* Get a diff */
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
g_repo
,
index
,
NULL
));
cl_assert_equal_i
(
1
,
git_diff_num_deltas
(
diff
));
cl_assert_equal_i
(
5
,
git_diff_get_delta
(
diff
,
0
)
->
new_file
.
size
);
/* Empty out the file after we've gotten the diff */
cl_git_mkfile
(
path
.
ptr
,
""
);
/* Attempt to get a patch */
cl_git_fail
(
git_patch_from_diff
(
&
patch
,
diff
,
0
));
git_index_free
(
index
);
git_diff_free
(
diff
);
git_str_dispose
(
&
path
);
}
void
test_diff_externalmodifications__file_deleted
(
void
)
{
git_index
*
index
;
...
...
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