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
4117a235
Commit
4117a235
authored
Sep 24, 2015
by
Edward Thomson
Committed by
Edward Thomson
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch parse: dup the patch from the callers
parent
6278fbc5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
src/patch.c
+0
-6
src/patch_diff.c
+6
-0
src/patch_parse.c
+21
-4
No files found.
src/patch.c
View file @
4117a235
...
@@ -196,12 +196,6 @@ int git_patch_get_line_in_hunk(
...
@@ -196,12 +196,6 @@ int git_patch_get_line_in_hunk(
static
void
git_patch__free
(
git_patch
*
patch
)
static
void
git_patch__free
(
git_patch
*
patch
)
{
{
git_array_clear
(
patch
->
lines
);
git_array_clear
(
patch
->
hunks
);
git__free
((
char
*
)
patch
->
binary
.
old_file
.
data
);
git__free
((
char
*
)
patch
->
binary
.
new_file
.
data
);
if
(
patch
->
free_fn
)
if
(
patch
->
free_fn
)
patch
->
free_fn
(
patch
);
patch
->
free_fn
(
patch
);
}
}
...
...
src/patch_diff.c
View file @
4117a235
...
@@ -25,6 +25,12 @@ static void patch_diff_free(git_patch *p)
...
@@ -25,6 +25,12 @@ static void patch_diff_free(git_patch *p)
{
{
git_patch_diff
*
patch
=
(
git_patch_diff
*
)
p
;
git_patch_diff
*
patch
=
(
git_patch_diff
*
)
p
;
git_array_clear
(
patch
->
base
.
lines
);
git_array_clear
(
patch
->
base
.
hunks
);
git__free
((
char
*
)
patch
->
base
.
binary
.
old_file
.
data
);
git__free
((
char
*
)
patch
->
base
.
binary
.
new_file
.
data
);
git_diff_file_content__clear
(
&
patch
->
ofile
);
git_diff_file_content__clear
(
&
patch
->
ofile
);
git_diff_file_content__clear
(
&
patch
->
nfile
);
git_diff_file_content__clear
(
&
patch
->
nfile
);
...
...
src/patch_parse.c
View file @
4117a235
...
@@ -10,6 +10,10 @@ typedef struct {
...
@@ -10,6 +10,10 @@ typedef struct {
git_patch_options
opts
;
git_patch_options
opts
;
/* the patch contents, which lines will point into. */
/* TODO: allow us to point somewhere refcounted. */
char
*
content
;
/* the paths from the `diff --git` header, these will be used if this is not
/* the paths from the `diff --git` header, these will be used if this is not
* a rename (and rename paths are specified) or if no `+++`/`---` line specify
* a rename (and rename paths are specified) or if no `+++`/`---` line specify
* the paths.
* the paths.
...
@@ -931,6 +935,12 @@ static void patch_parsed__free(git_patch *p)
...
@@ -931,6 +935,12 @@ static void patch_parsed__free(git_patch *p)
if
(
!
patch
)
if
(
!
patch
)
return
;
return
;
git__free
((
char
*
)
patch
->
base
.
binary
.
old_file
.
data
);
git__free
((
char
*
)
patch
->
base
.
binary
.
new_file
.
data
);
git_array_clear
(
patch
->
base
.
hunks
);
git_array_clear
(
patch
->
base
.
lines
);
git__free
(
patch
->
base
.
delta
);
git__free
(
patch
->
old_prefix
);
git__free
(
patch
->
old_prefix
);
git__free
(
patch
->
new_prefix
);
git__free
(
patch
->
new_prefix
);
git__free
(
patch
->
header_old_path
);
git__free
(
patch
->
header_old_path
);
...
@@ -939,9 +949,7 @@ static void patch_parsed__free(git_patch *p)
...
@@ -939,9 +949,7 @@ static void patch_parsed__free(git_patch *p)
git__free
(
patch
->
rename_new_path
);
git__free
(
patch
->
rename_new_path
);
git__free
(
patch
->
old_path
);
git__free
(
patch
->
old_path
);
git__free
(
patch
->
new_path
);
git__free
(
patch
->
new_path
);
git_array_clear
(
patch
->
base
.
hunks
);
git__free
(
patch
->
content
);
git_array_clear
(
patch
->
base
.
lines
);
git__free
(
patch
->
base
.
delta
);
git__free
(
patch
);
git__free
(
patch
);
}
}
...
@@ -969,10 +977,19 @@ int git_patch_from_patchfile(
...
@@ -969,10 +977,19 @@ int git_patch_from_patchfile(
patch
->
base
.
free_fn
=
patch_parsed__free
;
patch
->
base
.
free_fn
=
patch_parsed__free
;
patch
->
base
.
delta
=
git__calloc
(
1
,
sizeof
(
git_diff_delta
));
patch
->
base
.
delta
=
git__calloc
(
1
,
sizeof
(
git_diff_delta
));
GITERR_CHECK_ALLOC
(
patch
->
base
.
delta
);
patch
->
base
.
delta
->
status
=
GIT_DELTA_MODIFIED
;
patch
->
base
.
delta
->
status
=
GIT_DELTA_MODIFIED
;
patch
->
base
.
delta
->
nfiles
=
2
;
patch
->
base
.
delta
->
nfiles
=
2
;
ctx
.
content
=
content
;
if
(
content_len
)
{
patch
->
content
=
git__malloc
(
content_len
);
GITERR_CHECK_ALLOC
(
patch
->
content
);
memcpy
(
patch
->
content
,
content
,
content_len
);
}
ctx
.
content
=
patch
->
content
;
ctx
.
content_len
=
content_len
;
ctx
.
content_len
=
content_len
;
ctx
.
remain
=
content_len
;
ctx
.
remain
=
content_len
;
...
...
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