2019-10-15 23:47:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git log --graph of skewed merges'
|
|
|
|
|
2023-10-03 20:27:24 +00:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2019-10-15 23:47:53 +00:00
|
|
|
. ./test-lib.sh
|
2020-02-24 13:38:13 +00:00
|
|
|
. "$TEST_DIRECTORY"/lib-log-graph.sh
|
2019-10-15 23:47:53 +00:00
|
|
|
|
2019-11-12 18:56:22 +00:00
|
|
|
check_graph () {
|
|
|
|
cat >expect &&
|
2020-02-24 13:38:13 +00:00
|
|
|
lib_test_cmp_graph --format=%s "$@"
|
2019-11-12 18:56:22 +00:00
|
|
|
}
|
|
|
|
|
2019-10-15 23:47:53 +00:00
|
|
|
test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
|
2019-11-12 18:56:22 +00:00
|
|
|
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 &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
2019-10-15 23:47:53 +00:00
|
|
|
* H
|
|
|
|
|\
|
|
|
|
| * G
|
|
|
|
| |\
|
|
|
|
| | * F
|
2019-10-15 23:47:58 +00:00
|
|
|
| * | E
|
|
|
|
|/|\|
|
2019-10-15 23:47:53 +00:00
|
|
|
| | * D
|
|
|
|
| * | C
|
|
|
|
| |/
|
2019-10-15 23:47:57 +00:00
|
|
|
* / B
|
2019-10-15 23:47:53 +00:00
|
|
|
|/
|
|
|
|
* A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2019-10-15 23:47:54 +00:00
|
|
|
test_expect_success 'log --graph with left-skewed merge' '
|
2019-11-12 18:56:22 +00:00
|
|
|
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 &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
2019-10-15 23:47:54 +00:00
|
|
|
*-----. 0_H
|
|
|
|
|\ \ \ \
|
|
|
|
| | | | * 0_G
|
|
|
|
| |_|_|/|
|
|
|
|
|/| | | |
|
2019-10-15 23:47:58 +00:00
|
|
|
| | | * | 0_F
|
|
|
|
| |_|/|\|
|
|
|
|
|/| | | |
|
2019-10-15 23:47:54 +00:00
|
|
|
| | | | * 0_E
|
|
|
|
| |_|_|/
|
|
|
|
|/| | |
|
|
|
|
| | * | 0_D
|
|
|
|
| | |/
|
|
|
|
| | * 0_C
|
|
|
|
| |/
|
|
|
|
|/|
|
|
|
|
| * 0_B
|
|
|
|
|/
|
|
|
|
* 0_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
test_expect_success 'log --graph with nested left-skewed merge' '
|
2019-11-12 18:56:22 +00:00
|
|
|
git checkout --orphan 1_p &&
|
|
|
|
test_commit 1_A &&
|
|
|
|
test_commit 1_B &&
|
|
|
|
test_commit 1_C &&
|
|
|
|
git checkout -b 1_q @^ && test_commit 1_D &&
|
|
|
|
git checkout 1_p && git merge --no-ff 1_q -m 1_E &&
|
|
|
|
git checkout -b 1_r @~3 && test_commit 1_F &&
|
|
|
|
git checkout 1_p && git merge --no-ff 1_r -m 1_G &&
|
|
|
|
git checkout @^^ && git merge --no-ff 1_p -m 1_H &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
* 1_H
|
|
|
|
|\
|
|
|
|
| * 1_G
|
|
|
|
| |\
|
|
|
|
| | * 1_F
|
|
|
|
| * | 1_E
|
|
|
|
|/| |
|
|
|
|
| * | 1_D
|
|
|
|
* | | 1_C
|
|
|
|
|/ /
|
2019-10-15 23:47:57 +00:00
|
|
|
* / 1_B
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
|/
|
|
|
|
* 1_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'log --graph with nested left-skewed merge following normal merge' '
|
2019-11-12 18:56:22 +00:00
|
|
|
git checkout --orphan 2_p &&
|
|
|
|
test_commit 2_A &&
|
|
|
|
test_commit 2_B &&
|
|
|
|
test_commit 2_C &&
|
|
|
|
git checkout -b 2_q @^^ &&
|
|
|
|
test_commit 2_D &&
|
|
|
|
test_commit 2_E &&
|
|
|
|
git checkout -b 2_r @^ && test_commit 2_F &&
|
|
|
|
git checkout 2_q &&
|
|
|
|
git merge --no-ff 2_r -m 2_G &&
|
|
|
|
git merge --no-ff 2_p^ -m 2_H &&
|
|
|
|
git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&
|
|
|
|
git checkout 2_p && git merge --no-ff 2_s -m 2_K &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
* 2_K
|
|
|
|
|\
|
|
|
|
| * 2_J
|
|
|
|
| |\
|
|
|
|
| | * 2_H
|
|
|
|
| | |\
|
|
|
|
| | * | 2_G
|
|
|
|
| |/| |
|
|
|
|
| | * | 2_F
|
|
|
|
| * | | 2_E
|
|
|
|
| |/ /
|
|
|
|
| * | 2_D
|
|
|
|
* | | 2_C
|
|
|
|
| |/
|
|
|
|
|/|
|
|
|
|
* | 2_B
|
|
|
|
|/
|
|
|
|
* 2_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' '
|
2019-11-12 18:56:22 +00:00
|
|
|
git checkout --orphan 3_p &&
|
|
|
|
test_commit 3_A &&
|
|
|
|
git checkout -b 3_q &&
|
|
|
|
test_commit 3_B &&
|
|
|
|
test_commit 3_C &&
|
|
|
|
git checkout -b 3_r @^ &&
|
|
|
|
test_commit 3_D &&
|
|
|
|
git checkout 3_q && git merge --no-ff 3_r -m 3_E &&
|
|
|
|
git checkout 3_p && git merge --no-ff 3_q -m 3_F &&
|
|
|
|
git checkout 3_r && test_commit 3_G &&
|
|
|
|
git checkout 3_p && git merge --no-ff 3_r -m 3_H &&
|
|
|
|
git checkout @^^ && git merge --no-ff 3_p -m 3_J &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
* 3_J
|
|
|
|
|\
|
|
|
|
| * 3_H
|
|
|
|
| |\
|
|
|
|
| | * 3_G
|
|
|
|
| * | 3_F
|
|
|
|
|/| |
|
2019-10-15 23:47:58 +00:00
|
|
|
| * | 3_E
|
|
|
|
| |\|
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
| | * 3_D
|
|
|
|
| * | 3_C
|
|
|
|
| |/
|
|
|
|
| * 3_B
|
|
|
|
|/
|
|
|
|
* 3_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'log --graph with right-skewed merge following a left-skewed one' '
|
2019-11-12 18:56:22 +00:00
|
|
|
git checkout --orphan 4_p &&
|
|
|
|
test_commit 4_A &&
|
|
|
|
test_commit 4_B &&
|
|
|
|
test_commit 4_C &&
|
|
|
|
git checkout -b 4_q @^^ && test_commit 4_D &&
|
|
|
|
git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E &&
|
|
|
|
git checkout -b 4_s 4_p^^ &&
|
|
|
|
git merge --no-ff 4_r -m 4_F &&
|
|
|
|
git merge --no-ff 4_p -m 4_G &&
|
|
|
|
git checkout @^^ && git merge --no-ff 4_s -m 4_H &&
|
|
|
|
|
|
|
|
check_graph --date-order <<-\EOF
|
graph: commit and post-merge lines for left-skewed merges
Following the introduction of "left-skewed" merges, which are merges
whose first parent fuses with another edge to its left, we have some
more edge cases to deal with in the display of commit and post-merge
lines.
The current graph code handles the following cases for edges appearing
to the right of the commit (*) on commit lines. A 2-way merge is usually
followed by vertical lines:
| | |
| * |
| |\ \
An octopus merge (more than two parents) is always followed by edges
sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \
A 2-way merge is followed by a right-sloping edge if the commit line
immediately follows a post-merge line for a commit that appears in the
same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \
This commit introduces the following new cases for commit lines. If a
2-way merge skews to the left, then the edges to its right are always
vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |
A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \
If a 3-way left-skewed merge commit appears immediately after a
post-merge line, then it may be followed the right-sloping edges, just
like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \
Octopus merges with 4 or more parents that skew to the left will always
be followed by right-sloping edges, because the existing columns need to
expand around the merge.
| | \
| *-. \
|/|\ \ \
On post-merge lines, usually all edges following the current commit
slope to the right:
| * | |
| |\ \ \
However, if the commit is a left-skewed 2-way merge, the edges to its
right remain vertical. We also need to display a space after the
vertical line descending from the commit marker, whereas this line would
normally be followed by a backslash.
| * | |
|/| | |
If a left-skewed merge has more than 2 parents, then the edges to its
right are still sloped as they bend around the edges introduced by the
merge.
| * | |
|/|\ \ \
To handle these new cases, we need to know not just how many parents
each commit has, but how many new columns it adds to the display; this
quantity is recorded in the `edges_added` field for the current commit,
and `prev_edges_added` field for the previous commit.
Here, "column" refers to visual columns, not the logical columns of the
`columns` array. This is because even if all the commit's parents end up
fusing with existing edges, they initially introduce distinct edges in
the commit and post-merge lines before those edges collapse. For
example, a 3-way merge whose 2nd and 3rd parents fuse with existing
edges still introduces 2 visual columns that affect the display of edges
to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |
This merge does not introduce any *logical* columns; there are 4 edges
before and after this commit once all edges have collapsed. But it does
initially introduce 2 new edges that need to be accommodated by the
edges to their right.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-10-15 23:47:55 +00:00
|
|
|
* 4_H
|
|
|
|
|\
|
|
|
|
| * 4_G
|
|
|
|
| |\
|
|
|
|
| * | 4_F
|
|
|
|
|/| |
|
|
|
|
| * | 4_E
|
|
|
|
| |\ \
|
|
|
|
| | * | 4_D
|
|
|
|
| |/ /
|
|
|
|
|/| |
|
|
|
|
| | * 4_C
|
|
|
|
| |/
|
|
|
|
| * 4_B
|
|
|
|
|/
|
|
|
|
* 4_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2019-10-15 23:47:58 +00:00
|
|
|
test_expect_success 'log --graph with octopus merge with column joining its penultimate parent' '
|
2019-11-12 18:56:22 +00:00
|
|
|
git checkout --orphan 5_p &&
|
|
|
|
test_commit 5_A &&
|
|
|
|
git branch 5_q &&
|
|
|
|
git branch 5_r &&
|
|
|
|
test_commit 5_B &&
|
|
|
|
git checkout 5_q && test_commit 5_C &&
|
|
|
|
git checkout 5_r && test_commit 5_D &&
|
|
|
|
git checkout 5_p &&
|
|
|
|
git merge --no-ff 5_q 5_r -m 5_E &&
|
|
|
|
git checkout 5_q && test_commit 5_F &&
|
|
|
|
git checkout -b 5_s 5_p^ &&
|
|
|
|
git merge --no-ff 5_p 5_q -m 5_G &&
|
|
|
|
git checkout 5_r &&
|
|
|
|
git merge --no-ff 5_s -m 5_H &&
|
|
|
|
|
|
|
|
check_graph <<-\EOF
|
2019-10-15 23:47:58 +00:00
|
|
|
* 5_H
|
|
|
|
|\
|
|
|
|
| *-. 5_G
|
|
|
|
| |\ \
|
|
|
|
| | | * 5_F
|
|
|
|
| | * | 5_E
|
|
|
|
| |/|\ \
|
|
|
|
| |_|/ /
|
|
|
|
|/| | /
|
|
|
|
| | |/
|
|
|
|
* | | 5_D
|
|
|
|
| | * 5_C
|
|
|
|
| |/
|
|
|
|
|/|
|
|
|
|
| * 5_B
|
|
|
|
|/
|
|
|
|
* 5_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
graph: drop assert() for merge with two collapsing parents
When "git log --graph" shows a merge commit that has two collapsing
lines, like:
| | | | *
| |_|_|/|
|/| | |/
| | |/|
| |/| |
| * | |
* | | |
we trigger an assert():
graph.c:1228: graph_output_collapsing_line: Assertion
`graph->mapping[i - 3] == target' failed.
The assert was introduced by eaf158f8 ("graph API: Use horizontal
lines for more compact graphs", 2009-04-21), which is quite old.
This assert is trying to say that when we complete a horizontal
line with a single slash, it is because we have reached our target.
It is actually the _second_ collapsing line that hits this assert.
The reason we are in this code path is because we are collapsing
the first line, and in that case we are hitting our target now
that the horizontal line is complete. However, the second line
cannot be a horizontal line, so it will collapse without horizontal
lines. In this case, it is inappropriate to assert that we have
reached our target, as we need to continue for another column
before reaching the target. Dropping the assert is safe here.
The new behavior in 0f0f389f12 (graph: tidy up display of
left-skewed merges, 2019-10-15) caused the behavior change that
made this assertion failure possible. In addition to making the
assert possible, it also changed how multiple edges collapse.
In a larger example, the current code will output a collapse
as follows:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | | | |/| /
| | | |/| |/
| | |/| |/|
| |/| |/| |
| | |/| | |
| | * | | |
However, the intended collapse should allow multiple horizontal lines
as follows:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | |_|_|/| /
| |/| | | |/
| | | |_|/|
| | |/| | |
| | * | | |
This behavior is not corrected by this change, but is noted for a later
update.
Helped-by: Jeff King <peff@peff.net>
Reported-by: Bradley Smith <brad@brad-smith.co.uk>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-01-07 21:27:01 +00:00
|
|
|
test_expect_success 'log --graph with multiple tips' '
|
|
|
|
git checkout --orphan 6_1 &&
|
|
|
|
test_commit 6_A &&
|
|
|
|
git branch 6_2 &&
|
|
|
|
git branch 6_4 &&
|
|
|
|
test_commit 6_B &&
|
|
|
|
git branch 6_3 &&
|
|
|
|
test_commit 6_C &&
|
|
|
|
git checkout 6_2 && test_commit 6_D &&
|
|
|
|
git checkout 6_3 && test_commit 6_E &&
|
|
|
|
git checkout -b 6_5 6_1 &&
|
|
|
|
git merge --no-ff 6_2 -m 6_F &&
|
|
|
|
git checkout 6_4 && test_commit 6_G &&
|
|
|
|
git checkout 6_3 &&
|
|
|
|
git merge --no-ff 6_4 -m 6_H &&
|
|
|
|
git checkout 6_1 &&
|
|
|
|
git merge --no-ff 6_2 -m 6_I &&
|
|
|
|
|
|
|
|
check_graph 6_1 6_3 6_5 <<-\EOF
|
|
|
|
* 6_I
|
|
|
|
|\
|
|
|
|
| | * 6_H
|
|
|
|
| | |\
|
|
|
|
| | | * 6_G
|
|
|
|
| | * | 6_E
|
|
|
|
| | | | * 6_F
|
|
|
|
| |_|_|/|
|
|
|
|
|/| | |/
|
|
|
|
| | |/|
|
|
|
|
| |/| |
|
|
|
|
| * | | 6_D
|
|
|
|
| | |/
|
|
|
|
| |/|
|
|
|
|
* | | 6_C
|
|
|
|
| |/
|
|
|
|
|/|
|
|
|
|
* | 6_B
|
|
|
|
|/
|
|
|
|
* 6_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2020-01-07 21:27:02 +00:00
|
|
|
test_expect_success 'log --graph with multiple tips and colors' '
|
|
|
|
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
|
|
|
|
cat >expect.colors <<-\EOF &&
|
|
|
|
* 6_I
|
|
|
|
<RED>|<RESET><GREEN>\<RESET>
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> * 6_H
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET>
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET>
|
|
|
|
<RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET>
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET>
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
|
|
|
|
<RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E
|
|
|
|
<RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D
|
|
|
|
<RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET>
|
|
|
|
<RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET>
|
|
|
|
* <BLUE>|<RESET> <CYAN>|<RESET> 6_C
|
|
|
|
<CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET>
|
|
|
|
<CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
|
|
|
|
* <BLUE>|<RESET> 6_B
|
|
|
|
<BLUE>|<RESET><BLUE>/<RESET>
|
|
|
|
* 6_A
|
|
|
|
EOF
|
2020-02-24 13:38:14 +00:00
|
|
|
lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
|
2020-01-07 21:27:02 +00:00
|
|
|
'
|
|
|
|
|
2020-01-08 04:27:55 +00:00
|
|
|
test_expect_success 'log --graph with multiple tips' '
|
2020-01-08 04:27:54 +00:00
|
|
|
git checkout --orphan 7_1 &&
|
|
|
|
test_commit 7_A &&
|
|
|
|
test_commit 7_B &&
|
|
|
|
test_commit 7_C &&
|
|
|
|
git checkout -b 7_2 7_1~2 &&
|
|
|
|
test_commit 7_D &&
|
|
|
|
test_commit 7_E &&
|
|
|
|
git checkout -b 7_3 7_1~1 &&
|
|
|
|
test_commit 7_F &&
|
|
|
|
test_commit 7_G &&
|
|
|
|
git checkout -b 7_4 7_2~1 &&
|
|
|
|
test_commit 7_H &&
|
|
|
|
git checkout -b 7_5 7_1~2 &&
|
|
|
|
test_commit 7_I &&
|
|
|
|
git checkout -b 7_6 7_3~1 &&
|
|
|
|
test_commit 7_J &&
|
|
|
|
git checkout -b M_1 7_1 &&
|
|
|
|
git merge --no-ff 7_2 -m 7_M1 &&
|
|
|
|
git checkout -b M_3 7_3 &&
|
|
|
|
git merge --no-ff 7_4 -m 7_M2 &&
|
|
|
|
git checkout -b M_5 7_5 &&
|
|
|
|
git merge --no-ff 7_6 -m 7_M3 &&
|
|
|
|
git checkout -b M_7 7_1 &&
|
|
|
|
git merge --no-ff 7_2 7_3 -m 7_M4 &&
|
|
|
|
|
|
|
|
check_graph M_1 M_3 M_5 M_7 <<-\EOF
|
|
|
|
* 7_M1
|
|
|
|
|\
|
|
|
|
| | * 7_M2
|
|
|
|
| | |\
|
|
|
|
| | | * 7_H
|
|
|
|
| | | | * 7_M3
|
|
|
|
| | | | |\
|
|
|
|
| | | | | * 7_J
|
|
|
|
| | | | * | 7_I
|
|
|
|
| | | | | | * 7_M4
|
|
|
|
| |_|_|_|_|/|\
|
|
|
|
|/| | | | |/ /
|
|
|
|
| | |_|_|/| /
|
|
|
|
| |/| | | |/
|
|
|
|
| | | |_|/|
|
|
|
|
| | |/| | |
|
|
|
|
| | * | | | 7_G
|
|
|
|
| | | |_|/
|
|
|
|
| | |/| |
|
|
|
|
| | * | | 7_F
|
|
|
|
| * | | | 7_E
|
|
|
|
| | |/ /
|
|
|
|
| |/| |
|
|
|
|
| * | | 7_D
|
|
|
|
| | |/
|
|
|
|
| |/|
|
|
|
|
* | | 7_C
|
|
|
|
| |/
|
|
|
|
|/|
|
|
|
|
* | 7_B
|
|
|
|
|/
|
|
|
|
* 7_A
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2019-10-15 23:47:53 +00:00
|
|
|
test_done
|