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
c79f9dae
Commit
c79f9dae
authored
Mar 29, 2019
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch_parse: improve formatting
parent
1df7d27a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
src/patch_parse.c
+12
-18
No files found.
src/patch_parse.c
View file @
c79f9dae
...
...
@@ -921,21 +921,15 @@ static int check_filenames(git_patch_parsed *patch)
return
git_parse_err
(
"missing old path"
);
/* Ensure (non-renamed) paths match */
if
(
check_header_names
(
patch
->
header_old_path
,
patch
->
old_path
,
"old"
,
added
)
<
0
||
check_header_names
(
patch
->
header_new_path
,
patch
->
new_path
,
"new"
,
deleted
)
<
0
)
if
(
check_header_names
(
patch
->
header_old_path
,
patch
->
old_path
,
"old"
,
added
)
<
0
||
check_header_names
(
patch
->
header_new_path
,
patch
->
new_path
,
"new"
,
deleted
)
<
0
)
return
-
1
;
prefixed_old
=
(
!
added
&&
patch
->
old_path
)
?
patch
->
old_path
:
patch
->
header_old_path
;
prefixed_new
=
(
!
deleted
&&
patch
->
new_path
)
?
patch
->
new_path
:
patch
->
header_new_path
;
prefixed_old
=
(
!
added
&&
patch
->
old_path
)
?
patch
->
old_path
:
patch
->
header_old_path
;
prefixed_new
=
(
!
deleted
&&
patch
->
new_path
)
?
patch
->
new_path
:
patch
->
header_new_path
;
if
(
check_prefix
(
&
patch
->
old_prefix
,
&
old_prefixlen
,
patch
,
prefixed_old
)
<
0
||
check_prefix
(
&
patch
->
new_prefix
,
&
new_prefixlen
,
patch
,
prefixed_new
)
<
0
)
if
(
check_prefix
(
&
patch
->
old_prefix
,
&
old_prefixlen
,
patch
,
prefixed_old
)
<
0
||
check_prefix
(
&
patch
->
new_prefix
,
&
new_prefixlen
,
patch
,
prefixed_new
)
<
0
)
return
-
1
;
/* Prefer the rename filenames as they are unambiguous and unprefixed */
...
...
@@ -950,7 +944,7 @@ static int check_filenames(git_patch_parsed *patch)
patch
->
base
.
delta
->
new_file
.
path
=
prefixed_new
+
new_prefixlen
;
if
(
!
patch
->
base
.
delta
->
old_file
.
path
&&
!
patch
->
base
.
delta
->
new_file
.
path
)
!
patch
->
base
.
delta
->
new_file
.
path
)
return
git_parse_err
(
"git diff header lacks old / new paths"
);
return
0
;
...
...
@@ -964,14 +958,14 @@ static int check_patch(git_patch_parsed *patch)
return
-
1
;
if
(
delta
->
old_file
.
path
&&
delta
->
status
!=
GIT_DELTA_DELETED
&&
!
delta
->
new_file
.
mode
)
delta
->
status
!=
GIT_DELTA_DELETED
&&
!
delta
->
new_file
.
mode
)
delta
->
new_file
.
mode
=
delta
->
old_file
.
mode
;
if
(
delta
->
status
==
GIT_DELTA_MODIFIED
&&
!
(
delta
->
flags
&
GIT_DIFF_FLAG_BINARY
)
&&
delta
->
new_file
.
mode
==
delta
->
old_file
.
mode
&&
git_array_size
(
patch
->
base
.
hunks
)
==
0
)
!
(
delta
->
flags
&
GIT_DIFF_FLAG_BINARY
)
&&
delta
->
new_file
.
mode
==
delta
->
old_file
.
mode
&&
git_array_size
(
patch
->
base
.
hunks
)
==
0
)
return
git_parse_err
(
"patch with no hunks"
);
if
(
delta
->
status
==
GIT_DELTA_ADDED
)
{
...
...
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