Add initial path for primary branch, fix font pitch to 0.5 of height

The primary branch (`master` or whichever other branch is the primary) has now
an automatic merge path that leads to the beginning of time, much like branches
that have been created before the first commit.

The font pitch is also fixed to half the height, as is usually the case with
monospace fonts.
This commit is contained in:
Alex Palaistras 2017-01-12 22:31:50 +00:00
parent de2258422e
commit b5708197cf
7 changed files with 99 additions and 81 deletions

View File

@ -103,10 +103,10 @@ function branch(idx, _, buf, tmp, refs, tags, t, i, hspc, vspc) {
# > Function `label` adds a sidebar label at commit index, with a specific class
# > and label name. Multiple labels for the same index will be placed side-by-side.
function label(idx, class, name, _, buf, w, h, hspc, vspc) {
# Calculate width and height for label rectangle. Pitch size is set to 0.525
# Calculate width and height for label rectangle. Pitch size is set to 0.5
# here, which is approximately right for 'Inconsolata', but may vary for other
# fonts, as fixed width fonts are usually twice as tall as they are wide.
w = ((style["label/font-size"] * 0.525) * length(name)) + style["label/spacing"]
w = ((style["label/font-size"] * 0.5) * length(name)) + style["label/spacing"]
h = style["label/font-size"] + style["label/spacing"]
# Calculate label offsets.
@ -226,14 +226,14 @@ BEGIN {
# Branch definitions.
branches[0,"name"] = "master"
branches[0,"refs"] = ""
branches[0,"merges"] = ""
branches[0,"merges"] = "0|0"
branches[0,"tags"] = ""
len["branches"] = 1
# Commit definitions.
commits[0,"type"] = ""
commits[0,"message"] = ""
len["commits"] = 0
len["commits"] = 1
# Tracks the state across calls.
state["branch"] = 0

View File

@ -4,7 +4,7 @@
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 0 -30">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 0 20">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -29,5 +29,9 @@
}
.branch-master {stroke: #002b36; fill: #002b36}
]]></style>
<g class="merge">
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,0" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 599 B

View File

@ -7,7 +7,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 114 70">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 112 120">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -32,13 +32,17 @@ git commit
}
.branch-master {stroke: #002b36; fill: #002b36}
]]></style>
<g class="merge">
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
</g>
</g>
<g class="branch-master">
<path class="branch" d="M0,0 L0,50" />
<circle class="commit" cx="0" cy="0" r="7.5" />
<path class="branch" d="M0,50 L0,100" />
<circle class="commit" cx="0" cy="50" r="7.5" />
<g class="label-branch" transform="translate(50,50)">
<rect x="0" y="-14" width="54" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="0" cy="100" r="7.5" />
<g class="label-branch" transform="translate(50,100)">
<rect x="0" y="-14" width="52" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">master</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -18,7 +18,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 193 220">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 190 270">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -46,25 +46,28 @@ git commit
]]></style>
<g class="merge">
<g class="branch-test-stuff">
<path class="branch" d="M0,50 C50,50 50,50 50,100" />
<path class="branch" d="M0,100 C50,100 50,100 50,150" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
</g>
</g>
<g class="branch-test-stuff">
<path class="branch" d="M50,100 L50,150" />
<circle class="commit" cx="50" cy="100" r="7.5" />
<path class="branch" d="M50,150 L50,200" />
<circle class="commit" cx="50" cy="150" r="7.5" />
<g class="label-branch" transform="translate(100,150)">
<rect x="0" y="-14" width="83" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="50" cy="200" r="7.5" />
<g class="label-branch" transform="translate(100,200)">
<rect x="0" y="-14" width="80" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">test-stuff</text>
</g>
</g>
<g class="branch-master">
<path class="branch" d="M0,0 L0,200" />
<circle class="commit" cx="0" cy="0" r="7.5" />
<path class="branch" d="M0,50 L0,250" />
<circle class="commit" cx="0" cy="50" r="7.5" />
<circle class="commit" cx="0" cy="200" r="7.5" />
<g class="label-branch" transform="translate(100,200)">
<rect x="0" y="-14" width="54" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="0" cy="100" r="7.5" />
<circle class="commit" cx="0" cy="250" r="7.5" />
<g class="label-branch" transform="translate(100,250)">
<rect x="0" y="-14" width="52" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">master</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -5,7 +5,6 @@
git branch test-merging
git commit -m "Commit on master"
git commit -m "Still on master"
git checkout test-merging
git commit -m 'A sample commit'
@ -17,7 +16,7 @@ git merge test-merging
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 208 220">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 204 220">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -48,23 +47,25 @@ git merge test-merging
<path class="branch" d="M50,0 C50,0 50,0 50,100" />
<path class="branch" d="M0,200 C50,200 50,200 50,100" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
</g>
</g>
<g class="branch-test-merging">
<path class="branch" d="M50,100 L50,100" />
<circle class="commit" cx="50" cy="100" r="7.5" />
<g class="label-branch" transform="translate(100,100)">
<rect x="0" y="-14" width="98" height="24" rx="3" class="label-rect" />
<rect x="0" y="-14" width="94" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">test-merging</text>
</g>
</g>
<g class="branch-master">
<path class="branch" d="M0,0 L0,200" />
<circle class="commit" cx="0" cy="0" r="7.5" />
<path class="branch" d="M0,50 L0,200" />
<circle class="commit" cx="0" cy="50" r="7.5" />
<circle class="commit" cx="0" cy="150" r="7.5" />
<circle class="commit" cx="0" cy="200" r="7.5" />
<g class="label-branch" transform="translate(100,200)">
<rect x="0" y="-14" width="54" height="24" rx="3" class="label-rect" />
<rect x="0" y="-14" width="52" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">master</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -28,7 +28,7 @@ git commit
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 401 320">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-10 -10 394 370">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -58,57 +58,60 @@ git commit
]]></style>
<g class="merge">
<g class="branch-test-third">
<path class="branch" d="M50,100 C150,100 150,100 150,300" />
<path class="branch" d="M50,150 C150,150 150,150 150,350" />
</g>
<g class="branch-test-second">
<path class="branch" d="M0,0 C100,0 100,0 100,150" />
<path class="branch" d="M0,250 C100,250 100,250 100,150" />
<path class="branch" d="M0,50 C100,50 100,50 100,200" />
<path class="branch" d="M0,300 C100,300 100,300 100,200" />
</g>
<g class="branch-test-first">
<path class="branch" d="M0,0 C50,0 50,0 50,100" />
<path class="branch" d="M100,200 C50,200 50,200 50,100" />
<path class="branch" d="M0,50 C50,50 50,50 50,150" />
<path class="branch" d="M100,250 C50,250 50,250 50,150" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,50" />
</g>
</g>
<g class="branch-test-third">
<path class="branch" d="M150,300 L150,300" />
<circle class="commit" cx="150" cy="300" r="7.5" />
<g class="label-branch" transform="translate(200,300)">
<rect x="0" y="-14" width="83" height="24" rx="3" class="label-rect" />
<path class="branch" d="M150,350 L150,350" />
<circle class="commit" cx="150" cy="350" r="7.5" />
<g class="label-branch" transform="translate(200,350)">
<rect x="0" y="-14" width="80" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">test-third</text>
</g>
</g>
<g class="branch-test-second">
<path class="branch" d="M100,150 L100,200" />
<circle class="commit" cx="100" cy="150" r="7.5" />
<path class="branch" d="M100,200 L100,250" />
<circle class="commit" cx="100" cy="200" r="7.5" />
<g class="label-tag" transform="translate(200,200)">
<rect x="0" y="-14" width="90" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="100" cy="250" r="7.5" />
<g class="label-tag" transform="translate(200,250)">
<rect x="0" y="-14" width="87" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">v.2.0.0-rc1</text>
</g>
<g class="label-branch" transform="translate(300,200)">
<rect x="0" y="-14" width="90" height="24" rx="3" class="label-rect" />
<g class="label-branch" transform="translate(297,250)">
<rect x="0" y="-14" width="87" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">test-second</text>
</g>
</g>
<g class="branch-test-first">
<path class="branch" d="M50,100 L50,100" />
<circle class="commit" cx="50" cy="100" r="7.5" />
<g class="label-branch" transform="translate(200,100)">
<rect x="0" y="-14" width="83" height="24" rx="3" class="label-rect" />
<path class="branch" d="M50,150 L50,150" />
<circle class="commit" cx="50" cy="150" r="7.5" />
<g class="label-branch" transform="translate(200,150)">
<rect x="0" y="-14" width="80" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">test-first</text>
</g>
</g>
<g class="branch-master">
<path class="branch" d="M0,0 L0,250" />
<circle class="commit" cx="0" cy="0" r="7.5" />
<path class="branch" d="M0,50 L0,300" />
<circle class="commit" cx="0" cy="50" r="7.5" />
<circle class="commit" cx="0" cy="250" r="7.5" />
<g class="label-tag" transform="translate(200,50)">
<rect x="0" y="-14" width="61" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="0" cy="100" r="7.5" />
<circle class="commit" cx="0" cy="300" r="7.5" />
<g class="label-tag" transform="translate(200,100)">
<rect x="0" y="-14" width="59" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">v.1.0.0</text>
</g>
<g class="label-branch" transform="translate(200,250)">
<rect x="0" y="-14" width="54" height="24" rx="3" class="label-rect" />
<g class="label-branch" transform="translate(200,300)">
<rect x="0" y="-14" width="52" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">master</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 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 477 370">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="40 -10 465 420">
<style type="text/css"><![CDATA[
.branch {
fill: none;
@ -58,53 +58,56 @@ git merge feature/ZZ-704_take-it-to-the-limit
]]></style>
<g class="merge">
<g class="branch-feature-abc-66-make-bar">
<path class="branch" d="M50,200 C200,200 200,200 200,250" />
<path class="branch" d="M50,250 C200,250 200,250 200,300" />
</g>
<g class="branch-feature-zz-704-take-it-to-the-limit">
<path class="branch" d="M50,0 C150,0 150,0 150,150" />
<path class="branch" d="M50,350 C150,350 150,350 150,150" />
<path class="branch" d="M50,50 C150,50 150,50 150,200" />
<path class="branch" d="M50,400 C150,400 150,400 150,200" />
</g>
<g class="branch-feature-xyz-12-fix-foo">
<path class="branch" d="M50,0 C100,0 100,0 100,50" />
<path class="branch" d="M50,200 C100,200 100,200 100,50" />
<path class="branch" d="M50,50 C100,50 100,50 100,100" />
<path class="branch" d="M50,250 C100,250 100,250 100,100" />
</g>
<g class="branch-develop">
<path class="branch" d="M50,0 C50,0 50,0 50,0" />
<path class="branch" d="M50,0 C50,0 50,0 50,50" />
</g>
<g class="branch-master">
<path class="branch" d="M0,0 C0,0 0,0 0,0" />
</g>
</g>
<g class="branch-feature-abc-66-make-bar">
<path class="branch" d="M200,250 L200,300" />
<circle class="commit" cx="200" cy="250" r="7.5" />
<path class="branch" d="M200,300 L200,350" />
<circle class="commit" cx="200" cy="300" r="7.5" />
<g class="label-branch" transform="translate(250,300)">
<rect x="0" y="-14" width="179" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="200" cy="350" r="7.5" />
<g class="label-branch" transform="translate(250,350)">
<rect x="0" y="-14" width="171" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">feature/ABC-66_make-bar</text>
</g>
</g>
<g class="branch-feature-zz-704-take-it-to-the-limit">
<path class="branch" d="M150,150 L150,150" />
<circle class="commit" cx="150" cy="150" r="7.5" />
<g class="label-branch" transform="translate(250,150)">
<rect x="0" y="-14" width="267" height="24" rx="3" class="label-rect" />
<path class="branch" d="M150,200 L150,200" />
<circle class="commit" cx="150" cy="200" r="7.5" />
<g class="label-branch" transform="translate(250,200)">
<rect x="0" y="-14" width="255" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">feature/ZZ-704_take-it-to-the-limit</text>
</g>
</g>
<g class="branch-feature-xyz-12-fix-foo">
<path class="branch" d="M100,50 L100,100" />
<circle class="commit" cx="100" cy="50" r="7.5" />
<path class="branch" d="M100,100 L100,150" />
<circle class="commit" cx="100" cy="100" r="7.5" />
<g class="label-branch" transform="translate(250,100)">
<rect x="0" y="-14" width="171" height="24" rx="3" class="label-rect" />
<circle class="commit" cx="100" cy="150" r="7.5" />
<g class="label-branch" transform="translate(250,150)">
<rect x="0" y="-14" width="164" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">feature/XYZ-12_fix-foo</text>
</g>
</g>
<g class="branch-develop">
<path class="branch" d="M50,0 L50,350" />
<circle class="commit" cx="50" cy="0" r="7.5" />
<circle class="commit" cx="50" cy="200" r="7.5" />
<circle class="commit" cx="50" cy="350" r="7.5" />
<g class="label-branch" transform="translate(250,350)">
<rect x="0" y="-14" width="61" height="24" rx="3" class="label-rect" />
<path class="branch" d="M50,50 L50,400" />
<circle class="commit" cx="50" cy="50" r="7.5" />
<circle class="commit" cx="50" cy="250" r="7.5" />
<circle class="commit" cx="50" cy="400" r="7.5" />
<g class="label-branch" transform="translate(250,400)">
<rect x="0" y="-14" width="59" height="24" rx="3" class="label-rect" />
<text x="5" y="2" class="label-text">develop</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB