Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
bef36921
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,发现更多精彩内容 >>
提交
bef36921
编写于
5月 08, 2012
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'rs/maint-dir-strbuf' into rs/dir-strbuf
By René Scharfe * rs/maint-dir-strbuf: dir: convert to strbuf
上级
a3935e67
49dc2cc2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
39 deletion
+37
-39
dir.c
dir.c
+37
-39
未找到文件。
dir.c
浏览文件 @
bef36921
...
...
@@ -873,14 +873,14 @@ enum path_treatment {
};
static
enum
path_treatment
treat_one_path
(
struct
dir_struct
*
dir
,
char
*
path
,
int
*
len
,
struct
strbuf
*
path
,
const
struct
path_simplify
*
simplify
,
int
dtype
,
struct
dirent
*
de
)
{
int
exclude
=
excluded
(
dir
,
path
,
&
dtype
);
int
exclude
=
excluded
(
dir
,
path
->
buf
,
&
dtype
);
if
(
exclude
&&
(
dir
->
flags
&
DIR_COLLECT_IGNORED
)
&&
exclude_matches_pathspec
(
path
,
*
len
,
simplify
))
dir_add_ignored
(
dir
,
path
,
*
len
);
&&
exclude_matches_pathspec
(
path
->
buf
,
path
->
len
,
simplify
))
dir_add_ignored
(
dir
,
path
->
buf
,
path
->
len
);
/*
* Excluded? If we don't explicitly want to show
...
...
@@ -890,7 +890,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
return
path_ignored
;
if
(
dtype
==
DT_UNKNOWN
)
dtype
=
get_dtype
(
de
,
path
,
*
len
);
dtype
=
get_dtype
(
de
,
path
->
buf
,
path
->
len
);
/*
* Do we want to see just the ignored files?
...
...
@@ -907,9 +907,8 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
default:
return
path_ignored
;
case
DT_DIR
:
memcpy
(
path
+
*
len
,
"/"
,
2
);
(
*
len
)
++
;
switch
(
treat_directory
(
dir
,
path
,
*
len
,
simplify
))
{
strbuf_addch
(
path
,
'/'
);
switch
(
treat_directory
(
dir
,
path
->
buf
,
path
->
len
,
simplify
))
{
case
show_directory
:
if
(
exclude
!=
!!
(
dir
->
flags
&
DIR_SHOW_IGNORED
))
...
...
@@ -930,26 +929,21 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
static
enum
path_treatment
treat_path
(
struct
dir_struct
*
dir
,
struct
dirent
*
de
,
char
*
path
,
int
path_max
,
struct
strbuf
*
path
,
int
baselen
,
const
struct
path_simplify
*
simplify
,
int
*
len
)
const
struct
path_simplify
*
simplify
)
{
int
dtype
;
if
(
is_dot_or_dotdot
(
de
->
d_name
)
||
!
strcmp
(
de
->
d_name
,
".git"
))
return
path_ignored
;
*
len
=
strlen
(
de
->
d_name
);
/* Ignore overly long pathnames! */
if
(
*
len
+
baselen
+
8
>
path_max
)
return
path_ignored
;
memcpy
(
path
+
baselen
,
de
->
d_name
,
*
len
+
1
);
*
len
+=
baselen
;
if
(
simplify_away
(
path
,
*
len
,
simplify
))
strbuf_setlen
(
path
,
baselen
);
strbuf_addstr
(
path
,
de
->
d_name
);
if
(
simplify_away
(
path
->
buf
,
path
->
len
,
simplify
))
return
path_ignored
;
dtype
=
DTYPE
(
de
);
return
treat_one_path
(
dir
,
path
,
len
,
simplify
,
dtype
,
de
);
return
treat_one_path
(
dir
,
path
,
simplify
,
dtype
,
de
);
}
/*
...
...
@@ -969,19 +963,19 @@ static int read_directory_recursive(struct dir_struct *dir,
DIR
*
fdir
=
opendir
(
*
base
?
base
:
"."
);
int
contents
=
0
;
struct
dirent
*
de
;
char
path
[
PATH_MAX
+
1
]
;
struct
strbuf
path
=
STRBUF_INIT
;
if
(
!
fdir
)
return
0
;
memcpy
(
path
,
base
,
baselen
);
strbuf_add
(
&
path
,
base
,
baselen
);
while
((
de
=
readdir
(
fdir
))
!=
NULL
)
{
int
len
;
switch
(
treat_path
(
dir
,
de
,
path
,
sizeof
(
path
),
baselen
,
simplify
,
&
len
))
{
switch
(
treat_path
(
dir
,
de
,
&
path
,
baselen
,
simplify
))
{
case
path_recurse
:
contents
+=
read_directory_recursive
(
dir
,
path
,
len
,
0
,
simplify
);
contents
+=
read_directory_recursive
(
dir
,
path
.
buf
,
path
.
len
,
0
,
simplify
);
continue
;
case
path_ignored
:
continue
;
...
...
@@ -992,10 +986,11 @@ static int read_directory_recursive(struct dir_struct *dir,
if
(
check_only
)
goto
exit_early
;
else
dir_add_name
(
dir
,
path
,
len
);
dir_add_name
(
dir
,
path
.
buf
,
path
.
len
);
}
exit_early:
closedir
(
fdir
);
strbuf_release
(
&
path
);
return
contents
;
}
...
...
@@ -1058,8 +1053,8 @@ static int treat_leading_path(struct dir_struct *dir,
const
char
*
path
,
int
len
,
const
struct
path_simplify
*
simplify
)
{
char
pathbuf
[
PATH_MAX
]
;
int
baselen
,
blen
;
struct
strbuf
sb
=
STRBUF_INIT
;
int
baselen
,
rc
=
0
;
const
char
*
cp
;
while
(
len
&&
path
[
len
-
1
]
==
'/'
)
...
...
@@ -1074,19 +1069,22 @@ static int treat_leading_path(struct dir_struct *dir,
baselen
=
len
;
else
baselen
=
cp
-
path
;
memcpy
(
pathbuf
,
path
,
baselen
);
pathbuf
[
baselen
]
=
'\0'
;
if
(
!
is_directory
(
pathbuf
))
return
0
;
if
(
simplify_away
(
pathbuf
,
baselen
,
simplify
))
return
0
;
blen
=
baselen
;
if
(
treat_one_path
(
dir
,
pathbuf
,
&
blen
,
simplify
,
strbuf_setlen
(
&
sb
,
0
);
strbuf_add
(
&
sb
,
path
,
baselen
);
if
(
!
is_directory
(
sb
.
buf
))
break
;
if
(
simplify_away
(
sb
.
buf
,
sb
.
len
,
simplify
))
break
;
if
(
treat_one_path
(
dir
,
&
sb
,
simplify
,
DT_DIR
,
NULL
)
==
path_ignored
)
return
0
;
/* do not recurse into it */
if
(
len
<=
baselen
)
return
1
;
/* finished checking */
break
;
/* do not recurse into it */
if
(
len
<=
baselen
)
{
rc
=
1
;
break
;
/* finished checking */
}
}
strbuf_release
(
&
sb
);
return
rc
;
}
int
read_directory
(
struct
dir_struct
*
dir
,
const
char
*
path
,
int
len
,
const
char
**
pathspec
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录