Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
168cc639
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,发现更多精彩内容 >>
提交
168cc639
编写于
8月 23, 2005
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge refs/heads/master from .
上级
58eaf287
0d6a873c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
15 deletion
+76
-15
Documentation/git.txt
Documentation/git.txt
+3
-0
git-resolve-script
git-resolve-script
+35
-1
merge-base.c
merge-base.c
+38
-14
未找到文件。
Documentation/git.txt
浏览文件 @
168cc639
...
...
@@ -16,6 +16,9 @@ DESCRIPTION
This is reference information for the core git commands.
Before reading this cover to cover, you may want to take a look
at the link:tutorial.html[tutorial] document.
The Discussion section below contains much useful definition and
clarification info - read that first. And of the commands, I suggest
reading link:git-update-cache.html[git-update-cache] and
...
...
git-resolve-script
浏览文件 @
168cc639
...
...
@@ -49,7 +49,41 @@ if [ "$common" == "$head" ]; then
dropheads
exit
0
fi
echo
"Trying to merge
$merge
into
$head
"
# Find an optimum merge base if there are more than one candidates.
LF
=
'
'
common
=
$(
git-merge-base
-a
$head
$merge
)
case
"
$common
"
in
?
*
"
$LF
"
?
*
)
echo
"Trying to find the optimum merge base."
G
=
.tmp-index
$$
best
=
best_cnt
=
-1
for
c
in
$common
do
rm
-f
$G
GIT_INDEX_FILE
=
$G
git-read-tree
-m
$c
$head
$merge
\
2>/dev/null
||
continue
# Count the paths that are unmerged.
cnt
=
`
GIT_INDEX_FILE
=
$G
git-ls-files
--unmerged
|
wc
-l
`
if
test
$best_cnt
-le
0
-o
$cnt
-le
$best_cnt
then
best
=
$c
best_cnt
=
$cnt
if
test
"
$best_cnt
"
-eq
0
then
# Cannot do any better than all trivial merge.
break
fi
fi
done
rm
-f
$G
common
=
"
$best
"
esac
echo
"Trying to merge
$merge
into
$head
using
$common
."
git-update-cache
--refresh
2>/dev/null
git-read-tree
-u
-m
$common
$head
$merge
||
exit
1
result_tree
=
$(
git-write-tree 2> /dev/null
)
if
[
$?
-ne
0
]
;
then
...
...
merge-base.c
浏览文件 @
168cc639
...
...
@@ -82,13 +82,17 @@ static struct commit *interesting(struct commit_list *list)
* commit B.
*/
static
struct
commit
*
common_ancestor
(
struct
commit
*
rev1
,
struct
commit
*
rev2
)
static
int
show_all
=
0
;
static
int
merge_base
(
struct
commit
*
rev1
,
struct
commit
*
rev2
)
{
struct
commit_list
*
list
=
NULL
;
struct
commit_list
*
result
=
NULL
;
if
(
rev1
==
rev2
)
return
rev1
;
if
(
rev1
==
rev2
)
{
printf
(
"%s
\n
"
,
sha1_to_hex
(
rev1
->
object
.
sha1
));
return
0
;
}
parse_commit
(
rev1
);
parse_commit
(
rev2
);
...
...
@@ -108,7 +112,7 @@ static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
if
(
flags
==
3
)
{
insert_by_date
(
commit
,
&
result
);
/* Mark
children
of a found merge uninteresting */
/* Mark
parents
of a found merge uninteresting */
flags
|=
UNINTERESTING
;
}
parents
=
commit
->
parents
;
...
...
@@ -122,26 +126,46 @@ static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
insert_by_date
(
p
,
&
list
);
}
}
return
interesting
(
result
);
if
(
!
result
)
return
1
;
while
(
result
)
{
struct
commit
*
commit
=
result
->
item
;
result
=
result
->
next
;
if
(
commit
->
object
.
flags
&
UNINTERESTING
)
continue
;
printf
(
"%s
\n
"
,
sha1_to_hex
(
commit
->
object
.
sha1
));
if
(
!
show_all
)
return
0
;
commit
->
object
.
flags
|=
UNINTERESTING
;
}
return
0
;
}
static
const
char
merge_base_usage
[]
=
"git-merge-base [--all] <commit-id> <commit-id>"
;
int
main
(
int
argc
,
char
**
argv
)
{
struct
commit
*
rev1
,
*
rev2
,
*
ret
;
struct
commit
*
rev1
,
*
rev2
;
unsigned
char
rev1key
[
20
],
rev2key
[
20
];
while
(
1
<
argc
&&
argv
[
1
][
0
]
==
'-'
)
{
char
*
arg
=
argv
[
1
];
if
(
!
strcmp
(
arg
,
"-a"
)
||
!
strcmp
(
arg
,
"--all"
))
show_all
=
1
;
else
usage
(
merge_base_usage
);
argc
--
;
argv
++
;
}
if
(
argc
!=
3
||
get_sha1
(
argv
[
1
],
rev1key
)
||
get_sha1
(
argv
[
2
],
rev2key
))
{
usage
(
"git-merge-base <commit-id> <commit-id>"
);
}
get_sha1
(
argv
[
2
],
rev2key
))
usage
(
merge_base_usage
);
rev1
=
lookup_commit_reference
(
rev1key
);
rev2
=
lookup_commit_reference
(
rev2key
);
if
(
!
rev1
||
!
rev2
)
return
1
;
ret
=
common_ancestor
(
rev1
,
rev2
);
if
(
!
ret
)
return
1
;
printf
(
"%s
\n
"
,
sha1_to_hex
(
ret
->
object
.
sha1
));
return
0
;
return
merge_base
(
rev1
,
rev2
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录