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
19e46645
Commit
19e46645
authored
Sep 23, 2015
by
Edward Thomson
Committed by
Edward Thomson
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch printing: include rename information
parent
d536ceac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
src/diff_print.c
+23
-0
src/patch_parse.c
+2
-2
No files found.
src/diff_print.c
View file @
19e46645
...
...
@@ -322,6 +322,26 @@ static int diff_delta_format_with_paths(
return
git_buf_printf
(
out
,
template
,
oldpfx
,
oldpath
,
newpfx
,
newpath
);
}
int
diff_delta_format_rename_header
(
git_buf
*
out
,
const
git_diff_delta
*
delta
)
{
if
(
delta
->
similarity
>
100
)
{
giterr_set
(
GITERR_PATCH
,
"invalid similarity %d"
,
delta
->
similarity
);
return
-
1
;
}
git_buf_printf
(
out
,
"similarity index %d%%
\n
"
"rename from %s
\n
"
"rename to %s
\n
"
,
delta
->
similarity
,
delta
->
old_file
.
path
,
delta
->
new_file
.
path
);
return
git_buf_oom
(
out
)
?
-
1
:
0
;
}
int
git_diff_delta__format_file_header
(
git_buf
*
out
,
const
git_diff_delta
*
delta
,
...
...
@@ -341,6 +361,9 @@ int git_diff_delta__format_file_header(
git_buf_printf
(
out
,
"diff --git %s%s %s%s
\n
"
,
oldpfx
,
delta
->
old_file
.
path
,
newpfx
,
delta
->
new_file
.
path
);
if
(
delta
->
status
==
GIT_DELTA_RENAMED
)
GITERR_CHECK_ERROR
(
diff_delta_format_rename_header
(
out
,
delta
));
GITERR_CHECK_ERROR
(
diff_print_oid_range
(
out
,
delta
,
oid_strlen
));
if
((
delta
->
flags
&
GIT_DIFF_FLAG_BINARY
)
==
0
)
...
...
src/patch_parse.c
View file @
19e46645
...
...
@@ -306,7 +306,7 @@ static int parse_header_rename(
static
int
parse_header_renamefrom
(
git_patch_parsed
*
patch
,
patch_parse_ctx
*
ctx
)
{
patch
->
base
.
delta
->
status
|
=
GIT_DELTA_RENAMED
;
patch
->
base
.
delta
->
status
=
GIT_DELTA_RENAMED
;
return
parse_header_rename
(
(
char
**
)
&
patch
->
base
.
delta
->
old_file
.
path
,
...
...
@@ -317,7 +317,7 @@ static int parse_header_renamefrom(
static
int
parse_header_renameto
(
git_patch_parsed
*
patch
,
patch_parse_ctx
*
ctx
)
{
patch
->
base
.
delta
->
status
|
=
GIT_DELTA_RENAMED
;
patch
->
base
.
delta
->
status
=
GIT_DELTA_RENAMED
;
return
parse_header_rename
(
(
char
**
)
&
patch
->
base
.
delta
->
new_file
.
path
,
...
...
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