Merge branch 'jc/maint-limit-note-output' into maint
* jc/maint-limit-note-output: Fix "log --oneline" not to show notes Fix "log" family not to be too agressive about showing notesmaint
commit
b401a12a2c
|
|
@ -28,3 +28,11 @@ people using 80-column terminals.
|
||||||
command to re-code the commit log message in the encoding
|
command to re-code the commit log message in the encoding
|
||||||
preferred by the user. For non plumbing commands this
|
preferred by the user. For non plumbing commands this
|
||||||
defaults to UTF-8.
|
defaults to UTF-8.
|
||||||
|
|
||||||
|
--no-notes::
|
||||||
|
--show-notes::
|
||||||
|
Show the notes (see linkgit:git-notes[1]) that annotate the
|
||||||
|
commit, when showing the commit log message. This is the default
|
||||||
|
for `git log`, `git show` and `git whatchanged` commands when
|
||||||
|
there is no `--pretty`, `--format` nor `--oneline` option is
|
||||||
|
given on the command line.
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
|
||||||
usage(builtin_log_usage);
|
usage(builtin_log_usage);
|
||||||
argc = setup_revisions(argc, argv, rev, "HEAD");
|
argc = setup_revisions(argc, argv, rev, "HEAD");
|
||||||
|
|
||||||
|
if (!rev->show_notes_given && !rev->pretty_given)
|
||||||
|
rev->show_notes = 1;
|
||||||
|
|
||||||
if (rev->diffopt.pickaxe || rev->diffopt.filter)
|
if (rev->diffopt.pickaxe || rev->diffopt.filter)
|
||||||
rev->always_show_header = 0;
|
rev->always_show_header = 0;
|
||||||
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
|
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
|
||||||
|
|
|
||||||
1
commit.h
1
commit.h
|
|
@ -70,6 +70,7 @@ struct pretty_print_context
|
||||||
const char *after_subject;
|
const char *after_subject;
|
||||||
enum date_mode date_mode;
|
enum date_mode date_mode;
|
||||||
int need_8bit_cte;
|
int need_8bit_cte;
|
||||||
|
int show_notes;
|
||||||
struct reflog_walk_info *reflog_info;
|
struct reflog_walk_info *reflog_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,7 @@ void show_log(struct rev_info *opt)
|
||||||
struct pretty_print_context ctx = {0};
|
struct pretty_print_context ctx = {0};
|
||||||
|
|
||||||
opt->loginfo = NULL;
|
opt->loginfo = NULL;
|
||||||
|
ctx.show_notes = opt->show_notes;
|
||||||
if (!opt->verbose_header) {
|
if (!opt->verbose_header) {
|
||||||
graph_show_commit(opt->graph);
|
graph_show_commit(opt->graph);
|
||||||
|
|
||||||
|
|
|
||||||
2
pretty.c
2
pretty.c
|
|
@ -1094,7 +1094,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
|
||||||
if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
|
if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
|
||||||
strbuf_addch(sb, '\n');
|
strbuf_addch(sb, '\n');
|
||||||
|
|
||||||
if (fmt != CMIT_FMT_ONELINE)
|
if (context->show_notes)
|
||||||
get_commit_notes(commit, sb, encoding,
|
get_commit_notes(commit, sb, encoding,
|
||||||
NOTES_SHOW_HEADER | NOTES_INDENT);
|
NOTES_SHOW_HEADER | NOTES_INDENT);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1161,13 +1161,22 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
|
||||||
revs->verbose_header = 1;
|
revs->verbose_header = 1;
|
||||||
} else if (!strcmp(arg, "--pretty")) {
|
} else if (!strcmp(arg, "--pretty")) {
|
||||||
revs->verbose_header = 1;
|
revs->verbose_header = 1;
|
||||||
|
revs->pretty_given = 1;
|
||||||
get_commit_format(arg+8, revs);
|
get_commit_format(arg+8, revs);
|
||||||
} else if (!prefixcmp(arg, "--pretty=") || !prefixcmp(arg, "--format=")) {
|
} else if (!prefixcmp(arg, "--pretty=") || !prefixcmp(arg, "--format=")) {
|
||||||
revs->verbose_header = 1;
|
revs->verbose_header = 1;
|
||||||
|
revs->pretty_given = 1;
|
||||||
get_commit_format(arg+9, revs);
|
get_commit_format(arg+9, revs);
|
||||||
|
} else if (!strcmp(arg, "--show-notes")) {
|
||||||
|
revs->show_notes = 1;
|
||||||
|
revs->show_notes_given = 1;
|
||||||
|
} else if (!strcmp(arg, "--no-notes")) {
|
||||||
|
revs->show_notes = 0;
|
||||||
|
revs->show_notes_given = 1;
|
||||||
} else if (!strcmp(arg, "--oneline")) {
|
} else if (!strcmp(arg, "--oneline")) {
|
||||||
revs->verbose_header = 1;
|
revs->verbose_header = 1;
|
||||||
get_commit_format("oneline", revs);
|
get_commit_format("oneline", revs);
|
||||||
|
revs->pretty_given = 1;
|
||||||
revs->abbrev_commit = 1;
|
revs->abbrev_commit = 1;
|
||||||
} else if (!strcmp(arg, "--graph")) {
|
} else if (!strcmp(arg, "--graph")) {
|
||||||
revs->topo_order = 1;
|
revs->topo_order = 1;
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@ struct rev_info {
|
||||||
/* Format info */
|
/* Format info */
|
||||||
unsigned int shown_one:1,
|
unsigned int shown_one:1,
|
||||||
show_merge:1,
|
show_merge:1,
|
||||||
|
show_notes:1,
|
||||||
|
show_notes_given:1,
|
||||||
|
pretty_given:1,
|
||||||
abbrev_commit:1,
|
abbrev_commit:1,
|
||||||
use_terminator:1,
|
use_terminator:1,
|
||||||
missing_newline:1,
|
missing_newline:1,
|
||||||
|
|
|
||||||
|
|
@ -147,4 +147,63 @@ test_expect_success 'show -m and -F notes' '
|
||||||
test_cmp expect-m-and-F output
|
test_cmp expect-m-and-F output
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >expect << EOF
|
||||||
|
commit 15023535574ded8b1a89052b32673f84cf9582b8
|
||||||
|
tree e070e3af51011e47b183c33adf9736736a525709
|
||||||
|
parent 1584215f1d29c65e99c6c6848626553fdd07fd75
|
||||||
|
author A U Thor <author@example.com> 1112912173 -0700
|
||||||
|
committer C O Mitter <committer@example.com> 1112912173 -0700
|
||||||
|
|
||||||
|
4th
|
||||||
|
EOF
|
||||||
|
test_expect_success 'git log --pretty=raw does not show notes' '
|
||||||
|
git log -1 --pretty=raw >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >>expect <<EOF
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
spam
|
||||||
|
$whitespace
|
||||||
|
xyzzy
|
||||||
|
$whitespace
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
EOF
|
||||||
|
test_expect_success 'git log --show-notes' '
|
||||||
|
git log -1 --pretty=raw --show-notes >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git log --no-notes' '
|
||||||
|
git log -1 --no-notes >output &&
|
||||||
|
! grep spam output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git format-patch does not show notes' '
|
||||||
|
git format-patch -1 --stdout >output &&
|
||||||
|
! grep spam output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git format-patch --show-notes does show notes' '
|
||||||
|
git format-patch --show-notes -1 --stdout >output &&
|
||||||
|
grep spam output
|
||||||
|
'
|
||||||
|
|
||||||
|
for pretty in \
|
||||||
|
"" --pretty --pretty=raw --pretty=short --pretty=medium \
|
||||||
|
--pretty=full --pretty=fuller --pretty=format:%s --oneline
|
||||||
|
do
|
||||||
|
case "$pretty" in
|
||||||
|
"") p= not= negate="" ;;
|
||||||
|
?*) p="$pretty" not=" not" negate="!" ;;
|
||||||
|
esac
|
||||||
|
test_expect_success "git show $pretty does$not show notes" '
|
||||||
|
git show $p >output &&
|
||||||
|
eval "$negate grep spam output"
|
||||||
|
'
|
||||||
|
done
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue