mirror of
https://github.com/git/git.git
synced 2026-01-10 10:13:33 +00:00
Currently, when we display a merge whose first parent is already present
in a column to the left of the merge commit, we display the first parent
as a vertical pipe `|` in the GRAPH_POST_MERGE line and then immediately
enter the GRAPH_COLLAPSING state. The first-parent line tracks to the
left and all the other parent lines follow it; this creates a "kink" in
those lines:
| *---.
| |\ \ \
|/ / / /
| | | *
This change tidies the display of such commits such that if the first
parent appears to the left of the merge, we render it as a `/` and the
second parent as a `|`. This reduces the horizontal and vertical space
needed to render the merge, and makes the resulting lines easier to
read.
| *-.
|/|\ \
| | | *
If the first parent is separated from the merge by several columns, a
horizontal line is drawn in a similar manner to how the GRAPH_COLLAPSING
state displays the line.
| | | *-.
| |_|/|\ \
|/| | | | *
This effect is applied to both "normal" two-parent merges, and to
octopus merges. It also reduces the vertical space needed for pre-commit
lines, as the merge occupies one less column than usual.
Before: After:
| * | *
| |\ | |\
| | \ | * \
| | \ |/|\ \
| *-. \
| |\ \ \
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
77 lines
1.5 KiB
Bash
Executable File
77 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git log --graph of skewed merges'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
|
|
cat >expect <<-\EOF &&
|
|
* H
|
|
|\
|
|
| * G
|
|
| |\
|
|
| | * F
|
|
| * \ E
|
|
|/|\ \
|
|
| | |/
|
|
| | * D
|
|
| * | C
|
|
| |/
|
|
* | B
|
|
|/
|
|
* A
|
|
EOF
|
|
|
|
git checkout --orphan _p &&
|
|
test_commit A &&
|
|
test_commit B &&
|
|
git checkout -b _q @^ && test_commit C &&
|
|
git checkout -b _r @^ && test_commit D &&
|
|
git checkout _p && git merge --no-ff _q _r -m E &&
|
|
git checkout _r && test_commit F &&
|
|
git checkout _p && git merge --no-ff _r -m G &&
|
|
git checkout @^^ && git merge --no-ff _p -m H &&
|
|
|
|
git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'log --graph with left-skewed merge' '
|
|
cat >expect <<-\EOF &&
|
|
*-----. 0_H
|
|
|\ \ \ \
|
|
| | | | * 0_G
|
|
| |_|_|/|
|
|
|/| | | |
|
|
| | | * \ 0_F
|
|
| |_|/|\ \
|
|
|/| | | |/
|
|
| | | | * 0_E
|
|
| |_|_|/
|
|
|/| | |
|
|
| | * | 0_D
|
|
| | |/
|
|
| | * 0_C
|
|
| |/
|
|
|/|
|
|
| * 0_B
|
|
|/
|
|
* 0_A
|
|
EOF
|
|
|
|
git checkout --orphan 0_p && test_commit 0_A &&
|
|
git checkout -b 0_q 0_p && test_commit 0_B &&
|
|
git checkout -b 0_r 0_p &&
|
|
test_commit 0_C &&
|
|
test_commit 0_D &&
|
|
git checkout -b 0_s 0_p && test_commit 0_E &&
|
|
git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F &&
|
|
git checkout 0_p && git merge --no-ff 0_s -m 0_G &&
|
|
git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&
|
|
|
|
git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|