Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
fc062aa2
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,发现更多精彩内容 >>
提交
fc062aa2
编写于
7月 13, 2008
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'js/pick-root'
* js/pick-root: Allow cherry-picking root commits
上级
ef567fe7
f95ebf74
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
10 deletion
+46
-10
builtin-revert.c
builtin-revert.c
+16
-10
t/t3503-cherry-pick-root.sh
t/t3503-cherry-pick-root.sh
+30
-0
未找到文件。
builtin-revert.c
浏览文件 @
fc062aa2
...
...
@@ -206,6 +206,7 @@ static int merge_recursive(const char *base_sha1,
{
char
buffer
[
256
];
const
char
*
argv
[
6
];
int
i
=
0
;
sprintf
(
buffer
,
"GITHEAD_%s"
,
head_sha1
);
setenv
(
buffer
,
head_name
,
1
);
...
...
@@ -218,12 +219,13 @@ static int merge_recursive(const char *base_sha1,
* and $prev on top of us (when reverting), or the change between
* $prev and $commit on top of us (when cherry-picking or replaying).
*/
argv
[
0
]
=
"merge-recursive"
;
argv
[
1
]
=
base_sha1
;
argv
[
2
]
=
"--"
;
argv
[
3
]
=
head_sha1
;
argv
[
4
]
=
next_sha1
;
argv
[
5
]
=
NULL
;
argv
[
i
++
]
=
"merge-recursive"
;
if
(
base_sha1
)
argv
[
i
++
]
=
base_sha1
;
argv
[
i
++
]
=
"--"
;
argv
[
i
++
]
=
head_sha1
;
argv
[
i
++
]
=
next_sha1
;
argv
[
i
++
]
=
NULL
;
return
run_command_v_opt
(
argv
,
RUN_COMMAND_NO_STDIN
|
RUN_GIT_CMD
);
}
...
...
@@ -297,9 +299,12 @@ static int revert_or_cherry_pick(int argc, const char **argv)
discard_cache
();
}
if
(
!
commit
->
parents
)
die
(
"Cannot %s a root commit"
,
me
);
if
(
commit
->
parents
->
next
)
{
if
(
!
commit
->
parents
)
{
if
(
action
==
REVERT
)
die
(
"Cannot revert a root commit"
);
parent
=
NULL
;
}
else
if
(
commit
->
parents
->
next
)
{
/* Reverting or cherry-picking a merge commit */
int
cnt
;
struct
commit_list
*
p
;
...
...
@@ -368,7 +373,8 @@ static int revert_or_cherry_pick(int argc, const char **argv)
}
}
if
(
merge_recursive
(
sha1_to_hex
(
base
->
object
.
sha1
),
if
(
merge_recursive
(
base
==
NULL
?
NULL
:
sha1_to_hex
(
base
->
object
.
sha1
),
sha1_to_hex
(
head
),
"HEAD"
,
sha1_to_hex
(
next
->
object
.
sha1
),
oneline
)
||
write_cache_as_tree
(
head
,
0
,
NULL
))
{
...
...
t/t3503-cherry-pick-root.sh
0 → 100755
浏览文件 @
fc062aa2
#!/bin/sh
test_description
=
'test cherry-picking a root commit'
.
./test-lib.sh
test_expect_success setup
'
echo first > file1 &&
git add file1 &&
test_tick &&
git commit -m "first" &&
git symbolic-ref HEAD refs/heads/second &&
rm .git/index file1 &&
echo second > file2 &&
git add file2 &&
test_tick &&
git commit -m "second"
'
test_expect_success
'cherry-pick a root commit'
'
git cherry-pick master &&
test first = $(cat file1)
'
test_done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录