Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
5f809ff5
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,发现更多精彩内容 >>
提交
5f809ff5
编写于
10月 30, 2009
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
fixup tr/stash-format merge
上级
d39d6671
b7b10385
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
192 addition
and
79 deletion
+192
-79
Documentation/git-stash.txt
Documentation/git-stash.txt
+1
-2
Documentation/pretty-formats.txt
Documentation/pretty-formats.txt
+9
-0
archive.c
archive.c
+3
-1
builtin-branch.c
builtin-branch.c
+2
-1
builtin-checkout.c
builtin-checkout.c
+2
-1
builtin-commit.c
builtin-commit.c
+6
-2
builtin-log.c
builtin-log.c
+2
-1
builtin-merge.c
builtin-merge.c
+5
-2
builtin-rev-list.c
builtin-rev-list.c
+4
-3
builtin-shortlog.c
builtin-shortlog.c
+6
-3
builtin-show-branch.c
builtin-show-branch.c
+2
-2
commit.h
commit.h
+14
-6
git-stash.sh
git-stash.sh
+1
-7
log-tree.c
log-tree.c
+14
-11
pretty.c
pretty.c
+31
-13
reflog-walk.c
reflog-walk.c
+61
-22
reflog-walk.h
reflog-walk.h
+8
-0
submodule.c
submodule.c
+3
-2
t/t6006-rev-list-format.sh
t/t6006-rev-list-format.sh
+18
-0
未找到文件。
Documentation/git-stash.txt
浏览文件 @
5f809ff5
...
...
@@ -78,8 +78,7 @@ stash@{1}: On master: 9cc0589... Add git-stash
----------------------------------------------------------------
+
The command takes options applicable to the 'git-log'
command to control what is shown and how. If no options are set, the
default is `-n 10`. See linkgit:git-log[1].
command to control what is shown and how. See linkgit:git-log[1].
show [<stash>]::
...
...
Documentation/pretty-formats.txt
浏览文件 @
5f809ff5
...
...
@@ -123,6 +123,9 @@ The placeholders are:
- '%s': subject
- '%f': sanitized subject line, suitable for a filename
- '%b': body
- '%gD': reflog selector, e.g., `refs/stash@\{1\}`
- '%gd': shortened reflog selector, e.g., `stash@\{1\}`
- '%gs': reflog subject
- '%Cred': switch color to red
- '%Cgreen': switch color to green
- '%Cblue': switch color to blue
...
...
@@ -132,6 +135,12 @@ The placeholders are:
- '%n': newline
- '%x00': print a byte from a hex code
NOTE: Some placeholders may depend on other options given to the
revision traversal engine. For example, the `%g*` reflog options will
insert an empty string unless we are traversing reflog entries (e.g., by
`git log -g`). The `%d` placeholder will use the "short" decoration
format if `--decorate` was not already provided on the command line.
* 'tformat:'
+
The 'tformat:' format works exactly like 'format:', except that it
...
...
archive.c
浏览文件 @
5f809ff5
...
...
@@ -31,6 +31,8 @@ static void format_subst(const struct commit *commit,
{
char
*
to_free
=
NULL
;
struct
strbuf
fmt
=
STRBUF_INIT
;
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
date_mode
=
DATE_NORMAL
;
if
(
src
==
buf
->
buf
)
to_free
=
strbuf_detach
(
buf
,
NULL
);
...
...
@@ -48,7 +50,7 @@ static void format_subst(const struct commit *commit,
strbuf_add
(
&
fmt
,
b
+
8
,
c
-
b
-
8
);
strbuf_add
(
buf
,
src
,
b
-
src
);
format_commit_message
(
commit
,
fmt
.
buf
,
buf
,
DATE_NORMAL
);
format_commit_message
(
commit
,
fmt
.
buf
,
buf
,
&
ctx
);
len
-=
c
+
1
-
src
;
src
=
c
+
1
;
}
...
...
builtin-branch.c
浏览文件 @
5f809ff5
...
...
@@ -387,8 +387,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
commit
=
item
->
commit
;
if
(
commit
&&
!
parse_commit
(
commit
))
{
struct
pretty_print_context
ctx
=
{
0
};
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
subject
,
0
,
NULL
,
NULL
,
0
,
0
);
&
subject
,
&
ctx
);
sub
=
subject
.
buf
;
}
...
...
builtin-checkout.c
浏览文件 @
5f809ff5
...
...
@@ -302,8 +302,9 @@ static void show_local_changes(struct object *head)
static
void
describe_detached_head
(
char
*
msg
,
struct
commit
*
commit
)
{
struct
strbuf
sb
=
STRBUF_INIT
;
struct
pretty_print_context
ctx
=
{
0
};
parse_commit
(
commit
);
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
sb
,
0
,
NULL
,
NULL
,
0
,
0
);
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
sb
,
&
ctx
);
fprintf
(
stderr
,
"%s %s... %s
\n
"
,
msg
,
find_unique_abbrev
(
commit
->
object
.
sha1
,
DEFAULT_ABBREV
),
sb
.
buf
);
strbuf_release
(
&
sb
);
...
...
builtin-commit.c
浏览文件 @
5f809ff5
...
...
@@ -725,8 +725,10 @@ static const char *find_author_by_nickname(const char *name)
prepare_revision_walk
(
&
revs
);
commit
=
get_revision
(
&
revs
);
if
(
commit
)
{
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
date_mode
=
DATE_NORMAL
;
strbuf_release
(
&
buf
);
format_commit_message
(
commit
,
"%an <%ae>"
,
&
buf
,
DATE_NORMAL
);
format_commit_message
(
commit
,
"%an <%ae>"
,
&
buf
,
&
ctx
);
return
strbuf_detach
(
&
buf
,
NULL
);
}
die
(
"No existing author found with '%s'"
,
name
);
...
...
@@ -983,8 +985,10 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
initial_commit
?
" (root-commit)"
:
""
);
if
(
!
log_tree_commit
(
&
rev
,
commit
))
{
struct
pretty_print_context
ctx
=
{
0
};
struct
strbuf
buf
=
STRBUF_INIT
;
format_commit_message
(
commit
,
format
+
7
,
&
buf
,
DATE_NORMAL
);
ctx
.
date_mode
=
DATE_NORMAL
;
format_commit_message
(
commit
,
format
+
7
,
&
buf
,
&
ctx
);
printf
(
"%s
\n
"
,
buf
.
buf
);
strbuf_release
(
&
buf
);
}
...
...
builtin-log.c
浏览文件 @
5f809ff5
...
...
@@ -1304,8 +1304,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
if
(
verbose
)
{
struct
strbuf
buf
=
STRBUF_INIT
;
struct
pretty_print_context
ctx
=
{
0
};
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
buf
,
0
,
NULL
,
NULL
,
0
,
0
);
&
buf
,
&
ctx
);
printf
(
"%c %s %s
\n
"
,
sign
,
sha1_to_hex
(
commit
->
object
.
sha1
),
buf
.
buf
);
strbuf_release
(
&
buf
);
...
...
builtin-merge.c
浏览文件 @
5f809ff5
...
...
@@ -264,6 +264,7 @@ static void squash_message(void)
struct
strbuf
out
=
STRBUF_INIT
;
struct
commit_list
*
j
;
int
fd
;
struct
pretty_print_context
ctx
=
{
0
};
printf
(
"Squash commit -- not updating HEAD
\n
"
);
fd
=
open
(
git_path
(
"SQUASH_MSG"
),
O_WRONLY
|
O_CREAT
,
0666
);
...
...
@@ -285,13 +286,15 @@ static void squash_message(void)
if
(
prepare_revision_walk
(
&
rev
))
die
(
"revision walk setup failed"
);
ctx
.
abbrev
=
rev
.
abbrev
;
ctx
.
date_mode
=
rev
.
date_mode
;
strbuf_addstr
(
&
out
,
"Squashed commit of the following:
\n
"
);
while
((
commit
=
get_revision
(
&
rev
))
!=
NULL
)
{
strbuf_addch
(
&
out
,
'\n'
);
strbuf_addf
(
&
out
,
"commit %s
\n
"
,
sha1_to_hex
(
commit
->
object
.
sha1
));
pretty_print_commit
(
rev
.
commit_format
,
commit
,
&
out
,
rev
.
abbrev
,
NULL
,
NULL
,
rev
.
date_mode
,
0
);
pretty_print_commit
(
rev
.
commit_format
,
commit
,
&
out
,
&
ctx
);
}
if
(
write
(
fd
,
out
.
buf
,
out
.
len
)
<
0
)
die_errno
(
"Writing SQUASH_MSG"
);
...
...
builtin-rev-list.c
浏览文件 @
5f809ff5
...
...
@@ -96,9 +96,10 @@ static void show_commit(struct commit *commit, void *data)
if
(
revs
->
verbose_header
&&
commit
->
buffer
)
{
struct
strbuf
buf
=
STRBUF_INIT
;
pretty_print_commit
(
revs
->
commit_format
,
commit
,
&
buf
,
revs
->
abbrev
,
NULL
,
NULL
,
revs
->
date_mode
,
0
);
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
abbrev
=
revs
->
abbrev
;
ctx
.
date_mode
=
revs
->
date_mode
;
pretty_print_commit
(
revs
->
commit_format
,
commit
,
&
buf
,
&
ctx
);
if
(
revs
->
graph
)
{
if
(
buf
.
len
)
{
if
(
revs
->
commit_format
!=
CMIT_FMT_ONELINE
)
...
...
builtin-shortlog.c
浏览文件 @
5f809ff5
...
...
@@ -158,9 +158,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
sha1_to_hex
(
commit
->
object
.
sha1
));
if
(
log
->
user_format
)
{
struct
strbuf
buf
=
STRBUF_INIT
;
pretty_print_commit
(
CMIT_FMT_USERFORMAT
,
commit
,
&
buf
,
DEFAULT_ABBREV
,
""
,
""
,
DATE_NORMAL
,
0
);
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
abbrev
=
DEFAULT_ABBREV
;
ctx
.
subject
=
""
;
ctx
.
after_subject
=
""
;
ctx
.
date_mode
=
DATE_NORMAL
;
pretty_print_commit
(
CMIT_FMT_USERFORMAT
,
commit
,
&
buf
,
&
ctx
);
insert_one_record
(
log
,
author
,
buf
.
buf
);
strbuf_release
(
&
buf
);
return
;
...
...
builtin-show-branch.c
浏览文件 @
5f809ff5
...
...
@@ -293,8 +293,8 @@ static void show_one_commit(struct commit *commit, int no_name)
struct
commit_name
*
name
=
commit
->
util
;
if
(
commit
->
object
.
parsed
)
{
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
pretty
,
0
,
NULL
,
NULL
,
0
,
0
);
struct
pretty_print_context
ctx
=
{
0
};
pretty_print_commit
(
CMIT_FMT_ONELINE
,
commit
,
&
pretty
,
&
ctx
);
pretty_str
=
pretty
.
buf
;
}
if
(
!
prefixcmp
(
pretty_str
,
"[PATCH] "
))
...
...
commit.h
浏览文件 @
5f809ff5
...
...
@@ -63,6 +63,16 @@ enum cmit_fmt {
CMIT_FMT_UNSPECIFIED
,
};
struct
pretty_print_context
{
int
abbrev
;
const
char
*
subject
;
const
char
*
after_subject
;
enum
date_mode
date_mode
;
int
need_8bit_cte
;
struct
reflog_walk_info
*
reflog_info
;
};
extern
int
non_ascii
(
int
);
extern
int
has_non_ascii
(
const
char
*
text
);
struct
rev_info
;
/* in revision.h, it circularly uses enum cmit_fmt */
...
...
@@ -71,12 +81,10 @@ extern char *reencode_commit_message(const struct commit *commit,
extern
void
get_commit_format
(
const
char
*
arg
,
struct
rev_info
*
);
extern
void
format_commit_message
(
const
struct
commit
*
commit
,
const
char
*
format
,
struct
strbuf
*
sb
,
enum
date_mode
dmode
);
extern
void
pretty_print_commit
(
enum
cmit_fmt
fmt
,
const
struct
commit
*
,
struct
strbuf
*
,
int
abbrev
,
const
char
*
subject
,
const
char
*
after_subject
,
enum
date_mode
,
int
need_8bit_cte
);
const
struct
pretty_print_context
*
context
);
extern
void
pretty_print_commit
(
enum
cmit_fmt
fmt
,
const
struct
commit
*
commit
,
struct
strbuf
*
sb
,
const
struct
pretty_print_context
*
context
);
void
pp_user_info
(
const
char
*
what
,
enum
cmit_fmt
fmt
,
struct
strbuf
*
sb
,
const
char
*
line
,
enum
date_mode
dmode
,
const
char
*
encoding
);
...
...
git-stash.sh
浏览文件 @
5f809ff5
...
...
@@ -205,8 +205,7 @@ have_stash () {
list_stash
()
{
have_stash
||
return
0
git log
--no-color
--pretty
=
oneline
-g
"
$@
"
$ref_stash
--
|
sed
-n
-e
's/^[.0-9a-f]* refs\///p'
git log
--format
=
"%gd: %gs"
-g
"
$@
"
$ref_stash
--
}
show_stash
()
{
...
...
@@ -383,11 +382,6 @@ test -n "$seen_non_option" || set "save" "$@"
case
"
$1
"
in
list
)
shift
if
test
$#
=
0
then
set
x
-n
10
shift
fi
list_stash
"
$@
"
;;
show
)
...
...
log-tree.c
浏览文件 @
5f809ff5
...
...
@@ -179,8 +179,10 @@ void get_patch_filename(struct commit *commit, int nr, const char *suffix,
strbuf_addf
(
buf
,
commit
?
"%04d-"
:
"%d"
,
nr
);
if
(
commit
)
{
int
max_len
=
start_len
+
FORMAT_PATCH_NAME_MAX
-
suffix_len
;
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
date_mode
=
DATE_NORMAL
;
format_commit_message
(
commit
,
"%f"
,
buf
,
DATE_NORMAL
);
format_commit_message
(
commit
,
"%f"
,
buf
,
&
ctx
);
if
(
max_len
<
buf
->
len
)
strbuf_setlen
(
buf
,
max_len
);
strbuf_addstr
(
buf
,
suffix
);
...
...
@@ -277,10 +279,9 @@ void show_log(struct rev_info *opt)
struct
strbuf
msgbuf
=
STRBUF_INIT
;
struct
log_info
*
log
=
opt
->
loginfo
;
struct
commit
*
commit
=
log
->
commit
,
*
parent
=
log
->
parent
;
int
abbrev
=
opt
->
diffopt
.
abbrev
;
int
abbrev_commit
=
opt
->
abbrev_commit
?
opt
->
abbrev
:
40
;
const
char
*
subject
=
NULL
,
*
extra_headers
=
opt
->
extra_headers
;
int
need_8bit_cte
=
0
;
const
char
*
extra_headers
=
opt
->
extra_headers
;
struct
pretty_print_context
ctx
=
{
0
}
;
opt
->
loginfo
=
NULL
;
if
(
!
opt
->
verbose_header
)
{
...
...
@@ -347,8 +348,8 @@ void show_log(struct rev_info *opt)
*/
if
(
opt
->
commit_format
==
CMIT_FMT_EMAIL
)
{
log_write_email_headers
(
opt
,
commit
,
&
subject
,
&
extra_headers
,
&
need_8bit_cte
);
log_write_email_headers
(
opt
,
commit
,
&
ctx
.
subject
,
&
extra_headers
,
&
ctx
.
need_8bit_cte
);
}
else
if
(
opt
->
commit_format
!=
CMIT_FMT_USERFORMAT
)
{
fputs
(
diff_get_color_opt
(
&
opt
->
diffopt
,
DIFF_COMMIT
),
stdout
);
if
(
opt
->
commit_format
!=
CMIT_FMT_ONELINE
)
...
...
@@ -405,11 +406,13 @@ void show_log(struct rev_info *opt)
/*
* And then the pretty-printed message itself
*/
if
(
need_8bit_cte
>=
0
)
need_8bit_cte
=
has_non_ascii
(
opt
->
add_signoff
);
pretty_print_commit
(
opt
->
commit_format
,
commit
,
&
msgbuf
,
abbrev
,
subject
,
extra_headers
,
opt
->
date_mode
,
need_8bit_cte
);
if
(
ctx
.
need_8bit_cte
>=
0
)
ctx
.
need_8bit_cte
=
has_non_ascii
(
opt
->
add_signoff
);
ctx
.
date_mode
=
opt
->
date_mode
;
ctx
.
abbrev
=
opt
->
diffopt
.
abbrev
;
ctx
.
after_subject
=
extra_headers
;
ctx
.
reflog_info
=
opt
->
reflog_info
;
pretty_print_commit
(
opt
->
commit_format
,
commit
,
&
msgbuf
,
&
ctx
);
if
(
opt
->
add_signoff
)
append_signoff
(
&
msgbuf
,
opt
->
add_signoff
);
...
...
pretty.c
浏览文件 @
5f809ff5
...
...
@@ -7,6 +7,7 @@
#include "mailmap.h"
#include "log-tree.h"
#include "color.h"
#include "reflog-walk.h"
static
char
*
user_format
;
...
...
@@ -442,7 +443,7 @@ struct chunk {
struct
format_commit_context
{
const
struct
commit
*
commit
;
enum
date_mode
dmode
;
const
struct
pretty_print_context
*
pretty_ctx
;
unsigned
commit_header_parsed
:
1
;
unsigned
commit_message_parsed
:
1
;
...
...
@@ -701,6 +702,22 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case
'd'
:
format_decoration
(
sb
,
commit
);
return
1
;
case
'g'
:
/* reflog info */
switch
(
placeholder
[
1
])
{
case
'd'
:
/* reflog selector */
case
'D'
:
if
(
c
->
pretty_ctx
->
reflog_info
)
get_reflog_selector
(
sb
,
c
->
pretty_ctx
->
reflog_info
,
c
->
pretty_ctx
->
date_mode
,
(
placeholder
[
1
]
==
'd'
));
return
2
;
case
's'
:
/* reflog message */
if
(
c
->
pretty_ctx
->
reflog_info
)
get_reflog_message
(
sb
,
c
->
pretty_ctx
->
reflog_info
);
return
2
;
}
return
0
;
/* unknown %g placeholder */
}
/* For the rest we have to parse the commit header. */
...
...
@@ -711,11 +728,11 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case
'a'
:
/* author ... */
return
format_person_part
(
sb
,
placeholder
[
1
],
msg
+
c
->
author
.
off
,
c
->
author
.
len
,
c
->
d
mode
);
c
->
pretty_ctx
->
date_
mode
);
case
'c'
:
/* committer ... */
return
format_person_part
(
sb
,
placeholder
[
1
],
msg
+
c
->
committer
.
off
,
c
->
committer
.
len
,
c
->
d
mode
);
c
->
pretty_ctx
->
date_
mode
);
case
'e'
:
/* encoding */
strbuf_add
(
sb
,
msg
+
c
->
encoding
.
off
,
c
->
encoding
.
len
);
return
1
;
...
...
@@ -741,13 +758,13 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void
format_commit_message
(
const
struct
commit
*
commit
,
const
char
*
format
,
struct
strbuf
*
sb
,
enum
date_mode
dmode
)
const
struct
pretty_print_context
*
pretty_ctx
)
{
struct
format_commit_context
context
;
memset
(
&
context
,
0
,
sizeof
(
context
));
context
.
commit
=
commit
;
context
.
dmode
=
dmode
;
context
.
pretty_ctx
=
pretty_ctx
;
strbuf_expand
(
sb
,
format
,
format_commit_item
,
&
context
);
}
...
...
@@ -900,18 +917,18 @@ char *reencode_commit_message(const struct commit *commit, const char **encoding
}
void
pretty_print_commit
(
enum
cmit_fmt
fmt
,
const
struct
commit
*
commit
,
struct
strbuf
*
sb
,
int
abbrev
,
const
char
*
subject
,
const
char
*
after_subject
,
enum
date_mode
dmode
,
int
need_8bit_cte
)
struct
strbuf
*
sb
,
const
struct
pretty_print_context
*
context
)
{
unsigned
long
beginning_of_body
;
int
indent
=
4
;
const
char
*
msg
=
commit
->
buffer
;
char
*
reencoded
;
const
char
*
encoding
;
int
need_8bit_cte
=
context
->
need_8bit_cte
;
if
(
fmt
==
CMIT_FMT_USERFORMAT
)
{
format_commit_message
(
commit
,
user_format
,
sb
,
dmode
);
format_commit_message
(
commit
,
user_format
,
sb
,
context
);
return
;
}
...
...
@@ -946,8 +963,9 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
}
}
pp_header
(
fmt
,
abbrev
,
dmode
,
encoding
,
commit
,
&
msg
,
sb
);
if
(
fmt
!=
CMIT_FMT_ONELINE
&&
!
subject
)
{
pp_header
(
fmt
,
context
->
abbrev
,
context
->
date_mode
,
encoding
,
commit
,
&
msg
,
sb
);
if
(
fmt
!=
CMIT_FMT_ONELINE
&&
!
context
->
subject
)
{
strbuf_addch
(
sb
,
'\n'
);
}
...
...
@@ -956,8 +974,8 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
/* These formats treat the title line specially. */
if
(
fmt
==
CMIT_FMT_ONELINE
||
fmt
==
CMIT_FMT_EMAIL
)
pp_title_line
(
fmt
,
&
msg
,
sb
,
subject
,
after_subject
,
encoding
,
need_8bit_cte
);
pp_title_line
(
fmt
,
&
msg
,
sb
,
context
->
subject
,
context
->
after_subject
,
encoding
,
need_8bit_cte
);
beginning_of_body
=
sb
->
len
;
if
(
fmt
!=
CMIT_FMT_ONELINE
)
...
...
reflog-walk.c
浏览文件 @
5f809ff5
...
...
@@ -8,6 +8,7 @@
struct
complete_reflogs
{
char
*
ref
;
const
char
*
short_ref
;
struct
reflog_info
{
unsigned
char
osha1
[
20
],
nsha1
[
20
];
char
*
email
;
...
...
@@ -241,36 +242,74 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
commit
->
object
.
flags
&=
~
(
ADDED
|
SEEN
|
SHOWN
);
}
void
show_reflog_message
(
struct
reflog_walk_info
*
info
,
int
oneline
,
void
get_reflog_selector
(
struct
strbuf
*
sb
,
struct
reflog_walk_info
*
reflog_info
,
enum
date_mode
dmode
,
int
shorten
)
{
struct
commit_reflog
*
commit_reflog
=
reflog_info
->
last_commit_reflog
;
struct
reflog_info
*
info
;
const
char
*
printed_ref
;
if
(
!
commit_reflog
)
return
;
if
(
shorten
)
{
if
(
!
commit_reflog
->
reflogs
->
short_ref
)
commit_reflog
->
reflogs
->
short_ref
=
shorten_unambiguous_ref
(
commit_reflog
->
reflogs
->
ref
,
0
);
printed_ref
=
commit_reflog
->
reflogs
->
short_ref
;
}
else
{
printed_ref
=
commit_reflog
->
reflogs
->
ref
;
}
strbuf_addf
(
sb
,
"%s@{"
,
printed_ref
);
if
(
commit_reflog
->
flag
||
dmode
)
{
info
=
&
commit_reflog
->
reflogs
->
items
[
commit_reflog
->
recno
+
1
];
strbuf_addstr
(
sb
,
show_date
(
info
->
timestamp
,
info
->
tz
,
dmode
));
}
else
{
strbuf_addf
(
sb
,
"%d"
,
commit_reflog
->
reflogs
->
nr
-
2
-
commit_reflog
->
recno
);
}
strbuf_addch
(
sb
,
'}'
);
}
void
get_reflog_message
(
struct
strbuf
*
sb
,
struct
reflog_walk_info
*
reflog_info
)
{
struct
commit_reflog
*
commit_reflog
=
reflog_info
->
last_commit_reflog
;
struct
reflog_info
*
info
;
size_t
len
;
if
(
!
commit_reflog
)
return
;
info
=
&
commit_reflog
->
reflogs
->
items
[
commit_reflog
->
recno
+
1
];
len
=
strlen
(
info
->
message
);
if
(
len
>
0
)
len
--
;
/* strip away trailing newline */
strbuf_add
(
sb
,
info
->
message
,
len
);
}
void
show_reflog_message
(
struct
reflog_walk_info
*
reflog_info
,
int
oneline
,
enum
date_mode
dmode
)
{
if
(
info
&&
info
->
last_commit_reflog
)
{
struct
commit_reflog
*
commit_reflog
=
info
->
last_commit_reflog
;
if
(
reflog_info
&&
reflog_
info
->
last_commit_reflog
)
{
struct
commit_reflog
*
commit_reflog
=
reflog_
info
->
last_commit_reflog
;
struct
reflog_info
*
info
;
struct
strbuf
selector
=
STRBUF_INIT
;
info
=
&
commit_reflog
->
reflogs
->
items
[
commit_reflog
->
recno
+
1
];
get_reflog_selector
(
&
selector
,
reflog_info
,
dmode
,
0
);
if
(
oneline
)
{
printf
(
"%s@{"
,
commit_reflog
->
reflogs
->
ref
);
if
(
commit_reflog
->
flag
||
dmode
)
printf
(
"%s"
,
show_date
(
info
->
timestamp
,
info
->
tz
,
dmode
));
else
printf
(
"%d"
,
commit_reflog
->
reflogs
->
nr
-
2
-
commit_reflog
->
recno
);
printf
(
"}: %s"
,
info
->
message
);
printf
(
"%s: %s"
,
selector
.
buf
,
info
->
message
);
}
else
{
printf
(
"Reflog: %s@{"
,
commit_reflog
->
reflogs
->
ref
);
if
(
commit_reflog
->
flag
||
dmode
)
printf
(
"%s"
,
show_date
(
info
->
timestamp
,
info
->
tz
,
dmode
));
else
printf
(
"%d"
,
commit_reflog
->
reflogs
->
nr
-
2
-
commit_reflog
->
recno
);
printf
(
"} (%s)
\n
Reflog message: %s"
,
info
->
email
,
info
->
message
);
printf
(
"Reflog: %s (%s)
\n
Reflog message: %s"
,
selector
.
buf
,
info
->
email
,
info
->
message
);
}
strbuf_release
(
&
selector
);
}
}
reflog-walk.h
浏览文件 @
5f809ff5
...
...
@@ -3,6 +3,8 @@
#include "cache.h"
struct
reflog_walk_info
;
extern
void
init_reflog_walk
(
struct
reflog_walk_info
**
info
);
extern
int
add_reflog_for_walk
(
struct
reflog_walk_info
*
info
,
struct
commit
*
commit
,
const
char
*
name
);
...
...
@@ -10,5 +12,11 @@ extern void fake_reflog_parent(struct reflog_walk_info *info,
struct
commit
*
commit
);
extern
void
show_reflog_message
(
struct
reflog_walk_info
*
info
,
int
,
enum
date_mode
);
extern
void
get_reflog_message
(
struct
strbuf
*
sb
,
struct
reflog_walk_info
*
reflog_info
);
extern
void
get_reflog_selector
(
struct
strbuf
*
sb
,
struct
reflog_walk_info
*
reflog_info
,
enum
date_mode
dmode
,
int
shorten
);
#endif
submodule.c
浏览文件 @
5f809ff5
...
...
@@ -92,6 +92,8 @@ void show_submodule_summary(FILE *f, const char *path,
if
(
!
message
)
{
while
((
commit
=
get_revision
(
&
rev
)))
{
struct
pretty_print_context
ctx
=
{
0
};
ctx
.
date_mode
=
rev
.
date_mode
;
strbuf_setlen
(
&
sb
,
0
);
if
(
commit
->
object
.
flags
&
SYMMETRIC_LEFT
)
{
if
(
del
)
...
...
@@ -99,8 +101,7 @@ void show_submodule_summary(FILE *f, const char *path,
}
else
if
(
add
)
strbuf_addstr
(
&
sb
,
add
);
format_commit_message
(
commit
,
format
,
&
sb
,
rev
.
date_mode
);
format_commit_message
(
commit
,
format
,
&
sb
,
&
ctx
);
if
(
reset
)
strbuf_addstr
(
&
sb
,
reset
);
strbuf_addch
(
&
sb
,
'\n'
);
...
...
t/t6006-rev-list-format.sh
浏览文件 @
5f809ff5
...
...
@@ -162,4 +162,22 @@ test_expect_success 'empty email' '
}
'
test_expect_success
'"%h %gD: %gs" is same as git-reflog'
'
git reflog >expect &&
git log -g --format="%h %gD: %gs" >actual &&
test_cmp expect actual
'
test_expect_success
'"%h %gD: %gs" is same as git-reflog (with date)'
'
git reflog --date=raw >expect &&
git log -g --format="%h %gD: %gs" --date=raw >actual &&
test_cmp expect actual
'
test_expect_success
'%gd shortens ref name'
'
echo "master@{0}" >expect.gd-short &&
git log -g -1 --format=%gd refs/heads/master >actual.gd-short &&
test_cmp expect.gd-short actual.gd-short
'
test_done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录