Render paths to end of time for branches with no final merges

This is orthogonal to behaviour for rendering paths from the beginning of time for branches created
before the first commit, and helps frame the history in a better way.
This commit is contained in:
Alex Palaistras 2019-08-06 12:51:57 +01:00
parent 72d1059416
commit 892a5cec4d
8 changed files with 29 additions and 9 deletions

14
grawkit
View File

@ -129,7 +129,7 @@ function render_label(idx, class, name, _, buf, tw, w, h, hspc, vspc) {
}
# > Function `render_merge` renders merge paths for a branch pointed to by `idx`.
function render_merge(idx, _, buf, tmp, refs, fields, m, i, hspc) {
function render_merge(idx, _, buf, tmp, refs, fields, m, i, hspc, last) {
# Do not render merge paths for branch with no commits.
if (branches[idx,"refs"] == "") {
return
@ -160,6 +160,16 @@ function render_merge(idx, _, buf, tmp, refs, fields, m, i, hspc) {
# Draw the path.
buf = buf "\n\t\t" sprintf(svg["path"], tmp)
# Store the commit reference for the source commit of the last merge.
last = m[2]
}
# Extend branch to the end of time, if the last commit reference wasn't a merge source commit.
if (refs[length(refs)] != last) {
tmp = "M" hspc "," refs[length(refs)] * style["commit/spacing"]
tmp = tmp " L" hspc "," (state["HEAD"] + 1) * style["commit/spacing"]
buf = buf "\n\t\t" sprintf(svg["path"], tmp)
}
return buf "\n\t" svg["/g"]
@ -414,7 +424,7 @@ END {
w += style["branch/spacing"] * len["branches"]
w -= (branches[0,"refs"] == "") ? style["branch/spacing"] : 0
h = (style["commit/spacing"] * (len["commits"] - 1)) + (style["commit/stroke-width"] * 4)
h = (style["commit/spacing"] * (len["commits"])) + (style["commit/stroke-width"] * 4)
# Print SVG header.
printf svg["svg"], x, y, w, h

View File

@ -4,7 +4,7 @@
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 0 20">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 0 70">
<style type="text/css"><![CDATA[
.branch {
fill: none;

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 496 B

View File

@ -7,7 +7,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 112 120">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 112 170">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -35,6 +35,7 @@ git commit
<g class="merge">
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
<path class="branch" d="M0,100 L0,150" />
</g>
</g>
<g class="branch-master">

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -18,7 +18,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 190 270">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 190 320">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -47,9 +47,11 @@ git commit
<g class="merge">
<g class="branch-test-stuff">
<path class="branch" d="M0,100 C50,100 50,100 50,150" />
<path class="branch" d="M50,200 L50,300" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
<path class="branch" d="M0,250 L0,300" />
</g>
</g>
<g class="branch-test-stuff">

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -16,7 +16,7 @@ git merge test-merging
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 204 220">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 204 270">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -49,6 +49,7 @@ git merge test-merging
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
<path class="branch" d="M0,200 L0,250" />
</g>
</g>
<g class="branch-test-merging">

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -28,7 +28,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 394 370">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 394 420">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -59,6 +59,7 @@ git commit
<g class="merge">
<g class="branch-test-third">
<path class="branch" d="M50,150 C150,150 150,150 150,350" />
<path class="branch" d="M150,350 L150,400" />
</g>
<g class="branch-test-second">
<path class="branch" d="M0,50 C100,50 100,50 100,200" />
@ -70,6 +71,7 @@ git commit
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
<path class="branch" d="M0,300 L0,400" />
</g>
</g>
<g class="branch-test-third">

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -27,7 +27,7 @@ git merge feature/ZZ-704_take-it-to-the-limit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 465 420">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 465 470">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -59,6 +59,7 @@ git merge feature/ZZ-704_take-it-to-the-limit
<g class="merge">
<g class="branch-feature-abc-66-make-bar">
<path class="branch" d="M50,250 C200,250 200,250 200,300" />
<path class="branch" d="M200,350 L200,450" />
</g>
<g class="branch-feature-zz-704-take-it-to-the-limit">
<path class="branch" d="M50,50 C150,50 150,50 150,200" />
@ -70,6 +71,7 @@ git merge feature/ZZ-704_take-it-to-the-limit
</g>
<g class="branch-develop">
<path class="branch" d="M50,0 C50,0 50,0 50,50" />
<path class="branch" d="M50,400 L50,450" />
</g>
</g>
<g class="branch-feature-abc-66-make-bar">

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -23,7 +23,7 @@ git merge second
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 212 420">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 212 470">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -58,9 +58,11 @@ git merge second
</g>
<g class="branch-first">
<path class="branch" d="M0,50 C50,50 50,50 50,100" />
<path class="branch" d="M50,250 L50,450" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
<path class="branch" d="M0,400 L0,450" />
</g>
</g>
<g class="branch-second">

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB