Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
56532fa1
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,发现更多精彩内容 >>
提交
56532fa1
编写于
11月 01, 2006
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'rs/cherry'
* rs/cherry: Make git-cherry handle root trees Built-in cherry
上级
e0d68cd5
2b60356d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
139 addition
and
26 deletion
+139
-26
Makefile
Makefile
+2
-2
builtin-log.c
builtin-log.c
+111
-2
builtin.h
builtin.h
+1
-0
diff.h
diff.h
+2
-0
git.c
git.c
+1
-0
log-tree.c
log-tree.c
+4
-22
tree-diff.c
tree-diff.c
+18
-0
未找到文件。
Makefile
浏览文件 @
56532fa1
...
...
@@ -159,7 +159,7 @@ BASIC_LDFLAGS =
SCRIPT_SH
=
\
git-bisect.sh git-checkout.sh
\
git-c
herry.sh git-c
lean.sh git-clone.sh git-commit.sh
\
git-clean.sh git-clone.sh git-commit.sh
\
git-fetch.sh
\
git-ls-remote.sh
\
git-merge-one-file.sh git-parse-remote.sh
\
...
...
@@ -212,7 +212,7 @@ PROGRAMS = \
EXTRA_PROGRAMS
=
BUILT_INS
=
\
git-format-patch
$X
git-show
$X
git-whatchanged
$X
\
git-format-patch
$X
git-show
$X
git-whatchanged
$X
git-cherry
$X
\
git-get-tar-commit-id
$X
\
$(
patsubst
builtin-%.o,git-%
$X
,
$(BUILTIN_OBJS)
)
...
...
builtin-log.c
浏览文件 @
56532fa1
...
...
@@ -171,8 +171,11 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
static
int
get_patch_id
(
struct
commit
*
commit
,
struct
diff_options
*
options
,
unsigned
char
*
sha1
)
{
diff_tree_sha1
(
commit
->
parents
->
item
->
object
.
sha1
,
commit
->
object
.
sha1
,
""
,
options
);
if
(
commit
->
parents
)
diff_tree_sha1
(
commit
->
parents
->
item
->
object
.
sha1
,
commit
->
object
.
sha1
,
""
,
options
);
else
diff_root_tree_sha1
(
commit
->
object
.
sha1
,
""
,
options
);
diffcore_std
(
options
);
return
diff_flush_patch_id
(
options
,
sha1
);
}
...
...
@@ -437,3 +440,109 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
return
0
;
}
static
int
add_pending_commit
(
const
char
*
arg
,
struct
rev_info
*
revs
,
int
flags
)
{
unsigned
char
sha1
[
20
];
if
(
get_sha1
(
arg
,
sha1
)
==
0
)
{
struct
commit
*
commit
=
lookup_commit_reference
(
sha1
);
if
(
commit
)
{
commit
->
object
.
flags
|=
flags
;
add_pending_object
(
revs
,
&
commit
->
object
,
arg
);
return
0
;
}
}
return
-
1
;
}
static
const
char
cherry_usage
[]
=
"git-cherry [-v] <upstream> [<head>] [<limit>]"
;
int
cmd_cherry
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
{
struct
rev_info
revs
;
struct
diff_options
patch_id_opts
;
struct
commit
*
commit
;
struct
commit_list
*
list
=
NULL
;
const
char
*
upstream
;
const
char
*
head
=
"HEAD"
;
const
char
*
limit
=
NULL
;
int
verbose
=
0
;
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"-v"
))
{
verbose
=
1
;
argc
--
;
argv
++
;
}
switch
(
argc
)
{
case
4
:
limit
=
argv
[
3
];
/* FALLTHROUGH */
case
3
:
head
=
argv
[
2
];
/* FALLTHROUGH */
case
2
:
upstream
=
argv
[
1
];
break
;
default:
usage
(
cherry_usage
);
}
init_revisions
(
&
revs
,
prefix
);
revs
.
diff
=
1
;
revs
.
combine_merges
=
0
;
revs
.
ignore_merges
=
1
;
revs
.
diffopt
.
recursive
=
1
;
if
(
add_pending_commit
(
head
,
&
revs
,
0
))
die
(
"Unknown commit %s"
,
head
);
if
(
add_pending_commit
(
upstream
,
&
revs
,
UNINTERESTING
))
die
(
"Unknown commit %s"
,
upstream
);
/* Don't say anything if head and upstream are the same. */
if
(
revs
.
pending
.
nr
==
2
)
{
struct
object_array_entry
*
o
=
revs
.
pending
.
objects
;
if
(
hashcmp
(
o
[
0
].
item
->
sha1
,
o
[
1
].
item
->
sha1
)
==
0
)
return
0
;
}
get_patch_ids
(
&
revs
,
&
patch_id_opts
,
prefix
);
if
(
limit
&&
add_pending_commit
(
limit
,
&
revs
,
UNINTERESTING
))
die
(
"Unknown commit %s"
,
limit
);
/* reverse the list of commits */
prepare_revision_walk
(
&
revs
);
while
((
commit
=
get_revision
(
&
revs
))
!=
NULL
)
{
/* ignore merges */
if
(
commit
->
parents
&&
commit
->
parents
->
next
)
continue
;
commit_list_insert
(
commit
,
&
list
);
}
while
(
list
)
{
unsigned
char
sha1
[
20
];
char
sign
=
'+'
;
commit
=
list
->
item
;
if
(
!
get_patch_id
(
commit
,
&
patch_id_opts
,
sha1
)
&&
lookup_object
(
sha1
))
sign
=
'-'
;
if
(
verbose
)
{
static
char
buf
[
16384
];
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
~
0
,
buf
,
sizeof
(
buf
),
0
,
NULL
,
NULL
,
0
);
printf
(
"%c %s %s
\n
"
,
sign
,
sha1_to_hex
(
commit
->
object
.
sha1
),
buf
);
}
else
{
printf
(
"%c %s
\n
"
,
sign
,
sha1_to_hex
(
commit
->
object
.
sha1
));
}
list
=
list
->
next
;
}
return
0
;
}
builtin.h
浏览文件 @
56532fa1
...
...
@@ -21,6 +21,7 @@ extern int cmd_branch(int argc, const char **argv, const char *prefix);
extern
int
cmd_cat_file
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_checkout_index
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_check_ref_format
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_cherry
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_commit_tree
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_count_objects
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
extern
int
cmd_diff_files
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
);
...
...
diff.h
浏览文件 @
56532fa1
...
...
@@ -102,6 +102,8 @@ extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
const
char
*
base
,
struct
diff_options
*
opt
);
extern
int
diff_tree_sha1
(
const
unsigned
char
*
old
,
const
unsigned
char
*
new
,
const
char
*
base
,
struct
diff_options
*
opt
);
extern
int
diff_root_tree_sha1
(
const
unsigned
char
*
new
,
const
char
*
base
,
struct
diff_options
*
opt
);
struct
combine_diff_path
{
struct
combine_diff_path
*
next
;
...
...
git.c
浏览文件 @
56532fa1
...
...
@@ -226,6 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{
"cat-file"
,
cmd_cat_file
,
RUN_SETUP
},
{
"checkout-index"
,
cmd_checkout_index
,
RUN_SETUP
},
{
"check-ref-format"
,
cmd_check_ref_format
},
{
"cherry"
,
cmd_cherry
,
RUN_SETUP
},
{
"commit-tree"
,
cmd_commit_tree
,
RUN_SETUP
},
{
"count-objects"
,
cmd_count_objects
,
RUN_SETUP
},
{
"diff"
,
cmd_diff
,
RUN_SETUP
|
USE_PAGER
},
...
...
log-tree.c
浏览文件 @
56532fa1
...
...
@@ -252,26 +252,6 @@ int log_tree_diff_flush(struct rev_info *opt)
return
1
;
}
static
int
diff_root_tree
(
struct
rev_info
*
opt
,
const
unsigned
char
*
new
,
const
char
*
base
)
{
int
retval
;
void
*
tree
;
struct
tree_desc
empty
,
real
;
tree
=
read_object_with_reference
(
new
,
tree_type
,
&
real
.
size
,
NULL
);
if
(
!
tree
)
die
(
"unable to read root tree (%s)"
,
sha1_to_hex
(
new
));
real
.
buf
=
tree
;
empty
.
buf
=
""
;
empty
.
size
=
0
;
retval
=
diff_tree
(
&
empty
,
&
real
,
base
,
&
opt
->
diffopt
);
free
(
tree
);
log_tree_diff_flush
(
opt
);
return
retval
;
}
static
int
do_diff_combined
(
struct
rev_info
*
opt
,
struct
commit
*
commit
)
{
unsigned
const
char
*
sha1
=
commit
->
object
.
sha1
;
...
...
@@ -297,8 +277,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
/* Root commit? */
parents
=
commit
->
parents
;
if
(
!
parents
)
{
if
(
opt
->
show_root_diff
)
diff_root_tree
(
opt
,
sha1
,
""
);
if
(
opt
->
show_root_diff
)
{
diff_root_tree_sha1
(
sha1
,
""
,
&
opt
->
diffopt
);
log_tree_diff_flush
(
opt
);
}
return
!
opt
->
loginfo
;
}
...
...
tree-diff.c
浏览文件 @
56532fa1
...
...
@@ -215,6 +215,24 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
return
retval
;
}
int
diff_root_tree_sha1
(
const
unsigned
char
*
new
,
const
char
*
base
,
struct
diff_options
*
opt
)
{
int
retval
;
void
*
tree
;
struct
tree_desc
empty
,
real
;
tree
=
read_object_with_reference
(
new
,
tree_type
,
&
real
.
size
,
NULL
);
if
(
!
tree
)
die
(
"unable to read root tree (%s)"
,
sha1_to_hex
(
new
));
real
.
buf
=
tree
;
empty
.
size
=
0
;
empty
.
buf
=
""
;
retval
=
diff_tree
(
&
empty
,
&
real
,
base
,
opt
);
free
(
tree
);
return
retval
;
}
static
int
count_paths
(
const
char
**
paths
)
{
int
i
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录