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
610cff13
Commit
610cff13
authored
Oct 09, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pr/3809'
parents
2468bf06
dc5cfdba
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
58 additions
and
13 deletions
+58
-13
src/diff_stats.c
+18
-10
tests/diff/format_email.c
+2
-2
tests/diff/stats.c
+36
-0
tests/resources/diff_format_email/.gitted/index
+0
-0
tests/resources/diff_format_email/.gitted/objects/06/b7b69a62cbd1e53c6c4e0c3f16473dcfdb4af6
+0
-0
tests/resources/diff_format_email/.gitted/objects/52/19b9784f9a92d7bd7cb567a6d6a21bfb86697e
+0
-0
tests/resources/diff_format_email/.gitted/objects/53/525d4cc3ef3ba4a5cbf69492fdffb4e4a74558
+0
-0
tests/resources/diff_format_email/.gitted/objects/a7/a65f98355b5a7567bcc395f6f7936c9252cf57
+0
-0
tests/resources/diff_format_email/.gitted/objects/c7/1a05d36025c806496a74d46d7d596eb23295c4
+0
-0
tests/resources/diff_format_email/.gitted/objects/d3/b6b38486f620b5b532a8cc6e0198ab7c3f52e4
+0
-0
tests/resources/diff_format_email/.gitted/refs/heads/master
+1
-1
tests/resources/diff_format_email/file3.txt
+1
-0
No files found.
src/diff_stats.c
View file @
610cff13
...
...
@@ -300,15 +300,24 @@ int git_diff_stats_to_buf(
}
if
(
format
&
GIT_DIFF_STATS_FULL
||
format
&
GIT_DIFF_STATS_SHORT
)
{
error
=
git_buf_printf
(
out
,
" %"
PRIuZ
" file%s changed, %"
PRIuZ
" insertion%s(+), %"
PRIuZ
" deletion%s(-)
\n
"
,
stats
->
files_changed
,
stats
->
files_changed
!=
1
?
"s"
:
""
,
stats
->
insertions
,
stats
->
insertions
!=
1
?
"s"
:
""
,
stats
->
deletions
,
stats
->
deletions
!=
1
?
"s"
:
""
);
if
(
error
<
0
)
return
error
;
git_buf_printf
(
out
,
" %"
PRIuZ
" file%s changed"
,
stats
->
files_changed
,
stats
->
files_changed
!=
1
?
"s"
:
""
);
if
(
stats
->
insertions
||
stats
->
deletions
==
0
)
git_buf_printf
(
out
,
", %"
PRIuZ
" insertion%s(+)"
,
stats
->
insertions
,
stats
->
insertions
!=
1
?
"s"
:
""
);
if
(
stats
->
deletions
||
stats
->
insertions
==
0
)
git_buf_printf
(
out
,
", %"
PRIuZ
" deletion%s(-)"
,
stats
->
deletions
,
stats
->
deletions
!=
1
?
"s"
:
""
);
git_buf_putc
(
out
,
'\n'
);
if
(
git_buf_oom
(
out
))
return
-
1
;
}
if
(
format
&
GIT_DIFF_STATS_INCLUDE_SUMMARY
)
{
...
...
@@ -334,4 +343,3 @@ void git_diff_stats_free(git_diff_stats *stats)
git__free
(
stats
->
filestats
);
git__free
(
stats
);
}
tests/diff/format_email.c
View file @
610cff13
...
...
@@ -113,7 +113,7 @@ void test_diff_format_email__with_message(void)
"Also test if new paragraphs are included correctly.
\n
"
\
"---
\n
"
\
" file3.txt | 1 +
\n
"
\
" 1 file changed, 1 insertion(+)
, 0 deletions(-)
\n
"
\
" 1 file changed, 1 insertion(+)
\n
"
\
"
\n
"
\
"diff --git a/file3.txt b/file3.txt
\n
"
\
"index 9a2d780..7309653 100644
\n
"
\
...
...
@@ -156,7 +156,7 @@ void test_diff_format_email__multiple(void)
"---
\n
"
\
" file2.txt | 5 +++++
\n
"
\
" file3.txt | 5 +++++
\n
"
\
" 2 files changed, 10 insertions(+)
, 0 deletions(-)
\n
"
\
" 2 files changed, 10 insertions(+)
\n
"
\
" create mode 100644 file2.txt
\n
"
\
" create mode 100644 file3.txt
\n
"
\
"
\n
"
\
...
...
tests/diff/stats.c
View file @
610cff13
...
...
@@ -114,6 +114,42 @@ void test_diff_stats__shortstat(void)
git_buf_free
(
&
buf
);
}
void
test_diff_stats__shortstat_noinsertions
(
void
)
{
git_buf
buf
=
GIT_BUF_INIT
;
const
char
*
stat
=
" 1 file changed, 2 deletions(-)
\n
"
;
diff_stats_from_commit_oid
(
&
_stats
,
"06b7b69a62cbd1e53c6c4e0c3f16473dcfdb4af6"
,
false
);
cl_assert_equal_sz
(
1
,
git_diff_stats_files_changed
(
_stats
));
cl_assert_equal_sz
(
0
,
git_diff_stats_insertions
(
_stats
));
cl_assert_equal_sz
(
2
,
git_diff_stats_deletions
(
_stats
));
cl_git_pass
(
git_diff_stats_to_buf
(
&
buf
,
_stats
,
GIT_DIFF_STATS_SHORT
,
0
));
cl_assert_equal_s
(
stat
,
git_buf_cstr
(
&
buf
));
git_buf_free
(
&
buf
);
}
void
test_diff_stats__shortstat_nodeletions
(
void
)
{
git_buf
buf
=
GIT_BUF_INIT
;
const
char
*
stat
=
" 1 file changed, 3 insertions(+)
\n
"
;
diff_stats_from_commit_oid
(
&
_stats
,
"5219b9784f9a92d7bd7cb567a6d6a21bfb86697e"
,
false
);
cl_assert_equal_sz
(
1
,
git_diff_stats_files_changed
(
_stats
));
cl_assert_equal_sz
(
3
,
git_diff_stats_insertions
(
_stats
));
cl_assert_equal_sz
(
0
,
git_diff_stats_deletions
(
_stats
));
cl_git_pass
(
git_diff_stats_to_buf
(
&
buf
,
_stats
,
GIT_DIFF_STATS_SHORT
,
0
));
cl_assert_equal_s
(
stat
,
git_buf_cstr
(
&
buf
));
git_buf_free
(
&
buf
);
}
void
test_diff_stats__rename
(
void
)
{
git_buf
buf
=
GIT_BUF_INIT
;
...
...
tests/resources/diff_format_email/.gitted/index
View file @
610cff13
No preview for this file type
tests/resources/diff_format_email/.gitted/objects/06/b7b69a62cbd1e53c6c4e0c3f16473dcfdb4af6
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/objects/52/19b9784f9a92d7bd7cb567a6d6a21bfb86697e
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/objects/53/525d4cc3ef3ba4a5cbf69492fdffb4e4a74558
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/objects/a7/a65f98355b5a7567bcc395f6f7936c9252cf57
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/objects/c7/1a05d36025c806496a74d46d7d596eb23295c4
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/objects/d3/b6b38486f620b5b532a8cc6e0198ab7c3f52e4
0 → 100644
View file @
610cff13
File added
tests/resources/diff_format_email/.gitted/refs/heads/master
View file @
610cff13
627e7e12d87e07a83fad5b6bfa25e86ead4a5270
5219b9784f9a92d7bd7cb567a6d6a21bfb86697e
tests/resources/diff_format_email/file3.txt
View file @
610cff13
...
...
@@ -4,3 +4,4 @@ file3
file3
file3
file3
file3
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