Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
a757c646
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,发现更多精彩内容 >>
提交
a757c646
编写于
3月 24, 2010
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
diff --check: honor conflict-marker-size attribute
Signed-off-by:
N
Junio C Hamano
<
gitster@pobox.com
>
上级
8588567c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
14 deletion
+33
-14
diff.c
diff.c
+11
-13
t/t4017-diff-retval.sh
t/t4017-diff-retval.sh
+22
-1
未找到文件。
diff.c
浏览文件 @
a757c646
...
...
@@ -14,6 +14,7 @@
#include "userdiff.h"
#include "sigchain.h"
#include "submodule.h"
#include "ll-merge.h"
#ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY 0
...
...
@@ -1364,37 +1365,32 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
struct
checkdiff_t
{
const
char
*
filename
;
int
lineno
;
int
conflict_marker_size
;
struct
diff_options
*
o
;
unsigned
ws_rule
;
unsigned
status
;
};
static
int
is_conflict_marker
(
const
char
*
line
,
unsigned
long
len
)
static
int
is_conflict_marker
(
const
char
*
line
,
int
marker_size
,
unsigned
long
len
)
{
char
firstchar
;
int
cnt
;
if
(
len
<
8
)
if
(
len
<
marker_size
+
1
)
return
0
;
firstchar
=
line
[
0
];
switch
(
firstchar
)
{
case
'='
:
case
'>'
:
case
'<'
:
case
'='
:
case
'>'
:
case
'<'
:
case
'|'
:
break
;
default:
return
0
;
}
for
(
cnt
=
1
;
cnt
<
7
;
cnt
++
)
for
(
cnt
=
1
;
cnt
<
marker_size
;
cnt
++
)
if
(
line
[
cnt
]
!=
firstchar
)
return
0
;
/* line[0] thru line[6] are same as firstchar */
if
(
firstchar
==
'='
)
{
/* divider between ours and theirs? */
if
(
len
!=
8
||
line
[
7
]
!=
'\n'
)
return
0
;
}
else
if
(
len
<
8
||
!
isspace
(
line
[
7
]))
{
/* not divider before ours nor after theirs */
/* line[1] thru line[marker_size-1] are same as firstchar */
if
(
len
<
marker_size
+
1
||
!
isspace
(
line
[
marker_size
]))
return
0
;
}
return
1
;
}
...
...
@@ -1402,6 +1398,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
{
struct
checkdiff_t
*
data
=
priv
;
int
color_diff
=
DIFF_OPT_TST
(
data
->
o
,
COLOR_DIFF
);
int
marker_size
=
data
->
conflict_marker_size
;
const
char
*
ws
=
diff_get_color
(
color_diff
,
DIFF_WHITESPACE
);
const
char
*
reset
=
diff_get_color
(
color_diff
,
DIFF_RESET
);
const
char
*
set
=
diff_get_color
(
color_diff
,
DIFF_FILE_NEW
);
...
...
@@ -1410,7 +1407,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
if
(
line
[
0
]
==
'+'
)
{
unsigned
bad
;
data
->
lineno
++
;
if
(
is_conflict_marker
(
line
+
1
,
len
-
1
))
{
if
(
is_conflict_marker
(
line
+
1
,
marker_size
,
len
-
1
))
{
data
->
status
|=
1
;
fprintf
(
data
->
o
->
file
,
"%s:%d: leftover conflict marker
\n
"
,
...
...
@@ -1841,6 +1838,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
data
.
lineno
=
0
;
data
.
o
=
o
;
data
.
ws_rule
=
whitespace_rule
(
attr_path
);
data
.
conflict_marker_size
=
ll_merge_marker_size
(
attr_path
);
if
(
fill_mmfile
(
&
mf1
,
one
)
<
0
||
fill_mmfile
(
&
mf2
,
two
)
<
0
)
die
(
"unable to read files to diff"
);
...
...
t/t4017-diff-retval.sh
浏览文件 @
a757c646
...
...
@@ -105,7 +105,6 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '
'
test_expect_success
'check should test not just the last line'
'
echo "" >>a &&
git --no-pager diff --check
...
...
@@ -127,4 +126,26 @@ test_expect_success 'check detects leftover conflict markers' '
git reset --hard
'
test_expect_success
'check honors conflict marker length'
'
git reset --hard &&
echo ">>>>>>> boo" >>b &&
echo "======" >>a &&
git diff --check a &&
(
git diff --check b
test $? = 2
) &&
git reset --hard &&
echo ">>>>>>>> boo" >>b &&
echo "========" >>a &&
git diff --check &&
echo "b conflict-marker-size=8" >.gitattributes &&
(
git diff --check b
test $? = 2
) &&
git diff --check a &&
git reset --hard
'
test_done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录