Unexpected underscore in git log --graph output
Asked Answered
O

3

9

When running git log --graph on my copy of the Linux kernel, I'm seeing an underscore in the graph that doesn't look like it should be there.

What does that underscore mean?

The specific command I'm using is thus:

git log --graph --decorate --pretty=oneline --abbrev-commit --all --date-order

And the output looks like this:

git log --graph output

I've tried looking at this area in the graph in gitk, but there doesn't seem to be anything out of the ordinary there.

I don't think this is just showing a branch point, as I'd expect that to be rendered as on the right, not as on the left (the left should match the image above):

I see:        I'd expect for
              normal branching:

 \ \ \         \ \ \
 / / /         / / /
| _ /         | / /
|  /          |/ /
| |           | |
| |           | |
Oleum answered 6/3, 2013 at 14:30 Comment(5)
That's a rather large pile o' branches...Hinduism
Are you only asking about the rendering? I don't think there's any problem with the commit history (i.e. the purple branch splits in two at that point.)Melisma
@gcbenison: You can see in that image a few places where one branch has split into two, and they're rendered as |/ (pipe-slash), not | _ (pipe-space-underscore). If that's what this means, I want to know what the difference is between this split and a normal one; if it means something different, I want to know what.Oleum
@Oleum I don't think it does mean anything different; I think it's just a difference in rendering.Melisma
@gcbenison: So why is it rendered differently? What logic makes it decide to differ from its normal rendering and render like this instead?Oleum
A
4

From ack "'_'" on the Git sources it looks like the underscore is printed in graph.c, line 1120, inside the graph_output_collapsing_line function:

/*
 * Output out a line based on the new mapping info
 */
for (i = 0; i < graph->mapping_size; i++) {
    int target = graph->new_mapping[i];
    if (target < 0)
        strbuf_addch(sb, ' ');
    else if (target * 2 == i)
        strbuf_write_column(sb, &graph->new_columns[target], '|');
    else if (target == horizontal_edge_target &&
         i != horizontal_edge - 1) {
            /*
             * Set the mappings for all but the
             * first segment to -1 so that they
             * won't continue into the next line.
             */
            if (i != (target * 2)+3)
                graph->new_mapping[i] = -1;
            used_horizontal = 1;
        strbuf_write_column(sb, &graph->new_columns[target], '_');
    } else {
        if (used_horizontal && i < horizontal_edge)
            graph->new_mapping[i] = -1;
        strbuf_write_column(sb, &graph->new_columns[target], '/');

    }
}

But after thinking about it for a while it doesn’t make much sense anyway. The underscore is a symbol for crossing an unrelated branch to the left from the current one, to get to a branch point somewhere further to the left. This can be seen on other places in your screenshot, but this particular underscore really looks lost.

Alcove answered 6/3, 2013 at 15:40 Comment(1)
I agree that this underscore looks lost. The commit that introduced the code you're pointing to (v1.6.3-rc1-19-geaf158f) is for compacting graph lines that are traversing the screen, and should have /s at either side; this only has one to the right. Which implies it's a bug, or there's something else printing this specific underscore.Oleum
L
3

To me, this seems to be a rendering artefact. Most likely, the console output has some logic to prevent something like this

/ /
| /

from happening, as this snippet would not exactly show at which place a branch operation occurred. Thus, the designers probably opted for

/ /
| _

instead.

But I could be wrong here, it seems to be something that should be checked out in the code.

Lighting answered 6/3, 2013 at 15:3 Comment(1)
I don't think so: I can produce a simple four-commit example repository which shows the graph with /s directly above each other. There'd always be a space between a / and the one below it, but if you look in this image, if the _ were replaced with /s, there'd be a blank character too.Oleum
J
1

Very old question, but today I encountered this problem while writing a parser for the git graph output. At first I also thought it connected to the branch directly on the left of the _, but after trying some bigger repositories I found out that it means: connect to one of the | branches on the left. Why it is rendered like this is a complete mystery to me. See below for an example.

git log --graph --date-order --all --pretty=format:"%h %p %s"

git_weirdness

Jute answered 30/11, 2017 at 18:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.