Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
8fa40aa9
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,发现更多精彩内容 >>
提交
8fa40aa9
编写于
2月 18, 2006
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jc/rebase-limit'
* jc/rebase-limit: rebase: allow rebasing onto different base.
上级
c4d133a2
e646c9c8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
71 addition
and
18 deletion
+71
-18
git-rebase.sh
git-rebase.sh
+71
-18
未找到文件。
git-rebase.sh
浏览文件 @
8fa40aa9
...
...
@@ -3,10 +3,48 @@
# Copyright (c) 2005 Junio C Hamano.
#
USAGE
=
'<upstream> [<head>]'
USAGE
=
'[--onto <newbase>] <upstream> [<branch>]'
LONG_USAGE
=
'If <branch> is specified, switch to that branch first. Then,
extract commits in the current branch that are not in <upstream>,
and reconstruct the current on top of <upstream>, discarding the original
development history. If --onto <newbase> is specified, the history is
reconstructed on top of <newbase>, instead of <upstream>. For example,
while on "topic" branch:
A---B---C topic
/
D---E---F---G master
$ '
"
$0
"
' --onto master~1 master topic
would rewrite the history to look like this:
A'
\'
'--B'
\'
'--C'
\'
' topic
/
D---E---F---G master
'
.
git-sh-setup
case
$#
in
1|2
)
;;
*
)
usage
;;
esac
unset
newbase
while case
"$#"
in
0
)
break
;;
esac
do
case
"
$1
"
in
--onto
)
test
2
-le
"$#"
||
usage
newbase
=
"
$2
"
shift
;;
-
*
)
usage
;;
*
)
break
;;
esac
shift
done
# Make sure we do not have .dotest
if
mkdir
.dotest
...
...
@@ -30,11 +68,10 @@ case "$diff" in
;;
esac
# The other head is given. Make sure it is valid.
other
=
$(
git-rev-parse
--verify
"
$1
^0"
)
||
usage
# Make sure the branch to rebase is valid.
head
=
$(
git-rev-parse
--verify
"
${
2
-HEAD
}
^0"
)
||
exit
# The upstream head must be given. Make sure it is valid.
upstream_name
=
"
$1
"
upstream
=
`
git rev-parse
--verify
"
${
upstream_name
}
^0"
`
||
die
"invalid upsteram
$upstream_name
"
# If a hook exists, give it a chance to interrupt
if
test
-x
"
$GIT_DIR
/hooks/pre-rebase"
...
...
@@ -48,28 +85,44 @@ fi
# If the branch to rebase is given, first switch to it.
case
"$#"
in
2
)
branch_name
=
"
$2
"
git-checkout
"
$2
"
||
usage
;;
*
)
branch_name
=
`
git symbolic-ref HEAD
`
||
die
"No current branch"
branch_name
=
`
expr
"
$branch_name
"
:
'refs/heads/\(.*\)'
`
;;
esac
branch
=
$(
git-rev-parse
--verify
"
${
branch_name
}
^0"
)
||
exit
mb
=
$(
git-merge-base
"
$other
"
"
$head
"
)
# Make sure the branch to rebase onto is valid.
onto_name
=
${
newbase
-
"
$upstream_name
"
}
onto
=
$(
git-rev-parse
--verify
"
${
onto_name
}
^0"
)
||
exit
# Check if we are already based on $other.
if
test
"
$mb
"
=
"
$other
"
# Now we are rebasing commits $upstream..$branch on top of $onto
# Check if we are already based on $onto, but this should be
# done only when upstream and onto are the same.
if
test
"
$upstream
"
=
"onto"
then
echo
>
&2
"Current branch
`
git-symbolic-ref HEAD
`
is up to date."
exit
0
mb
=
$(
git-merge-base
"
$onto
"
"
$branch
"
)
if
test
"
$mb
"
=
"
$onto
"
then
echo
>
&2
"Current branch
$branch_name
is up to date."
exit
0
fi
fi
# Rewind the head to "$o
ther"
git-reset
--hard
"
$o
ther
"
# Rewind the head to "$o
nto"; this saves our current head in ORIG_HEAD.
git-reset
--hard
"
$o
nto
"
# If the $o
ther
is a proper descendant of the tip of the branch, then
# If the $o
nto
is a proper descendant of the tip of the branch, then
# we just fast forwarded.
if
test
"
$mb
"
=
"
$
head
"
if
test
"
$mb
"
=
"
$
onto
"
then
echo
>
&2
"Fast-forwarded
$
head
to
$other
."
echo
>
&2
"Fast-forwarded
$
branch
to
$newbase
."
exit
0
fi
git-format-patch
-k
--stdout
--full-index
"
$
other
"
ORIG_HEAD |
git-format-patch
-k
--stdout
--full-index
"
$
upstream
"
ORIG_HEAD |
git am
--binary
-3
-k
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录