Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
48cbf915
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,发现更多精彩内容 >>
提交
48cbf915
编写于
11月 10, 2009
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jp/dirty-describe'
* jp/dirty-describe: Teach "git describe" --dirty option
上级
25dfd1b9
9f67d2e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
1 deletion
+44
-1
Documentation/git-describe.txt
Documentation/git-describe.txt
+6
-0
builtin-describe.c
builtin-describe.c
+24
-1
t/t6120-describe.sh
t/t6120-describe.sh
+14
-0
未找到文件。
Documentation/git-describe.txt
浏览文件 @
48cbf915
...
...
@@ -9,6 +9,7 @@ git-describe - Show the most recent tag that is reachable from a commit
SYNOPSIS
--------
'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
DESCRIPTION
-----------
...
...
@@ -27,6 +28,11 @@ OPTIONS
<committish>...::
Committish object names to describe.
--dirty[=<mark>]::
Describe the working tree.
It means describe HEAD and appends <mark> (`-dirty` by
default) if the working tree is dirty.
--all::
Instead of using only the annotated tags, use any ref
found in `.git/refs/`. This option enables matching
...
...
builtin-describe.c
浏览文件 @
48cbf915
...
...
@@ -5,12 +5,14 @@
#include "builtin.h"
#include "exec_cmd.h"
#include "parse-options.h"
#include "diff.h"
#define SEEN (1u<<0)
#define MAX_TAGS (FLAG_BITS - 1)
static
const
char
*
const
describe_usage
[]
=
{
"git describe [options] <committish>*"
,
"git describe [options] --dirty"
,
NULL
};
...
...
@@ -23,6 +25,13 @@ static int max_candidates = 10;
static
int
found_names
;
static
const
char
*
pattern
;
static
int
always
;
static
const
char
*
dirty
;
/* diff-index command arguments to check if working tree is dirty. */
static
const
char
*
diff_index_args
[]
=
{
"diff-index"
,
"--quiet"
,
"HEAD"
,
"--"
,
NULL
};
struct
commit_name
{
struct
tag
*
tag
;
...
...
@@ -199,6 +208,8 @@ static void describe(const char *arg, int last_one)
display_name
(
n
);
if
(
longformat
)
show_suffix
(
0
,
n
->
tag
?
n
->
tag
->
tagged
->
sha1
:
sha1
);
if
(
dirty
)
printf
(
"%s"
,
dirty
);
printf
(
"
\n
"
);
return
;
}
...
...
@@ -256,7 +267,10 @@ static void describe(const char *arg, int last_one)
if
(
!
match_cnt
)
{
const
unsigned
char
*
sha1
=
cmit
->
object
.
sha1
;
if
(
always
)
{
printf
(
"%s
\n
"
,
find_unique_abbrev
(
sha1
,
abbrev
));
printf
(
"%s"
,
find_unique_abbrev
(
sha1
,
abbrev
));
if
(
dirty
)
printf
(
"%s"
,
dirty
);
printf
(
"
\n
"
);
return
;
}
die
(
"cannot describe '%s'"
,
sha1_to_hex
(
sha1
));
...
...
@@ -291,6 +305,8 @@ static void describe(const char *arg, int last_one)
display_name
(
all_matches
[
0
].
name
);
if
(
abbrev
)
show_suffix
(
all_matches
[
0
].
depth
,
cmit
->
object
.
sha1
);
if
(
dirty
)
printf
(
"%s"
,
dirty
);
printf
(
"
\n
"
);
if
(
!
last_one
)
...
...
@@ -315,6 +331,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
"only consider tags matching <pattern>"
),
OPT_BOOLEAN
(
0
,
"always"
,
&
always
,
"show abbreviated commit object as fallback"
),
{
OPTION_STRING
,
0
,
"dirty"
,
&
dirty
,
"mark"
,
"append <mark> on dirty working tree (default:
\"
-dirty
\"
)"
,
PARSE_OPT_OPTARG
,
NULL
,
(
intptr_t
)
"-dirty"
},
OPT_END
(),
};
...
...
@@ -355,7 +374,11 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
die
(
"No names found, cannot describe anything."
);
if
(
argc
==
0
)
{
if
(
dirty
&&
!
cmd_diff_index
(
ARRAY_SIZE
(
diff_index_args
)
-
1
,
diff_index_args
,
prefix
))
dirty
=
NULL
;
describe
(
"HEAD"
,
1
);
}
else
if
(
dirty
)
{
die
(
"--dirty is incompatible with committishes"
);
}
else
{
while
(
argc
--
>
0
)
{
describe
(
*
argv
++
,
argc
==
0
);
...
...
t/t6120-describe.sh
浏览文件 @
48cbf915
...
...
@@ -125,6 +125,20 @@ test_expect_success 'rename tag Q back to A' '
test_expect_success
'pack tag refs'
'git pack-refs'
check_describe A-
*
HEAD
check_describe
"A-*[0-9a-f]"
--dirty
test_expect_success
'set-up dirty work tree'
'
echo >>file
'
check_describe
"A-*[0-9a-f]-dirty"
--dirty
check_describe
"A-*[0-9a-f].mod"
--dirty
=
.mod
test_expect_success
'describe --dirty HEAD'
'
test_must_fail git describe --dirty HEAD
'
test_expect_success
'set-up matching pattern tests'
'
git tag -a -m test-annotated test-annotated &&
echo >>file &&
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录