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
0004386f
Commit
0004386f
authored
Jun 17, 2015
by
Edward Thomson
Committed by
Edward Thomson
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply: handle empty patches
When a patch is empty, simply copy the source into the destination.
parent
d34f6826
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
src/apply.c
+4
-1
tests/apply/fromdiff.c
+8
-0
No files found.
src/apply.c
View file @
0004386f
...
...
@@ -262,7 +262,10 @@ int git_apply__patch(
patch
->
nfile
.
file
->
mode
:
GIT_FILEMODE_BLOB
;
}
if
((
error
=
apply_hunks
(
contents_out
,
source
,
source_len
,
patch
))
<
0
)
/* If the patch is empty, simply keep the source unchanged */
if
(
patch
->
hunks
.
size
==
0
)
git_buf_put
(
contents_out
,
source
,
source_len
);
else
if
((
error
=
apply_hunks
(
contents_out
,
source
,
source_len
,
patch
))
<
0
)
goto
done
;
if
(
patch
->
delta
->
status
==
GIT_DELTA_DELETED
&&
...
...
tests/apply/fromdiff.c
View file @
0004386f
...
...
@@ -174,3 +174,11 @@ void test_apply_fromdiff__delete(void)
NULL
,
NULL
,
PATCH_DELETE_ORIGINAL
,
NULL
));
}
void
test_apply_fromdiff__no_change
(
void
)
{
cl_git_pass
(
apply_buf
(
FILE_ORIGINAL
,
"file.txt"
,
FILE_ORIGINAL
,
"file.txt"
,
""
,
NULL
));
}
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