Compare commits

..

No commits in common. "e1dcc1bf5e93a4fc754e93bc1f65e99be6dafeeb" and "9831b0b5b34569959e3d997f20aeae927924197f" have entirely different histories.

2 changed files with 88 additions and 166 deletions

Binary file not shown.

View file

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