Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
81b84bcb
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,发现更多精彩内容 >>
提交
81b84bcb
编写于
9月 25, 2008
作者:
S
Shawn O. Pearce
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jc/apply-include-exclude'
* jc/apply-include-exclude: git-apply:--include=pathspec
上级
58245a5e
6ecb1ee2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
16 deletion
+46
-16
Documentation/git-apply.txt
Documentation/git-apply.txt
+13
-1
builtin-apply.c
builtin-apply.c
+33
-15
未找到文件。
Documentation/git-apply.txt
浏览文件 @
81b84bcb
...
...
@@ -14,7 +14,8 @@ SYNOPSIS
[--allow-binary-replacement | --binary] [--reject] [-z]
[-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
[--whitespace=<nowarn|warn|fix|error|error-all>]
[--exclude=PATH] [--directory=<root>] [--verbose] [<patch>...]
[--exclude=PATH] [--include=PATH] [--directory=<root>]
[--verbose] [<patch>...]
DESCRIPTION
-----------
...
...
@@ -137,6 +138,17 @@ discouraged.
be useful when importing patchsets, where you want to exclude certain
files or directories.
--include=<path-pattern>::
Apply changes to files matching the given path pattern. This can
be useful when importing patchsets, where you want to include certain
files or directories.
+
When --exclude and --include patterns are used, they are examined in the
order they appear on the command line, and the first match determines if a
patch to each path is used. A patch to a path that does not match any
include/exclude pattern is used by default if there is no include pattern
on the command line, and ignored if there is any include pattern.
--whitespace=<action>::
When applying a patch, detect a new or modified line that has
whitespace errors. What are considered whitespace errors is
...
...
builtin-apply.c
浏览文件 @
81b84bcb
...
...
@@ -2994,29 +2994,45 @@ static int write_out_results(struct patch *list, int skipped_patch)
static
struct
lock_file
lock_file
;
static
struct
excludes
{
struct
excludes
*
next
;
const
char
*
path
;
}
*
excludes
;
static
struct
string_list
limit_by_name
;
static
int
has_include
;
static
void
add_name_limit
(
const
char
*
name
,
int
exclude
)
{
struct
string_list_item
*
it
;
it
=
string_list_append
(
name
,
&
limit_by_name
);
it
->
util
=
exclude
?
NULL
:
(
void
*
)
1
;
}
static
int
use_patch
(
struct
patch
*
p
)
{
const
char
*
pathname
=
p
->
new_name
?
p
->
new_name
:
p
->
old_name
;
struct
excludes
*
x
=
excludes
;
while
(
x
)
{
if
(
fnmatch
(
x
->
path
,
pathname
,
0
)
==
0
)
return
0
;
x
=
x
->
next
;
}
int
i
;
/* Paths outside are not touched regardless of "--include" */
if
(
0
<
prefix_length
)
{
int
pathlen
=
strlen
(
pathname
);
if
(
pathlen
<=
prefix_length
||
memcmp
(
prefix
,
pathname
,
prefix_length
))
return
0
;
}
return
1
;
/* See if it matches any of exclude/include rule */
for
(
i
=
0
;
i
<
limit_by_name
.
nr
;
i
++
)
{
struct
string_list_item
*
it
=
&
limit_by_name
.
items
[
i
];
if
(
!
fnmatch
(
it
->
string
,
pathname
,
0
))
return
(
it
->
util
!=
NULL
);
}
/*
* If we had any include, a path that does not match any rule is
* not used. Otherwise, we saw bunch of exclude rules (or none)
* and such a path is used.
*/
return
!
has_include
;
}
static
void
prefix_one
(
char
**
name
)
{
char
*
old_name
=
*
name
;
...
...
@@ -3157,10 +3173,12 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
continue
;
}
if
(
!
prefixcmp
(
arg
,
"--exclude="
))
{
struct
excludes
*
x
=
xmalloc
(
sizeof
(
*
x
));
x
->
path
=
arg
+
10
;
x
->
next
=
excludes
;
excludes
=
x
;
add_name_limit
(
arg
+
10
,
1
);
continue
;
}
if
(
!
prefixcmp
(
arg
,
"--include="
))
{
add_name_limit
(
arg
+
10
,
0
);
has_include
=
1
;
continue
;
}
if
(
!
prefixcmp
(
arg
,
"-p"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录