[PATCH] graph API: fix extra space during pre_commit_line state
- From
Allan Caffee <allan.caffee@gmail.com>
- Date
- Apr 21, 2009, 18:34 UTC
- Message-ID
- <20090421183412.GA8499@linux.vnet>
- In-Reply-To
- <87zlea9lit.fsf_-_@iki.fi>
An extra space is being inserted between the "commit" column and all of the successive edges. Remove this space. This regression was introduced by 427fc5b.
Signed-off-by: Allan Caffee <allan.caffee@gmail.com> --- graph.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
On Tue, 21 Apr 2009, Teemu Likonen wrote:
Show 23 quoted lines
> The colored log graph implementation (commit 427fc5b) introduces an > alignment bug which looks like this: > > | | * | edf2e37 git-apply: work from subdirectory. > | | * | 4ca0660 working from subdirectory: preparation > | | | | > | | \ \ > | | \ \ > | | \ \ > | | \ \ > | | \ \ > | *-----. \ \ 5401f30 Merge branches 'jc/apply', 'lt/ls-tree', [...] > | |\ \ \ \ \ \ > | | | | | * | | 0501c24 Tutorial: adjust merge example to recursive [...] > > > In other words, the diagonal lines after this octopus merge are aligned > wrong. To see it yourself type > > git log --graph --oneline a957207 > > in the Git repository and scroll the output down a bit. Note that the > bug exists with both --color _and_ --no-color.
It's actually the lines before the merge that are shifted to the right by one. This patch should fix that.
This issue exposes a gap in the existing test coverage, which doesn't exercise the pre_commit_line code. Maybe another patch is in order to extend t4202-log to cover pre-commit lines and octopus merges.
diff --git a/graph.c b/graph.c index d4571cf..31e09eb 100644 --- a/graph.c +++ b/graph.c @@ -727,8 +727,8 @@ static void graph_output_pre_commit_line(struct git_graph *graph, if (col->commit == graph->commit) { seen_this = 1; strbuf_write_column(sb, col, '|'); - strbuf_addf(sb, " %*s", graph->expansion_row, ""); - chars_written += 2 + graph->expansion_row; + strbuf_addf(sb, "%*s", graph->expansion_row, ""); + chars_written += 1 + graph->expansion_row; } else if (seen_this && (graph->expansion_row == 0)) { /* * This is the first line of the pre-commit output.
-- 1.5.6.3