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
c6320bec
Commit
c6320bec
authored
May 17, 2014
by
Philip Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print_binary_hunk: Treat types with respect
parent
bf6a5b61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
src/diff_print.c
+24
-7
No files found.
src/diff_print.c
View file @
c6320bec
...
...
@@ -286,7 +286,9 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
{
git_buf
deflate
=
GIT_BUF_INIT
,
delta
=
GIT_BUF_INIT
,
*
out
=
NULL
;
const
void
*
old_data
,
*
new_data
;
size_t
old_data_len
,
new_data_len
,
delta_data_len
,
inflated_len
,
remain
;
git_off_t
off_t_old_data_len
,
off_t_new_data_len
;
unsigned
long
old_data_len
,
new_data_len
,
delta_data_len
,
inflated_len
;
size_t
remain
;
const
char
*
out_type
=
"literal"
;
char
*
ptr
;
int
error
;
...
...
@@ -294,8 +296,17 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
old_data
=
old
?
git_blob_rawcontent
(
old
)
:
NULL
;
new_data
=
new
?
git_blob_rawcontent
(
new
)
:
NULL
;
old_data_len
=
old
?
(
size_t
)
git_blob_rawsize
(
old
)
:
0
;
new_data_len
=
new
?
(
size_t
)
git_blob_rawsize
(
new
)
:
0
;
off_t_old_data_len
=
old
?
git_blob_rawsize
(
old
)
:
0
;
off_t_new_data_len
=
new
?
git_blob_rawsize
(
new
)
:
0
;
/* The git_delta function accepts unsigned long only */
if
(
off_t_old_data_len
>
ULONG_MAX
||
off_t_new_data_len
>
ULONG_MAX
)
{
error
=
-
1
;
goto
done
;
}
old_data_len
=
(
unsigned
long
)
off_t_old_data_len
;
new_data_len
=
(
unsigned
long
)
off_t_new_data_len
;
out
=
&
deflate
;
inflated_len
=
new_data_len
;
...
...
@@ -304,11 +315,17 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
&
deflate
,
new_data
,
new_data_len
))
<
0
)
goto
done
;
/* The git_delta function accepts unsigned long only */
if
(
deflate
.
size
>
ULONG_MAX
)
{
error
=
-
1
;
goto
done
;
}
if
(
old
&&
new
)
{
void
*
delta_data
;
delta_data
=
git_delta
(
old_data
,
old_data_len
,
new_data
,
new_data_len
,
&
delta_data_len
,
deflate
.
size
);
new_data_len
,
&
delta_data_len
,
(
unsigned
long
)
deflate
.
size
);
if
(
delta_data
)
{
error
=
git_zstream_deflatebuf
(
&
delta
,
delta_data
,
delta_data_len
);
...
...
@@ -325,16 +342,16 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
}
}
git_buf_printf
(
pi
->
buf
,
"%s %
"
PRIuZ
"
\n
"
,
out_type
,
inflated_len
);
git_buf_printf
(
pi
->
buf
,
"%s %
u
\n
"
,
out_type
,
inflated_len
);
pi
->
line
.
num_lines
++
;
for
(
ptr
=
out
->
ptr
,
remain
=
out
->
size
;
remain
>
0
;
)
{
size_t
chunk_len
=
(
52
<
remain
)
?
52
:
remain
;
if
(
chunk_len
<=
26
)
git_buf_putc
(
pi
->
buf
,
chunk_len
+
'A'
-
1
);
git_buf_putc
(
pi
->
buf
,
(
char
)
chunk_len
+
'A'
-
1
);
else
git_buf_putc
(
pi
->
buf
,
chunk_len
-
26
+
'a'
-
1
);
git_buf_putc
(
pi
->
buf
,
(
char
)
chunk_len
-
26
+
'a'
-
1
);
git_buf_put_base85
(
pi
->
buf
,
ptr
,
chunk_len
);
git_buf_putc
(
pi
->
buf
,
'\n'
);
...
...
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