mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
rev-list: use hdr_termination instead of a always using a newline
When adding support for prefixing output of log and other commands using
--line-prefix, commit 660e113ce1
("graph: add support for
--line-prefix on all graph-aware output", 2016-08-31) accidentally
broke rev-list --header output.
In order to make the output appear with a line-prefix, the flow was
changed to always use the graph subsystem for display. Unfortunately
the graph flow in rev-list did not use info->hdr_termination as it was
assumed that graph output would never need to putput NULs.
Since we now always use the graph code in order to handle the case of
line-prefix, simply replace putchar('\n') with
putchar(info->hdr_termination) which will correct this issue.
Add a test for the --header case to make sure we don't break it in the
future.
Reported-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fd47ae6a5b
commit
98985c6911
|
@ -145,7 +145,7 @@ static void show_commit(struct commit *commit, void *data)
|
||||||
*/
|
*/
|
||||||
if (buf.len && buf.buf[buf.len - 1] == '\n')
|
if (buf.len && buf.buf[buf.len - 1] == '\n')
|
||||||
graph_show_padding(revs->graph);
|
graph_show_padding(revs->graph);
|
||||||
putchar('\n');
|
putchar(info->hdr_termination);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* If the message buffer is empty, just show
|
* If the message buffer is empty, just show
|
||||||
|
|
|
@ -100,4 +100,18 @@ test_expect_success '--bisect and --first-parent can not be combined' '
|
||||||
test_must_fail git rev-list --bisect --first-parent HEAD
|
test_must_fail git rev-list --bisect --first-parent HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--header shows a NUL after each commit' '
|
||||||
|
# We know that there is no Q in the true payload; names and
|
||||||
|
# addresses of the authors and the committers do not have
|
||||||
|
# any, and object names or header names do not, either.
|
||||||
|
git rev-list --header --max-count=2 HEAD |
|
||||||
|
nul_to_q |
|
||||||
|
grep "^Q" >actual &&
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
Q$(git rev-parse HEAD~1)
|
||||||
|
Q
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue