Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
c067e1e2
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,发现更多精彩内容 >>
提交
c067e1e2
编写于
3月 05, 2009
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'sg/rerere-cleanup'
* sg/rerere-cleanup: rerere: remove duplicated functions
上级
db225572
90056966
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
29 deletion
+20
-29
builtin-rerere.c
builtin-rerere.c
+7
-18
rerere.c
rerere.c
+11
-11
rerere.h
rerere.h
+2
-0
未找到文件。
builtin-rerere.c
浏览文件 @
c067e1e2
...
...
@@ -13,28 +13,17 @@ static const char git_rerere_usage[] =
static
int
cutoff_noresolve
=
15
;
static
int
cutoff_resolve
=
60
;
static
const
char
*
rr_path
(
const
char
*
name
,
const
char
*
file
)
{
return
git_path
(
"rr-cache/%s/%s"
,
name
,
file
);
}
static
time_t
rerere_created_at
(
const
char
*
name
)
{
struct
stat
st
;
return
stat
(
rr_path
(
name
,
"preimage"
),
&
st
)
?
(
time_t
)
0
:
st
.
st_mtime
;
}
static
int
has_resolution
(
const
char
*
name
)
{
struct
stat
st
;
return
!
stat
(
rr_path
(
name
,
"postimage"
),
&
st
);
return
stat
(
rerere_path
(
name
,
"preimage"
),
&
st
)
?
(
time_t
)
0
:
st
.
st_mtime
;
}
static
void
unlink_rr_item
(
const
char
*
name
)
{
unlink
(
r
r
_path
(
name
,
"thisimage"
));
unlink
(
r
r
_path
(
name
,
"preimage"
));
unlink
(
r
r
_path
(
name
,
"postimage"
));
unlink
(
r
erere
_path
(
name
,
"thisimage"
));
unlink
(
r
erere
_path
(
name
,
"preimage"
));
unlink
(
r
erere
_path
(
name
,
"postimage"
));
rmdir
(
git_path
(
"rr-cache/%s"
,
name
));
}
...
...
@@ -65,7 +54,7 @@ static void garbage_collect(struct string_list *rr)
then
=
rerere_created_at
(
e
->
d_name
);
if
(
!
then
)
continue
;
cutoff
=
(
has_resolution
(
e
->
d_name
)
cutoff
=
(
has_re
rere_re
solution
(
e
->
d_name
)
?
cutoff_resolve
:
cutoff_noresolve
);
if
(
then
<
now
-
cutoff
*
86400
)
string_list_append
(
e
->
d_name
,
&
to_remove
);
...
...
@@ -124,7 +113,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
if
(
!
strcmp
(
argv
[
1
],
"clear"
))
{
for
(
i
=
0
;
i
<
merge_rr
.
nr
;
i
++
)
{
const
char
*
name
=
(
const
char
*
)
merge_rr
.
items
[
i
].
util
;
if
(
!
has_resolution
(
name
))
if
(
!
has_re
rere_re
solution
(
name
))
unlink_rr_item
(
name
);
}
unlink
(
git_path
(
"rr-cache/MERGE_RR"
));
...
...
@@ -137,7 +126,7 @@ 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
(
r
r
_path
(
name
,
"preimage"
),
path
,
path
,
path
);
diff_two
(
r
erere
_path
(
name
,
"preimage"
),
path
,
path
,
path
);
}
else
usage
(
git_rerere_usage
);
...
...
rerere.c
浏览文件 @
c067e1e2
...
...
@@ -12,15 +12,15 @@ static int rerere_autoupdate;
static
char
*
merge_rr_path
;
static
const
char
*
rr_path
(
const
char
*
name
,
const
char
*
file
)
const
char
*
rerere_path
(
const
char
*
hex
,
const
char
*
file
)
{
return
git_path
(
"rr-cache/%s/%s"
,
name
,
file
);
return
git_path
(
"rr-cache/%s/%s"
,
hex
,
file
);
}
static
int
has_resolution
(
const
char
*
name
)
int
has_rerere_resolution
(
const
char
*
hex
)
{
struct
stat
st
;
return
!
stat
(
r
r_path
(
name
,
"postimage"
),
&
st
);
return
!
stat
(
r
erere_path
(
hex
,
"postimage"
),
&
st
);
}
static
void
read_rr
(
struct
string_list
*
rr
)
...
...
@@ -208,12 +208,12 @@ static int merge(const char *name, const char *path)
mmbuffer_t
result
=
{
NULL
,
0
};
xpparam_t
xpp
=
{
XDF_NEED_MINIMAL
};
if
(
handle_file
(
path
,
NULL
,
r
r
_path
(
name
,
"thisimage"
))
<
0
)
if
(
handle_file
(
path
,
NULL
,
r
erere
_path
(
name
,
"thisimage"
))
<
0
)
return
1
;
if
(
read_mmfile
(
&
cur
,
r
r
_path
(
name
,
"thisimage"
))
||
read_mmfile
(
&
base
,
r
r
_path
(
name
,
"preimage"
))
||
read_mmfile
(
&
other
,
r
r
_path
(
name
,
"postimage"
)))
if
(
read_mmfile
(
&
cur
,
r
erere
_path
(
name
,
"thisimage"
))
||
read_mmfile
(
&
base
,
r
erere
_path
(
name
,
"preimage"
))
||
read_mmfile
(
&
other
,
r
erere
_path
(
name
,
"postimage"
)))
return
1
;
ret
=
xdl_merge
(
&
base
,
&
cur
,
""
,
&
other
,
""
,
&
xpp
,
XDL_MERGE_ZEALOUS
,
&
result
);
...
...
@@ -291,7 +291,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
string_list_insert
(
path
,
rr
)
->
util
=
hex
;
if
(
mkdir
(
git_path
(
"rr-cache/%s"
,
hex
),
0755
))
continue
;
handle_file
(
path
,
NULL
,
r
r
_path
(
hex
,
"preimage"
));
handle_file
(
path
,
NULL
,
r
erere
_path
(
hex
,
"preimage"
));
fprintf
(
stderr
,
"Recorded preimage for '%s'
\n
"
,
path
);
}
}
...
...
@@ -307,7 +307,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
const
char
*
path
=
rr
->
items
[
i
].
string
;
const
char
*
name
=
(
const
char
*
)
rr
->
items
[
i
].
util
;
if
(
has_resolution
(
name
))
{
if
(
has_re
rere_re
solution
(
name
))
{
if
(
!
merge
(
name
,
path
))
{
if
(
rerere_autoupdate
)
string_list_insert
(
path
,
&
update
);
...
...
@@ -326,7 +326,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
continue
;
fprintf
(
stderr
,
"Recorded resolution for '%s'.
\n
"
,
path
);
copy_file
(
r
r
_path
(
name
,
"postimage"
),
path
,
0666
);
copy_file
(
r
erere
_path
(
name
,
"postimage"
),
path
,
0666
);
mark_resolved:
rr
->
items
[
i
].
util
=
NULL
;
}
...
...
rerere.h
浏览文件 @
c067e1e2
...
...
@@ -5,5 +5,7 @@
extern
int
setup_rerere
(
struct
string_list
*
);
extern
int
rerere
(
void
);
extern
const
char
*
rerere_path
(
const
char
*
hex
,
const
char
*
file
);
extern
int
has_rerere_resolution
(
const
char
*
hex
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录