#set text(lang: "sl") #set page("a4", margin: 5mm) #import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge #import fletcher.shapes: house, chevron, pill, hexagon #let commit-color = green #let tag-color = orange #let branch-color = purple #let thin = 0.5pt; #let thindotted = (thickness: thin, dash: "dotted"); #let thindashed = (thickness: thin, dash: "dashed"); #let commit-node(coord, hash, ..args) = node( coord, raw(hash), shape: pill, fill: commit-color.lighten(50%), stroke: thin, ..args) #let commit-object(coord, hash, name, ..args) = node( coord, align(left, [#text(size: 8pt, gray.darken(50%), raw(hash))\ #name]), corner-radius: 7pt, fill: commit-color.lighten(50%), stroke: none, ..args) #let tree-object(coord, hash, ..args) = commit-object(coord, hash, [tree], width: 2cm, fill: blue.lighten(50%), ..args) #let file-object(coord, hash, name, ..args) = commit-object(coord, hash, name, width: 2cm, fill: gray.lighten(50%), ..args) #diagram(debug: 1, node-stroke: 2pt, edge-stroke: 1pt, { let x_0 = 2 let x_delta = 1 let x_1 = x_0 + 1.5 /*let store = (2cm, 2cm) let (co1, co2) = { let x = 2cm let y = store.at(1) ((x, y+1.5cm), (x, y+1.5cm)) } let (tree1, tree2) = { let x = 3.2cm ((x, co1.at(1)), (x, co2.at(1))) } let (f1, f2, f3) = { let x = 4.2cm; let y = store.at(1) ((x, y), (x, y + 0.5cm), (x, y + 1cm)) }*/ let (A, B, C, D, E, F, G) = ((2, 6), (2, 5), (2, 4), (2, 3), (2, 2), (2, 1), (2, 0)) let (B1, B2) = ((3, 4.5), (3, 3.5)) let (E1, E2, E3) = ((3, 1.5), (3, 0.5), (3, -0.5)) let (Ah, Bh, Ch, Dh, Eh, Fh, Gh) = ("0a3d36", "ce2d1d", "0459b3", "b62527", "93f4ee", "7b67bd", "a6eb69") let (B1h, B2h) = ("2e4289", "7ed6de") let (E1h, E2h, E3h) = ("aa083c", "3f28d1", "2e9986") let tree1h = "43e2f7" //e05dcdcb48cd0772313f") /* let refs = (12cm, store.at(1)) let tags = (0.5, 3) let commit = (3.8, 2.5) let branches = (0.5, 0) let stage =(3.7, 0) let mc = (2.5, D.at(1)-0.5) commit-object(co1, "e264a1", [second commit]) commit-object(co2, "16f29", [first commit], width: 2.8cm) tree-object(tree1, "16f29") tree-object(tree2, "16f29") file-object(f1, "16f29", [`new content`]) file-object(f2, "16f29", [`unchanged`]) file-object(f3, "16f29", [`first content`]) edge(co2, tree2, "->") edge(co1, tree1, "->") node(store, stroke: thin, enclose:(co1, f3, f1)) */ commit-node(A, Ah, name: ) node((rel:(-1, 0), to: ), [Initial commit], corner-radius: 10pt, stroke: thin, name:) edge(, , stroke: thindotted) commit-node(B, Bh, name: ) commit-node(C, Ch, name: ) commit-node(D, Dh, name: ) node((rel: (0.5, -0.5), to: ), [Merge commit\ #text(size: 8pt)[commit with two parents]], stroke: thin, corner-radius: 10pt, name: ) edge(, , stroke: thindotted) commit-node(E, Eh, name: ) commit-node(F, Fh, name: ) // merge commit // merged branch commit-node((rel: (1, -0.5), to: ), B1h, name: ) commit-node((rel: (0, -1), to: ), B2h, name: ) // unmerged branch commit-node((rel: (1, -0.5), to: ), E1h, name: ) commit-node((rel: (0, -1), to: ), E2h, name: ) commit-node((rel: (0, -1), to: ), E3h, fill: none, stroke: thindashed, name: ) // branches node((rel: (-1, 0), to: ), [main], shape: hexagon, stroke: branch-color, name:
) edge(
, , "->", stroke: thin) node((rel: (-2, 0), to: ), [hotfix], shape: hexagon, stroke: branch-color, name: ) edge(, , "->", stroke: thin) // tags node((rel: (-1, 0), to: ), [v-1.0], shape: chevron, stroke: tag-color, name: ) edge(, , "->", stroke: thin) node((rel: (-1, 0), to: ), [v-1.1], shape: chevron, stroke: tag-color, name: ) edge(, , "->", stroke: thin) // enclose the tree node((rel: (0, -1), to: ), [*Version history*\ #align(left, text(size: 8pt)[ _Directed Acyclic Graph (DAG)_ describes version history. Commits are nodes in DAG, while an edge connect a commit with its parent. ])], stroke:none, width: 5cm, name: ) node(snap: false, enclose: (, , ), stroke: thindashed, width: 3cm, fill: gray.lighten(70%)) // branch cloud node((rel: (-0.5, -1), to: ), [#text(branch-color.darken(20%), smallcaps[*Branches*])\ references that moves along when commiting canges], stroke: thin, corner-radius: 10pt, inset: 5pt, width: 4cm, name: ) edge(, , corner: left, stroke: thindotted) edge(,
, corner: left, stroke: thindotted) // tag cloud node((rel: (-0.5, 1.5), to: ), [#text(tag-color, smallcaps[*Tags*])\ references that don't move], stroke: thin, corner-radius: 10pt, inset: 5pt, width: 4cm, name: ) edge(, , corner: right, stroke: thindotted) edge(, , corner: left, stroke: thindotted) // staging area node((rel: (1, 0), to: ), [#smallcaps[*Staging area*]\ #text(size: 8pt)[filesystem snapshot that will be commited in the next commit]], stroke: thindashed, corner-radius: 10pt, width: 3cm, name: ) edge(, , stroke: thindotted) // commit node((rel: (1, 0.5), to: ), [ #text(commit-color, smallcaps[*Commit*])\ #align(left)[snapshot of filesystem tree in object store]\ #table(columns: 1, fill: commit-color.lighten(50%), align: left, [commit hash: #raw(E1h)], raw(block: true, " tree 65c47fee parent 16f299 author MV ) edge(, , corner: right, stroke: thindotted) // refs /* node(refs, stroke: thin, inset:5pt, snap: false, enclose: (refs, (refs.at(0)+1cm, refs.at(1)+1cm)), align(left, [ *References* (`.git/refs`)\ *Tags* (`.git/refs/tags`)\ `tag-1`: `8dd6d4b...`\ *Branches* (`.git/refs/heads`) \ `main`: `8dd6d4b...`\ `feature-1`: `8dd6d4b...`\ `hotfix`: `8dd6d4b...` ]) ) /*, enclose: ( (branches.at(0)-0.5, branches.at(1)), (branches.at(0)+1, branches.at(1))))*/ /*, enclose: ((tags.at(0)-0.5, tags.at(1)), (tags.at(0)+1, tags.at(1))))*/ let ic = (A.at(0)+0.7, A.at(1)-0.2); edge(ic, A, stroke: thindotted) */ // history edge(, , "->") edge(, , "->") edge(, , "->") edge(, , "->") edge(, , "->") // merged branch edge(, , "->", layer: 1, label: [parent of], label-angle: auto) edge(, , "->") edge(, , "->") // unmerged branch edge(, , "->") edge(, , "->") edge(, , "->", stroke: (dash: "dashed")) // object store let obj_store = (rel: (-0.5, 1), to: ) node((rel: (4cm, -2.2cm), to: ), align(left)[Content addressable object store \ #raw(".git/objects")], stroke: none, snap: false ) commit-object((rel: (1.5, 2), to: ), E1h, [second commit], name: ) commit-object((rel: (1.5, 3), to: ), "16f29a", [first commit], width: 2.8cm, name: ) tree-object((rel:(-1, 0), to: ), tree1h, name:) edge(, , stroke: thin, "->") tree-object((rel:(-1, 0), to: ), "e05dcd", name: ) edge(, , stroke: thin, "->") file-object((rel:(-1, -1), to: ), "cb48cd", [`new content`], name: ) file-object((rel:(-1, 0), to: ), "077231", [`unchanged`], name: ) file-object((rel:(-1, 1), to: ), "d1bc32", [`first content`], name: ) edge(, , [`bar.txt`], "->", label-angle: auto, stroke: thin) edge(, , [`foo.txt`], "->", label-angle: auto, stroke: thin) edge(, , [`bar.txt`], "->", label-angle: auto, stroke: thin) edge(, , [`foo.txt`], "->", label-angle: auto, stroke: thin) node((rel: (0, 0.5), to:), enclose: (, , ), stroke: thindashed, corner-radius: 5pt, fill: gray.lighten(70%), snap: false, layer: -2) // time direction edge((0.2, 2.5), (0.2, 1), "->", label: [time], label-side: left, label-angle: 90deg, stroke: thindashed) edge(, , stroke: thin, "->", corner: right) } )