Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
92cdfd21
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,发现更多精彩内容 >>
提交
92cdfd21
编写于
9月 28, 2015
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jk/xdiff-memory-limits' into maint-2.3
上级
f2df3104
83c4d380
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
57 addition
and
26 deletion
+57
-26
builtin/blame.c
builtin/blame.c
+7
-2
builtin/merge-file.c
builtin/merge-file.c
+2
-1
builtin/merge-tree.c
builtin/merge-tree.c
+2
-1
builtin/rerere.c
builtin/rerere.c
+6
-4
combine-diff.c
combine-diff.c
+4
-2
diff.c
diff.c
+16
-10
diffcore-pickaxe.c
diffcore-pickaxe.c
+2
-2
line-log.c
line-log.c
+4
-3
ll-merge.c
ll-merge.c
+4
-1
xdiff-interface.c
xdiff-interface.c
+3
-0
xdiff-interface.h
xdiff-interface.h
+7
-0
未找到文件。
builtin/blame.c
浏览文件 @
92cdfd21
...
...
@@ -972,7 +972,10 @@ static void pass_blame_to_parent(struct scoreboard *sb,
fill_origin_blob
(
&
sb
->
revs
->
diffopt
,
target
,
&
file_o
);
num_get_patch
++
;
diff_hunks
(
&
file_p
,
&
file_o
,
0
,
blame_chunk_cb
,
&
d
);
if
(
diff_hunks
(
&
file_p
,
&
file_o
,
0
,
blame_chunk_cb
,
&
d
))
die
(
"unable to generate diff (%s -> %s)"
,
sha1_to_hex
(
parent
->
commit
->
object
.
sha1
),
sha1_to_hex
(
target
->
commit
->
object
.
sha1
));
/* The rest are the same as the parent */
blame_chunk
(
&
d
.
dstq
,
&
d
.
srcq
,
INT_MAX
,
d
.
offset
,
INT_MAX
,
parent
);
*
d
.
dstq
=
NULL
;
...
...
@@ -1118,7 +1121,9 @@ static void find_copy_in_blob(struct scoreboard *sb,
* file_p partially may match that image.
*/
memset
(
split
,
0
,
sizeof
(
struct
blame_entry
[
3
]));
diff_hunks
(
file_p
,
&
file_o
,
1
,
handle_split_cb
,
&
d
);
if
(
diff_hunks
(
file_p
,
&
file_o
,
1
,
handle_split_cb
,
&
d
))
die
(
"unable to generate diff (%s)"
,
sha1_to_hex
(
parent
->
commit
->
object
.
sha1
));
/* remainder, if any, all match the preimage */
handle_split
(
sb
,
ent
,
d
.
tlno
,
d
.
plno
,
ent
->
num_lines
,
parent
,
split
);
}
...
...
builtin/merge-file.c
浏览文件 @
92cdfd21
...
...
@@ -75,7 +75,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
names
[
i
]
=
argv
[
i
];
if
(
read_mmfile
(
mmfs
+
i
,
fname
))
return
-
1
;
if
(
buffer_is_binary
(
mmfs
[
i
].
ptr
,
mmfs
[
i
].
size
))
if
(
mmfs
[
i
].
size
>
MAX_XDIFF_SIZE
||
buffer_is_binary
(
mmfs
[
i
].
ptr
,
mmfs
[
i
].
size
))
return
error
(
"Cannot merge binary files: %s"
,
argv
[
i
]);
}
...
...
builtin/merge-tree.c
浏览文件 @
92cdfd21
...
...
@@ -118,7 +118,8 @@ static void show_diff(struct merge_list *entry)
if
(
!
dst
.
ptr
)
size
=
0
;
dst
.
size
=
size
;
xdi_diff
(
&
src
,
&
dst
,
&
xpp
,
&
xecfg
,
&
ecb
);
if
(
xdi_diff
(
&
src
,
&
dst
,
&
xpp
,
&
xecfg
,
&
ecb
))
die
(
"unable to generate diff"
);
free
(
src
.
ptr
);
free
(
dst
.
ptr
);
}
...
...
builtin/rerere.c
浏览文件 @
92cdfd21
...
...
@@ -29,9 +29,10 @@ static int diff_two(const char *file1, const char *label1,
xdemitconf_t
xecfg
;
xdemitcb_t
ecb
;
mmfile_t
minus
,
plus
;
int
ret
;
if
(
read_mmfile
(
&
minus
,
file1
)
||
read_mmfile
(
&
plus
,
file2
))
return
1
;
return
-
1
;
printf
(
"--- a/%s
\n
+++ b/%s
\n
"
,
label1
,
label2
);
fflush
(
stdout
);
...
...
@@ -40,11 +41,11 @@ static int diff_two(const char *file1, const char *label1,
memset
(
&
xecfg
,
0
,
sizeof
(
xecfg
));
xecfg
.
ctxlen
=
3
;
ecb
.
outf
=
outf
;
xdi_diff
(
&
minus
,
&
plus
,
&
xpp
,
&
xecfg
,
&
ecb
);
ret
=
xdi_diff
(
&
minus
,
&
plus
,
&
xpp
,
&
xecfg
,
&
ecb
);
free
(
minus
.
ptr
);
free
(
plus
.
ptr
);
return
0
;
return
ret
;
}
int
cmd_rerere
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
...
...
@@ -104,7 +105,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
for
(
i
=
0
;
i
<
merge_rr
.
nr
;
i
++
)
{
const
char
*
path
=
merge_rr
.
items
[
i
].
string
;
const
char
*
name
=
(
const
char
*
)
merge_rr
.
items
[
i
].
util
;
diff_two
(
rerere_path
(
name
,
"preimage"
),
path
,
path
,
path
);
if
(
diff_two
(
rerere_path
(
name
,
"preimage"
),
path
,
path
,
path
))
die
(
"unable to generate diff for %s"
,
name
);
}
else
usage_with_options
(
rerere_usage
,
options
);
...
...
combine-diff.c
浏览文件 @
92cdfd21
...
...
@@ -419,8 +419,10 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
state
.
num_parent
=
num_parent
;
state
.
n
=
n
;
xdi_diff_outf
(
&
parent_file
,
result_file
,
consume_line
,
&
state
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
parent_file
,
result_file
,
consume_line
,
&
state
,
&
xpp
,
&
xecfg
))
die
(
"unable to generate combined diff for %s"
,
sha1_to_hex
(
parent
));
free
(
parent_file
.
ptr
);
/* Assign line numbers for this parent.
...
...
diff.c
浏览文件 @
92cdfd21
...
...
@@ -1002,8 +1002,9 @@ static void diff_words_show(struct diff_words_data *diff_words)
xpp
.
flags
=
0
;
/* as only the hunk header will be parsed, we need a 0-context */
xecfg
.
ctxlen
=
0
;
xdi_diff_outf
(
&
minus
,
&
plus
,
fn_out_diff_words_aux
,
diff_words
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
minus
,
&
plus
,
fn_out_diff_words_aux
,
diff_words
,
&
xpp
,
&
xecfg
))
die
(
"unable to generate word diff"
);
free
(
minus
.
ptr
);
free
(
plus
.
ptr
);
if
(
diff_words
->
current_plus
!=
diff_words
->
plus
.
text
.
ptr
+
...
...
@@ -2400,8 +2401,9 @@ static void builtin_diff(const char *name_a,
xecfg
.
ctxlen
=
strtoul
(
v
,
NULL
,
10
);
if
(
o
->
word_diff
)
init_diff_words_data
(
&
ecbdata
,
o
,
one
,
two
);
xdi_diff_outf
(
&
mf1
,
&
mf2
,
fn_out_consume
,
&
ecbdata
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
mf1
,
&
mf2
,
fn_out_consume
,
&
ecbdata
,
&
xpp
,
&
xecfg
))
die
(
"unable to generate diff for %s"
,
one
->
path
);
if
(
o
->
word_diff
)
free_diff_words_data
(
&
ecbdata
);
if
(
textconv_one
)
...
...
@@ -2478,8 +2480,9 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
xpp
.
flags
=
o
->
xdl_opts
;
xecfg
.
ctxlen
=
o
->
context
;
xecfg
.
interhunkctxlen
=
o
->
interhunkcontext
;
xdi_diff_outf
(
&
mf1
,
&
mf2
,
diffstat_consume
,
diffstat
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
mf1
,
&
mf2
,
diffstat_consume
,
diffstat
,
&
xpp
,
&
xecfg
))
die
(
"unable to generate diffstat for %s"
,
one
->
path
);
}
diff_free_filespec_data
(
one
);
...
...
@@ -2525,8 +2528,9 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
memset
(
&
xecfg
,
0
,
sizeof
(
xecfg
));
xecfg
.
ctxlen
=
1
;
/* at least one context line */
xpp
.
flags
=
0
;
xdi_diff_outf
(
&
mf1
,
&
mf2
,
checkdiff_consume
,
&
data
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
mf1
,
&
mf2
,
checkdiff_consume
,
&
data
,
&
xpp
,
&
xecfg
))
die
(
"unable to generate checkdiff for %s"
,
one
->
path
);
if
(
data
.
ws_rule
&
WS_BLANK_AT_EOF
)
{
struct
emit_callback
ecbdata
;
...
...
@@ -4425,8 +4429,10 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
xpp
.
flags
=
0
;
xecfg
.
ctxlen
=
3
;
xecfg
.
flags
=
0
;
xdi_diff_outf
(
&
mf1
,
&
mf2
,
patch_id_consume
,
&
data
,
&
xpp
,
&
xecfg
);
if
(
xdi_diff_outf
(
&
mf1
,
&
mf2
,
patch_id_consume
,
&
data
,
&
xpp
,
&
xecfg
))
return
error
(
"unable to generate patch-id diff for %s"
,
p
->
one
->
path
);
}
git_SHA1_Final
(
sha1
,
&
ctx
);
...
...
diffcore-pickaxe.c
浏览文件 @
92cdfd21
...
...
@@ -62,8 +62,8 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,
ecbdata
.
hit
=
0
;
xecfg
.
ctxlen
=
o
->
context
;
xecfg
.
interhunkctxlen
=
o
->
interhunkcontext
;
xdi_diff_outf
(
one
,
two
,
diffgrep_consume
,
&
ecbdata
,
&
xpp
,
&
xecfg
)
;
if
(
xdi_diff_outf
(
one
,
two
,
diffgrep_consume
,
&
ecbdata
,
&
xpp
,
&
xecfg
))
return
0
;
return
ecbdata
.
hit
;
}
...
...
line-log.c
浏览文件 @
92cdfd21
...
...
@@ -325,7 +325,7 @@ static int collect_diff_cb(long start_a, long count_a,
return
0
;
}
static
void
collect_diff
(
mmfile_t
*
parent
,
mmfile_t
*
target
,
struct
diff_ranges
*
out
)
static
int
collect_diff
(
mmfile_t
*
parent
,
mmfile_t
*
target
,
struct
diff_ranges
*
out
)
{
struct
collect_diff_cbdata
cbdata
=
{
NULL
};
xpparam_t
xpp
;
...
...
@@ -340,7 +340,7 @@ static void collect_diff(mmfile_t *parent, mmfile_t *target, struct diff_ranges
xecfg
.
hunk_func
=
collect_diff_cb
;
memset
(
&
ecb
,
0
,
sizeof
(
ecb
));
ecb
.
priv
=
&
cbdata
;
xdi_diff
(
parent
,
target
,
&
xpp
,
&
xecfg
,
&
ecb
);
return
xdi_diff
(
parent
,
target
,
&
xpp
,
&
xecfg
,
&
ecb
);
}
/*
...
...
@@ -1030,7 +1030,8 @@ static int process_diff_filepair(struct rev_info *rev,
}
diff_ranges_init
(
&
diff
);
collect_diff
(
&
file_parent
,
&
file_target
,
&
diff
);
if
(
collect_diff
(
&
file_parent
,
&
file_target
,
&
diff
))
die
(
"unable to generate diff for %s"
,
pair
->
one
->
path
);
/* NEEDSWORK should apply some heuristics to prevent mismatches */
free
(
rg
->
path
);
...
...
ll-merge.c
浏览文件 @
92cdfd21
...
...
@@ -88,7 +88,10 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
xmparam_t
xmp
;
assert
(
opts
);
if
(
buffer_is_binary
(
orig
->
ptr
,
orig
->
size
)
||
if
(
orig
->
size
>
MAX_XDIFF_SIZE
||
src1
->
size
>
MAX_XDIFF_SIZE
||
src2
->
size
>
MAX_XDIFF_SIZE
||
buffer_is_binary
(
orig
->
ptr
,
orig
->
size
)
||
buffer_is_binary
(
src1
->
ptr
,
src1
->
size
)
||
buffer_is_binary
(
src2
->
ptr
,
src2
->
size
))
{
return
ll_binary_merge
(
drv_unused
,
result
,
...
...
xdiff-interface.c
浏览文件 @
92cdfd21
...
...
@@ -131,6 +131,9 @@ int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t co
mmfile_t
a
=
*
mf1
;
mmfile_t
b
=
*
mf2
;
if
(
mf1
->
size
>
MAX_XDIFF_SIZE
||
mf2
->
size
>
MAX_XDIFF_SIZE
)
return
-
1
;
trim_common_tail
(
&
a
,
&
b
,
xecfg
->
ctxlen
);
return
xdl_diff
(
&
a
,
&
b
,
xpp
,
xecfg
,
xecb
);
...
...
xdiff-interface.h
浏览文件 @
92cdfd21
...
...
@@ -3,6 +3,13 @@
#include "xdiff/xdiff.h"
/*
* xdiff isn't equipped to handle content over a gigabyte;
* we make the cutoff 1GB - 1MB to give some breathing
* room for constant-sized additions (e.g., merge markers)
*/
#define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)
typedef
void
(
*
xdiff_emit_consume_fn
)(
void
*
,
char
*
,
unsigned
long
);
int
xdi_diff
(
mmfile_t
*
mf1
,
mmfile_t
*
mf2
,
xpparam_t
const
*
xpp
,
xdemitconf_t
const
*
xecfg
,
xdemitcb_t
*
ecb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录