Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
1576f5f7
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,发现更多精彩内容 >>
提交
1576f5f7
编写于
12月 15, 2006
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'js/show'
* js/show: git-show: grok blobs, trees and tags, too
上级
2ce633b9
5d7eeee2
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
115 addition
and
9 deletion
+115
-9
Documentation/git-show.txt
Documentation/git-show.txt
+33
-7
builtin-log.c
builtin-log.c
+81
-1
generate-cmdlist.sh
generate-cmdlist.sh
+1
-1
未找到文件。
Documentation/git-show.txt
浏览文件 @
1576f5f7
...
@@ -3,20 +3,27 @@ git-show(1)
...
@@ -3,20 +3,27 @@ git-show(1)
NAME
NAME
----
----
git-show - Show
one commit with difference it introduce
s
git-show - Show
various types of object
s
SYNOPSIS
SYNOPSIS
--------
--------
'git-show'
<option
>...
'git-show'
[options] <object
>...
DESCRIPTION
DESCRIPTION
-----------
-----------
Shows commit log and textual diff for a single commit. The
Shows one or more objects (blobs, trees, tags and commits).
command internally invokes 'git-rev-list' piped to
'git-diff-tree', and takes command line options for both of
For commits it shows the log message and textual diff. It also
these commands. It also presents the merge commit in a special
presents the merge commit in a special format as produced by
format as produced by 'git-diff-tree --cc'.
'git-diff-tree --cc'.
For tags, it shows the tag message and the referenced objects.
For trees, it shows the names (equivalent to gitlink:git-ls-tree[1]
with \--name-only).
For plain blobs, it shows the plain contents.
This manual page describes only the most frequently used options.
This manual page describes only the most frequently used options.
...
@@ -28,6 +35,25 @@ OPTIONS
...
@@ -28,6 +35,25 @@ OPTIONS
include::pretty-formats.txt[]
include::pretty-formats.txt[]
EXAMPLES
--------
git show v1.0.0::
Shows the tag `v1.0.0`.
git show v1.0.0^{tree}::
Shows the tree pointed to by the tag `v1.0.0`.
git show next~10:Documentation/README
Shows the contents of the file `Documentation/README` as
they were current in the 10th last commit of the branch
`next`.
git show master:Makefile master:t/Makefile
Concatenates the contents of said Makefiles in the head
of the branch `master`.
Author
Author
------
------
Written by Linus Torvalds <torvalds@osdl.org> and
Written by Linus Torvalds <torvalds@osdl.org> and
...
...
builtin-log.c
浏览文件 @
1576f5f7
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "revision.h"
#include "revision.h"
#include "log-tree.h"
#include "log-tree.h"
#include "builtin.h"
#include "builtin.h"
#include "tag.h"
#include <time.h>
#include <time.h>
#include <sys/time.h>
#include <sys/time.h>
...
@@ -71,9 +72,43 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
...
@@ -71,9 +72,43 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
return
cmd_log_walk
(
&
rev
);
return
cmd_log_walk
(
&
rev
);
}
}
static
int
show_object
(
const
unsigned
char
*
sha1
,
int
suppress_header
)
{
unsigned
long
size
;
char
type
[
20
];
char
*
buf
=
read_sha1_file
(
sha1
,
type
,
&
size
);
int
offset
=
0
;
if
(
!
buf
)
return
error
(
"Could not read object %s"
,
sha1_to_hex
(
sha1
));
if
(
suppress_header
)
while
(
offset
<
size
&&
buf
[
offset
++
]
!=
'\n'
)
{
int
new_offset
=
offset
;
while
(
new_offset
<
size
&&
buf
[
new_offset
++
]
!=
'\n'
)
;
/* do nothing */
offset
=
new_offset
;
}
if
(
offset
<
size
)
fwrite
(
buf
+
offset
,
size
-
offset
,
1
,
stdout
);
free
(
buf
);
return
0
;
}
static
int
show_tree_object
(
const
unsigned
char
*
sha1
,
const
char
*
base
,
int
baselen
,
const
char
*
pathname
,
unsigned
mode
,
int
stage
)
{
printf
(
"%s%s
\n
"
,
pathname
,
S_ISDIR
(
mode
)
?
"/"
:
""
);
return
0
;
}
int
cmd_show
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
int
cmd_show
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
{
{
struct
rev_info
rev
;
struct
rev_info
rev
;
struct
object_array_entry
*
objects
;
int
i
,
count
,
ret
=
0
;
git_config
(
git_log_config
);
git_config
(
git_log_config
);
init_revisions
(
&
rev
,
prefix
);
init_revisions
(
&
rev
,
prefix
);
...
@@ -85,7 +120,52 @@ int cmd_show(int argc, const char **argv, const char *prefix)
...
@@ -85,7 +120,52 @@ int cmd_show(int argc, const char **argv, const char *prefix)
rev
.
ignore_merges
=
0
;
rev
.
ignore_merges
=
0
;
rev
.
no_walk
=
1
;
rev
.
no_walk
=
1
;
cmd_log_init
(
argc
,
argv
,
prefix
,
&
rev
);
cmd_log_init
(
argc
,
argv
,
prefix
,
&
rev
);
return
cmd_log_walk
(
&
rev
);
count
=
rev
.
pending
.
nr
;
objects
=
rev
.
pending
.
objects
;
for
(
i
=
0
;
i
<
count
&&
!
ret
;
i
++
)
{
struct
object
*
o
=
objects
[
i
].
item
;
const
char
*
name
=
objects
[
i
].
name
;
switch
(
o
->
type
)
{
case
OBJ_BLOB
:
ret
=
show_object
(
o
->
sha1
,
0
);
break
;
case
OBJ_TAG
:
{
struct
tag
*
t
=
(
struct
tag
*
)
o
;
printf
(
"%stag %s%s
\n\n
"
,
diff_get_color
(
rev
.
diffopt
.
color_diff
,
DIFF_COMMIT
),
t
->
tag
,
diff_get_color
(
rev
.
diffopt
.
color_diff
,
DIFF_RESET
));
ret
=
show_object
(
o
->
sha1
,
1
);
objects
[
i
].
item
=
(
struct
object
*
)
t
->
tagged
;
i
--
;
break
;
}
case
OBJ_TREE
:
printf
(
"%stree %s%s
\n\n
"
,
diff_get_color
(
rev
.
diffopt
.
color_diff
,
DIFF_COMMIT
),
name
,
diff_get_color
(
rev
.
diffopt
.
color_diff
,
DIFF_RESET
));
read_tree_recursive
((
struct
tree
*
)
o
,
""
,
0
,
0
,
NULL
,
show_tree_object
);
break
;
case
OBJ_COMMIT
:
rev
.
pending
.
nr
=
rev
.
pending
.
alloc
=
0
;
rev
.
pending
.
objects
=
NULL
;
add_object_array
(
o
,
name
,
&
rev
.
pending
);
ret
=
cmd_log_walk
(
&
rev
);
break
;
default:
ret
=
error
(
"Unknown type: %d"
,
o
->
type
);
}
}
free
(
objects
);
return
ret
;
}
}
int
cmd_log
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
int
cmd_log
(
int
argc
,
const
char
**
argv
,
const
char
*
prefix
)
...
...
generate-cmdlist.sh
浏览文件 @
1576f5f7
...
@@ -4,7 +4,7 @@ echo "/* Automatically generated by $0 */
...
@@ -4,7 +4,7 @@ echo "/* Automatically generated by $0 */
struct cmdname_help
struct cmdname_help
{
{
char name[16];
char name[16];
char help[
64
];
char help[
80
];
};
};
struct cmdname_help common_cmds[] = {"
struct cmdname_help common_cmds[] = {"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录