From 0264aaf47e7aabe0e712e4d7b3919835efffdbdb Mon Sep 17 00:00:00 2001 From: Suzanne Soy Date: Thu, 1 Apr 2021 02:32:32 +0100 Subject: [PATCH] branches, HEAD, detached --- index.html | 243 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 185 insertions(+), 58 deletions(-) diff --git a/index.html b/index.html index e05cb00..37c6463 100644 --- a/index.html +++ b/index.html @@ -7,17 +7,27 @@ body { width: 63rem; font-size: 1.2rem; text-align:justify; } textarea { display:block; width: 63rem; height: 18rem; font-size: 1.2rem; } input { display:block; font-size: 1.2rem; } table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2rem; } +td.cell-path { max-width: 26rem; } +td.cell-contents { max-width: 36rem; } .specialchar { color: red; } .hex-prefix { color: lightgrey; } .hex { color: brown; } -.hex-hash { border: thin solid brown; display: block; width: max-content; } -.hex-hash.hilite-src { background: lightyellow; border-color: red; } +.hex-hash { display: block; width: max-content; } +.hex-hash, .plain-hash-or-ref { border: thin solid brown; } +.hex-hash.hilite-src, .plain-hash-or-ref.hilite-src { background: lightyellow; border-color: red; } .object-hash.hilite-dest { background: lightyellow; border-color: red; } .object-hash { border: thin solid transparent; } -.space { text-decoration: underline; color: brown; opacity: 0.5; } +.space { text-decoration: underline; color: brown; opacity: 0.5; white-space: pre; } .deflated { color: red; } .directory { color: darkcyan; } .error { color: orangered; } +.newline:after { + content: ''; + display:inline-block; + width:100%; + height:0; +} +code { word-wrap: break-word; } @@ -77,14 +87,17 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re return hex; } function ___specialchars_and_colour(s) { - return ___specialchars(s) - .replace(/[^-a-zA-Z0-9+_/!%$@.()]/g, function (c) { + return s.replace(/[^-a-zA-Z0-9+_/!%$@.():]/g, function (c) { switch (c) { - case " ": return ' '; break; - case "\0": return '\\000'; break; + case " ": return ' '; break; + case "\0": return '\\000'; break; case "\r": return '\\r'; break; - case "\n": return '\\n'; break; + case "\n": return '\\n'; break; case "\t": return '\\t'; break; + case '&': return '&'; break; + case '<': return '<'; break; + case '>': return '>'; break; + case '"': return '"'; break; default: return '\\x'+___left_pad(c.charCodeAt(0).toString(16), 0, 2)+''; break; } }); @@ -97,10 +110,27 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re return { left: 0, top: 0 }; } } + var global_current_hilite = { src: false, dests: [] }; + function ___hilite_off() { + if (global_current_hilite.src) { + global_current_hilite.src.classList.remove('hilite-src'); + } + for (var d = 0; d < global_current_hilite.dests.length; d++) { + global_current_hilite.dests[d].classList.remove('hilite-dest'); + } + global_current_hilite = { src: false, dests: [] }; + document.getElementById('lines').innerHTML = ''; + } function ___hilite(src, dest) { + ___hilite_off(); var src = document.getElementById(src); + var wrapper = src; + while (wrapper && !wrapper.classList.contains('hilite-wrapper')) { wrapper = wrapper.parentElement; } + var dests = (wrapper || document).getElementsByClassName(dest); + + global_current_hilite = { src, dests }; + src.classList.add('hilite-src'); - var dests = document.getElementsByClassName(dest); var lines = document.getElementById('lines'); lines.innerHTML = ''; for (var d = 0; d < dests.length; d++) { @@ -124,11 +154,11 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re var op = getOffset(l1.offsetParent); - var xa = osrc.left - op.left + src.offsetWidth; - var ya = osrc.top - op.top + src.offsetHeight / 2; - var xb = otr.left - op.left + tr.offsetWidth; - var yb = otr.top - op.top + tr.offsetHeight / 2; - var x = Math.max(xa, xb) + (50 * i); + var xa = Math.floor(osrc.left - op.left + src.offsetWidth); + var ya = Math.floor(osrc.top - op.top + src.offsetHeight / 2); + var xb = Math.floor(otr.left - op.left + tr.offsetWidth); + var yb = Math.floor(otr.top - op.top + tr.offsetHeight / 2); + var x = Math.max(xa, xb) + (50 * (d+1)); if (ya > yb) { var tmpx = xa; var tmpy = ya; @@ -143,38 +173,33 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re var p3 = { left: x, top: yb }; var p4 = { left: xb, top: yb }; + var thickness = 2; + // line 1 l1.style.width = p2.left-p1.left; - console.log(l1.style.width); - l1.style.height = '1px'; + l1.style.height = thickness + 'px'; l1.style.backgroundColor = 'red'; l1.style.top = p1.top; l1.style.left = p1.left; // line 2 - l2.style.width = '1px'; - l2.style.height = p3.top-p2.top; + l2.style.width = thickness + 'px'; + l2.style.height = p3.top-p2.top + thickness; l2.style.backgroundColor = 'red'; l2.style.top = p2.top; l2.style.left = p2.left; // line 3 l3.style.width = p3.left-p4.left; - l3.style.height = '1px'; + l3.style.height = thickness+'px'; l3.style.backgroundColor = 'red'; l3.style.top = p4.top; l3.style.left = p4.left; } } function ___lolite(src, dest) { - var src = document.getElementById(src); - src.classList.remove('hilite-src'); - var dests = document.getElementsByClassName(dest); - for (var d = 0; d < dests.length; d++) { - dests[d].classList.remove('hilite-dest'); - } } function ___specialchars_and_colour_and_hex(s) { if (s.substr(0,5) == "tree ") { - sp = s.split('\0'); + var sp = s.split('\0'); sp[0] = ___specialchars_and_colour(sp[0]); sp[1] = ___specialchars_and_colour(sp[1]); for (i = 2; i < sp.length; i++) { @@ -186,7 +211,42 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re + '' + ___specialchars_and_colour(sp[i].substr(20)); } - return sp.join('\\000'); + return sp.join('\\000'); + } else if (/^[0-9a-f]{40}$/.test(s)) { + var id=global_element_id++; + var hash = "object-hash-"+s; + return '' + + s + + ''; + } else if (/^ref: refs\/[^\n]*$/.test(s)) { + var id=global_element_id++; + var hash = "object-hash-"+s.substr(5); + return s.substr(0,5) + + '' + + s.substr(5) + + ''; + } else if(s.substr(0,7) == "commit ") { + var sz = s.split('\0'); + var sp = sz[1].split('\n'); + sz[0] = ___specialchars_and_colour(sz[0]); + var i; + for (i = 0; i < sp.length && sp[i] != ''; i++) { + if (/tree [0-9a-f]{40}/.test(sp[i])) { + var id=global_element_id++; + var hash = "object-hash-"+sp[i].substr(5); + sp[i] = ___specialchars_and_colour(sp[i].substr(0,5)) + + '' + + sp[i].substr(5) + + ''; + } else { + sp[i] = ___specialchars_and_colour(sp[i]); + } + } + for (; i < sp.length; i++) { + sp[i] = ___specialchars_and_colour(sp[i]); + } + var sp_joined = sp.join('\\n'); + return [sz[0], sp_joined].join('\\000'); } else { return ___specialchars_and_colour(s); } @@ -242,18 +302,24 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re function ___format_filepath(x) { var sp = x.split('/'); if (sp.length > 3 && sp[sp.length-3] == 'objects' && /^[0-9a-f]{2}$/.test(sp[sp.length-2]) && /^[0-9a-f]{38}$/.test(sp[sp.length-1])) { - return ___specialchars_and_colour(sp.slice(0, sp.length-2).join('/')+(sp.length > 0 ? '/' : '')) + return sp.slice(0, sp.length-2).map(___specialchars_and_colour).join('/')+(sp.length > 2 ? '/' : '') + '' - + ___specialchars_and_colour(sp.slice(sp.length-2).join('/')) + + sp.slice(sp.length-2).map(___specialchars_and_colour).join('/') + + ""; + } else if (sp.length > 1 && sp.indexOf('refs') >= 0 && sp.length > sp.indexOf('refs') + 1) { + var refs_idx = sp.indexOf('refs'); + return sp.slice(0, refs_idx).map(___specialchars_and_colour).join('/')+'/' + + ''//TODO + + sp.slice(refs_idx).map(___specialchars_and_colour).join('/') + ""; } else { return ___specialchars_and_colour(x); } } function ___format_entry(x) { - return "" + return '' + ___format_filepath(x[0]) - + "" + + '' + (x[1] === null ? 'Directory' : ("" + ___specialchars_and_colour_and_hex_and_zlib(x[1]) + "")) @@ -264,7 +330,7 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re .sort((a,b) => a[0] < b[0] ? -1 : (a[0] > b[0] ? 1 : 0)) .map(___format_entry); var id = global_element_id++; - return "Filesystem contents: " + entries.length + " files and directories. " + return '
Filesystem contents: ' + entries.length + " files and directories. " + '' + "Copy commands to recreate in *nix terminal" + "." @@ -272,7 +338,7 @@ table, td { border:thin solid black; border-collapse: collapse; font-size: 1.2re + '' - + "" + entries.join('') + "
"; + + "" + entries.join('') + "
"; } function ___copyprintf_click(id) { var elem = document.getElementById(id); @@ -339,6 +405,11 @@ function write(filename, data) { function mkdir(dirname) { return filesystem[dirname] = null; } + +current_directory = ''; +function cd(d) { + current_directory = d; +}
@@ -363,7 +434,7 @@ function listdir(dirname) {

Our imaginary user will create a proj directory, and start filling in some files.

- +

Now that the GIT database contains the entire tree for the current version, @@ -605,7 +676,7 @@ function format_timezone(tm) { The first commit has no parent, which is represented by passing the empty list.

HEAD

- write here + The HEAD indicates the "current" commit. It is set at first as part of the git init routine.

Tags

git commit

-

+

If the HEAD points to a commit hash, then git commit updates the HEAD to point to the new commit. + Otherwise, when the HEAD points to a branch, then the target branch (represented by a file named .git/refs/heads/the_branch_name) is updated.

+

git init

+ + +
+ END OF DOCUMENT