Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
4581f402
G
git
项目概览
李少辉-开发者
/
git
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
git
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4581f402
编写于
4月 19, 2008
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jc/dirstat'
* jc/dirstat: diff: make --dirstat binary-file safe
上级
a2fa254b
c04a7155
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
60 addition
and
23 deletion
+60
-23
diff.c
diff.c
+60
-23
未找到文件。
diff.c
浏览文件 @
4581f402
...
...
@@ -991,18 +991,23 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
}
}
struct
diffstat_dir
{
struct
diffstat_file
**
files
;
int
nr
,
percent
,
cumulative
;
struct
dirstat_file
{
const
char
*
name
;
unsigned
long
changed
;
};
struct
dirstat_dir
{
struct
dirstat_file
*
files
;
int
alloc
,
nr
,
percent
,
cumulative
;
};
static
long
gather_dirstat
(
FILE
*
file
,
struct
di
ff
stat_dir
*
dir
,
unsigned
long
changed
,
const
char
*
base
,
int
baselen
)
static
long
gather_dirstat
(
FILE
*
file
,
struct
di
r
stat_dir
*
dir
,
unsigned
long
changed
,
const
char
*
base
,
int
baselen
)
{
unsigned
long
this_dir
=
0
;
unsigned
int
sources
=
0
;
while
(
dir
->
nr
)
{
struct
di
ffstat_file
*
f
=
*
dir
->
files
;
struct
di
rstat_file
*
f
=
dir
->
files
;
int
namelen
=
strlen
(
f
->
name
);
unsigned
long
this
;
char
*
slash
;
...
...
@@ -1017,10 +1022,7 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
this
=
gather_dirstat
(
file
,
dir
,
changed
,
f
->
name
,
newbaselen
);
sources
++
;
}
else
{
if
(
f
->
is_unmerged
||
f
->
is_binary
)
this
=
0
;
else
this
=
f
->
added
+
f
->
deleted
;
this
=
f
->
changed
;
dir
->
files
++
;
dir
->
nr
--
;
sources
+=
2
;
...
...
@@ -1048,19 +1050,58 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
return
this_dir
;
}
static
void
show_dirstat
(
struct
diff
stat_t
*
data
,
struct
diff
_options
*
options
)
static
void
show_dirstat
(
struct
diff_options
*
options
)
{
int
i
;
unsigned
long
changed
;
struct
diffstat_dir
dir
;
struct
dirstat_dir
dir
;
struct
diff_queue_struct
*
q
=
&
diff_queued_diff
;
dir
.
files
=
NULL
;
dir
.
alloc
=
0
;
dir
.
nr
=
0
;
dir
.
percent
=
options
->
dirstat_percent
;
dir
.
cumulative
=
options
->
output_format
&
DIFF_FORMAT_CUMULATIVE
;
/* Calculate total changes */
changed
=
0
;
for
(
i
=
0
;
i
<
data
->
nr
;
i
++
)
{
if
(
data
->
files
[
i
]
->
is_binary
||
data
->
files
[
i
]
->
is_unmerged
)
for
(
i
=
0
;
i
<
q
->
nr
;
i
++
)
{
struct
diff_filepair
*
p
=
q
->
queue
[
i
];
const
char
*
name
;
unsigned
long
copied
,
added
,
damage
;
name
=
p
->
one
->
path
?
p
->
one
->
path
:
p
->
two
->
path
;
if
(
DIFF_FILE_VALID
(
p
->
one
)
&&
DIFF_FILE_VALID
(
p
->
two
))
{
diff_populate_filespec
(
p
->
one
,
0
);
diff_populate_filespec
(
p
->
two
,
0
);
diffcore_count_changes
(
p
->
one
,
p
->
two
,
NULL
,
NULL
,
0
,
&
copied
,
&
added
);
diff_free_filespec_data
(
p
->
one
);
diff_free_filespec_data
(
p
->
two
);
}
else
if
(
DIFF_FILE_VALID
(
p
->
one
))
{
diff_populate_filespec
(
p
->
one
,
1
);
copied
=
added
=
0
;
diff_free_filespec_data
(
p
->
one
);
}
else
if
(
DIFF_FILE_VALID
(
p
->
two
))
{
diff_populate_filespec
(
p
->
two
,
1
);
copied
=
0
;
added
=
p
->
two
->
size
;
diff_free_filespec_data
(
p
->
two
);
}
else
continue
;
changed
+=
data
->
files
[
i
]
->
added
;
changed
+=
data
->
files
[
i
]
->
deleted
;
/*
* Original minus copied is the removed material,
* added is the new material. They are both damages
* made to the preimage.
*/
damage
=
(
p
->
one
->
size
-
copied
)
+
added
;
ALLOC_GROW
(
dir
.
files
,
dir
.
nr
+
1
,
dir
.
alloc
);
dir
.
files
[
dir
.
nr
].
name
=
name
;
dir
.
files
[
dir
.
nr
].
changed
=
damage
;
changed
+=
damage
;
dir
.
nr
++
;
}
/* This can happen even with many files, if everything was renames */
...
...
@@ -1068,10 +1109,6 @@ static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
return
;
/* Show all directories with more than x% of the changes */
dir
.
files
=
data
->
files
;
dir
.
nr
=
data
->
nr
;
dir
.
percent
=
options
->
dirstat_percent
;
dir
.
cumulative
=
options
->
output_format
&
DIFF_FORMAT_CUMULATIVE
;
gather_dirstat
(
options
->
file
,
&
dir
,
changed
,
""
,
0
);
}
...
...
@@ -3095,7 +3132,7 @@ void diff_flush(struct diff_options *options)
separator
++
;
}
if
(
output_format
&
(
DIFF_FORMAT_DIFFSTAT
|
DIFF_FORMAT_SHORTSTAT
|
DIFF_FORMAT_NUMSTAT
|
DIFF_FORMAT_DIRSTAT
))
{
if
(
output_format
&
(
DIFF_FORMAT_DIFFSTAT
|
DIFF_FORMAT_SHORTSTAT
|
DIFF_FORMAT_NUMSTAT
))
{
struct
diffstat_t
diffstat
;
memset
(
&
diffstat
,
0
,
sizeof
(
struct
diffstat_t
));
...
...
@@ -3105,8 +3142,6 @@ void diff_flush(struct diff_options *options)
if
(
check_pair_status
(
p
))
diff_flush_stat
(
p
,
options
,
&
diffstat
);
}
if
(
output_format
&
DIFF_FORMAT_DIRSTAT
)
show_dirstat
(
&
diffstat
,
options
);
if
(
output_format
&
DIFF_FORMAT_NUMSTAT
)
show_numstat
(
&
diffstat
,
options
);
if
(
output_format
&
DIFF_FORMAT_DIFFSTAT
)
...
...
@@ -3116,6 +3151,8 @@ void diff_flush(struct diff_options *options)
free_diffstat_info
(
&
diffstat
);
separator
++
;
}
if
(
output_format
&
DIFF_FORMAT_DIRSTAT
)
show_dirstat
(
options
);
if
(
output_format
&
DIFF_FORMAT_SUMMARY
&&
!
is_summary_empty
(
q
))
{
for
(
i
=
0
;
i
<
q
->
nr
;
i
++
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录