summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-11 10:03:33 -0800
committerJunio C Hamano <gitster@pobox.com>2017-02-21 12:12:23 -0800
commit81c03980b871caa2d27aa91632684595b32e76e3 (patch)
tree86b345e84d9e5f63abed28f763f61fd2c0187e4b
parent44cfe190b80bffcf5ea37f725e77dd84e294b57d (diff)
downloadgit-lt/oneline-decoration-at-end.tar.gz
log: fix regression to "--source" when "--decorate" was updatedlt/oneline-decoration-at-end
Split out the logic to show "--source" from showing "--decorate" annotation into a separate show_source() helper. Most of the time this is called immediately before show_decorations(), but the oneline output format is a special case that requires us to be able to show the decorations alone at the very end while showing the source before the message. This allows us to revert the change to t4202 in the previous step, which expected the regressed output for "--source". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/rev-list.c1
-rw-r--r--log-tree.c10
-rw-r--r--log-tree.h1
-rwxr-xr-xt/t4202-log.sh12
4 files changed, 16 insertions, 8 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 0aa93d5891..8833f029aa 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -107,6 +107,7 @@ static void show_commit(struct commit *commit, void *data)
children = children->next;
}
}
+ show_source(revs, commit);
show_decorations(revs, commit);
if (revs->commit_format == CMIT_FMT_ONELINE)
putchar(' ');
diff --git a/log-tree.c b/log-tree.c
index 3bf88182e2..9ca3e8c1ce 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -279,12 +279,16 @@ void format_decorations_extended(struct strbuf *sb,
strbuf_addstr(sb, color_reset);
}
+void show_source(struct rev_info *opt, struct commit *commit)
+{
+ if (opt->show_source && commit->util)
+ fprintf(opt->diffopt.file, "\t%s", (char *) commit->util);
+}
+
void show_decorations(struct rev_info *opt, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
- if (opt->show_source && commit->util)
- fprintf(opt->diffopt.file, "\t%s", (char *) commit->util);
if (!opt->show_decorations)
return;
format_decorations(&sb, commit, opt->diffopt.use_color);
@@ -556,6 +560,7 @@ void show_log(struct rev_info *opt)
show_parents(commit, abbrev_commit, opt->diffopt.file);
if (opt->children.name)
show_children(opt, commit, abbrev_commit);
+ show_source(opt, commit);
show_decorations(opt, commit);
if (opt->graph && !graph_is_commit_finished(opt->graph)) {
putc('\n', opt->diffopt.file);
@@ -622,6 +627,7 @@ void show_log(struct rev_info *opt)
find_unique_abbrev(parent->object.oid.hash,
abbrev_commit));
fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
+ show_source(opt, commit);
if (opt->commit_format == CMIT_FMT_ONELINE) {
/* Not at end of line, but.. */
if (opt->reflog_info)
diff --git a/log-tree.h b/log-tree.h
index c8116e60cd..33d4158203 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -20,6 +20,7 @@ void format_decorations_extended(struct strbuf *sb, const struct commit *commit,
const char *suffix);
#define format_decorations(strbuf, commit, color) \
format_decorations_extended((strbuf), (commit), (color), " (", ", ", ")")
+void show_source(struct rev_info *opt, struct commit *commit);
void show_decorations(struct rev_info *opt, struct commit *commit);
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **subject_p,
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index dea2d449ab..48b55bfd27 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -1353,9 +1353,9 @@ test_expect_success 'set up --source tests' '
test_expect_success 'log --source paints branch names' '
cat >expect <<-\EOF &&
- 09e12a9 three source-b
- 8e393e1 two source-a
- 1ac6c77 one source-b
+ 09e12a9 source-b three
+ 8e393e1 source-a two
+ 1ac6c77 source-b one
EOF
git log --oneline --source source-a source-b >actual &&
test_cmp expect actual
@@ -1364,9 +1364,9 @@ test_expect_success 'log --source paints branch names' '
test_expect_success 'log --source paints tag names' '
git tag -m tagged source-tag &&
cat >expect <<-\EOF &&
- 09e12a9 three source-tag
- 8e393e1 two source-a
- 1ac6c77 one source-tag
+ 09e12a9 source-tag three
+ 8e393e1 source-a two
+ 1ac6c77 source-tag one
EOF
git log --oneline --source source-tag source-a >actual &&
test_cmp expect actual