Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
79f5e064
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,发现更多精彩内容 >>
提交
79f5e064
编写于
8月 10, 2007
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'lt/readtree'
* lt/readtree: Start moving unpack-trees to "struct tree_desc"
上级
22631473
933bf40a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
30 deletion
+39
-30
builtin-read-tree.c
builtin-read-tree.c
+18
-8
merge-recursive.c
merge-recursive.c
+11
-5
unpack-trees.c
unpack-trees.c
+9
-16
unpack-trees.h
unpack-trees.h
+1
-1
未找到文件。
builtin-read-tree.c
浏览文件 @
79f5e064
...
...
@@ -13,14 +13,19 @@
#include "dir.h"
#include "builtin.h"
static
struct
object_list
*
trees
;
static
int
nr_trees
;
static
struct
tree
*
trees
[
4
];
static
int
list_tree
(
unsigned
char
*
sha1
)
{
struct
tree
*
tree
=
parse_tree_indirect
(
sha1
);
struct
tree
*
tree
;
if
(
nr_trees
>=
4
)
return
-
1
;
tree
=
parse_tree_indirect
(
sha1
);
if
(
!
tree
)
return
-
1
;
object_list_append
(
&
tree
->
object
,
&
trees
)
;
trees
[
nr_trees
++
]
=
tree
;
return
0
;
}
...
...
@@ -76,11 +81,10 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
static
void
prime_cache_tree
(
void
)
{
struct
tree
*
tree
=
(
struct
tree
*
)
trees
->
item
;
if
(
!
tree
)
if
(
!
nr_trees
)
return
;
active_cache_tree
=
cache_tree
();
prime_cache_tree_rec
(
active_cache_tree
,
tree
);
prime_cache_tree_rec
(
active_cache_tree
,
tree
s
[
0
]
);
}
...
...
@@ -92,6 +96,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{
int
i
,
newfd
,
stage
=
0
;
unsigned
char
sha1
[
20
];
struct
tree_desc
t
[
3
];
struct
unpack_trees_options
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
...
...
@@ -258,7 +263,12 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
opts
.
head_idx
=
1
;
}
unpack_trees
(
trees
,
&
opts
);
for
(
i
=
0
;
i
<
nr_trees
;
i
++
)
{
struct
tree
*
tree
=
trees
[
i
];
parse_tree
(
tree
);
init_tree_desc
(
t
+
i
,
tree
->
buffer
,
tree
->
size
);
}
unpack_trees
(
nr_trees
,
t
,
&
opts
);
/*
* When reading only one tree (either the most basic form,
...
...
@@ -266,7 +276,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
* valid cache-tree because the index must match exactly
* what came from the tree.
*/
if
(
trees
&&
trees
->
item
&&
!
opts
.
prefix
&&
(
!
opts
.
merge
||
(
stage
==
2
)))
{
if
(
nr_trees
&&
!
opts
.
prefix
&&
(
!
opts
.
merge
||
(
stage
==
2
)))
{
cache_tree_free
(
&
active_cache_tree
);
prime_cache_tree
();
}
...
...
merge-recursive.c
浏览文件 @
79f5e064
...
...
@@ -216,13 +216,19 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
*/
static
int
index_only
=
0
;
static
void
init_tree_desc_from_tree
(
struct
tree_desc
*
desc
,
struct
tree
*
tree
)
{
parse_tree
(
tree
);
init_tree_desc
(
desc
,
tree
->
buffer
,
tree
->
size
);
}
static
int
git_merge_trees
(
int
index_only
,
struct
tree
*
common
,
struct
tree
*
head
,
struct
tree
*
merge
)
{
int
rc
;
struct
object_list
*
trees
=
NULL
;
struct
tree_desc
t
[
3
]
;
struct
unpack_trees_options
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
...
...
@@ -234,11 +240,11 @@ static int git_merge_trees(int index_only,
opts
.
head_idx
=
2
;
opts
.
fn
=
threeway_merge
;
object_list_append
(
&
common
->
object
,
&
trees
);
object_list_append
(
&
head
->
object
,
&
trees
);
object_list_append
(
&
merge
->
object
,
&
trees
);
init_tree_desc_from_tree
(
t
+
0
,
common
);
init_tree_desc_from_tree
(
t
+
1
,
head
);
init_tree_desc_from_tree
(
t
+
2
,
merge
);
rc
=
unpack_trees
(
trees
,
&
opts
);
rc
=
unpack_trees
(
3
,
t
,
&
opts
);
cache_tree_free
(
&
active_cache_tree
);
return
rc
;
}
...
...
unpack-trees.c
浏览文件 @
79f5e064
...
...
@@ -16,19 +16,13 @@ struct tree_entry_list {
const
unsigned
char
*
sha1
;
};
static
struct
tree_entry_list
*
create_tree_entry_list
(
struct
tree
*
tree
)
static
struct
tree_entry_list
*
create_tree_entry_list
(
struct
tree
_desc
*
desc
)
{
struct
tree_desc
desc
;
struct
name_entry
one
;
struct
tree_entry_list
*
ret
=
NULL
;
struct
tree_entry_list
**
list_p
=
&
ret
;
if
(
!
tree
->
object
.
parsed
)
parse_tree
(
tree
);
init_tree_desc
(
&
desc
,
tree
->
buffer
,
tree
->
size
);
while
(
tree_entry
(
&
desc
,
&
one
))
{
while
(
tree_entry
(
desc
,
&
one
))
{
struct
tree_entry_list
*
entry
;
entry
=
xmalloc
(
sizeof
(
struct
tree_entry_list
));
...
...
@@ -173,9 +167,11 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
if
(
S_ISDIR
(
posns
[
i
]
->
mode
))
{
struct
tree
*
tree
=
lookup_tree
(
posns
[
i
]
->
sha1
);
struct
tree_desc
t
;
any_dirs
=
1
;
parse_tree
(
tree
);
subposns
[
i
]
=
create_tree_entry_list
(
tree
);
init_tree_desc
(
&
t
,
tree
->
buffer
,
tree
->
size
);
subposns
[
i
]
=
create_tree_entry_list
(
&
t
);
posns
[
i
]
=
posns
[
i
]
->
next
;
src
[
i
+
o
->
merge
]
=
o
->
df_conflict_entry
;
continue
;
...
...
@@ -331,12 +327,10 @@ static void check_updates(struct cache_entry **src, int nr,
stop_progress
(
&
progress
);;
}
int
unpack_trees
(
struct
object_list
*
trees
,
struct
unpack_trees_options
*
o
)
int
unpack_trees
(
unsigned
len
,
struct
tree_desc
*
t
,
struct
unpack_trees_options
*
o
)
{
unsigned
len
=
object_list_length
(
trees
);
struct
tree_entry_list
**
posns
;
int
i
;
struct
object_list
*
posn
=
trees
;
struct
tree_entry_list
df_conflict_list
;
static
struct
cache_entry
*
dfc
;
...
...
@@ -356,10 +350,9 @@ int unpack_trees(struct object_list *trees, struct unpack_trees_options *o)
if
(
len
)
{
posns
=
xmalloc
(
len
*
sizeof
(
struct
tree_entry_list
*
));
for
(
i
=
0
;
i
<
len
;
i
++
)
{
posns
[
i
]
=
create_tree_entry_list
((
struct
tree
*
)
posn
->
item
);
posn
=
posn
->
next
;
}
for
(
i
=
0
;
i
<
len
;
i
++
)
posns
[
i
]
=
create_tree_entry_list
(
t
+
i
);
if
(
unpack_trees_rec
(
posns
,
len
,
o
->
prefix
?
o
->
prefix
:
""
,
o
,
&
df_conflict_list
))
return
-
1
;
...
...
unpack-trees.h
浏览文件 @
79f5e064
...
...
@@ -26,7 +26,7 @@ struct unpack_trees_options {
struct
cache_entry
*
df_conflict_entry
;
};
extern
int
unpack_trees
(
struct
object_list
*
trees
,
extern
int
unpack_trees
(
unsigned
n
,
struct
tree_desc
*
t
,
struct
unpack_trees_options
*
options
);
int
threeway_merge
(
struct
cache_entry
**
stages
,
struct
unpack_trees_options
*
o
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录