Fixed CSS, fixed typos
This commit is contained in:
parent
a4ba52e378
commit
92ef4bb690
|
@ -12,14 +12,14 @@ article#git-tutorial { max-width: 63rem; position: absolute; right:18.4em; top:0
|
||||||
|
|
||||||
@media (max-width: 72em) {
|
@media (max-width: 72em) {
|
||||||
#git-tutorial td.cell-contents { width: 34em; }
|
#git-tutorial td.cell-contents { width: 34em; }
|
||||||
#git-tutorial article { right: 7em; }
|
article#git-tutorial { right: 7em; }
|
||||||
#git-tutorial #toc { right: -11em; }
|
#git-tutorial #toc { right: -11em; }
|
||||||
#git-tutorial #toc:hover { border-left: 5px solid gray; }
|
#git-tutorial #toc:hover { border-left: 5px solid gray; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 63em) {
|
@media (max-width: 63em) {
|
||||||
#git-tutorial td.cell-contents { width: 30em; }
|
#git-tutorial td.cell-contents { width: 30em; }
|
||||||
#git-tutorial article { right:6em; }
|
article#git-tutorial { right:6em; }
|
||||||
#git-tutorial #toc { right: -12em; }
|
#git-tutorial #toc { right: -12em; }
|
||||||
#git-tutorial #toc:hover { border-left: 5px solid gray; }
|
#git-tutorial #toc:hover { border-left: 5px solid gray; }
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ article#git-tutorial { max-width: 63rem; position: absolute; right:18.4em; top:0
|
||||||
#git-tutorial textarea { display:block; height: 18rem; }
|
#git-tutorial textarea { display:block; height: 18rem; }
|
||||||
#git-tutorial .CodeMirror { height: max-content; }
|
#git-tutorial .CodeMirror { height: max-content; }
|
||||||
#git-tutorial input { display: inline-block; margin-right: 1em; font-size: 1.2rem; }
|
#git-tutorial input { display: inline-block; margin-right: 1em; font-size: 1.2rem; }
|
||||||
#git-tutorial table, #git-tutorial td { border:thin solid black; border-collapse: collapse; }
|
#git-tutorial table, #git-tutorial td, #git-tutorial th { border:thin solid black; border-collapse: collapse; }
|
||||||
#git-tutorial .specialchar { color: red; word-wrap: normal; }
|
#git-tutorial .specialchar { color: red; word-wrap: normal; }
|
||||||
#git-tutorial .hex-prefix { color: lightgrey; }
|
#git-tutorial .hex-prefix { color: lightgrey; }
|
||||||
#git-tutorial .hex { color: brown; }
|
#git-tutorial .hex { color: brown; }
|
||||||
|
@ -43,7 +43,7 @@ article#git-tutorial { max-width: 63rem; position: absolute; right:18.4em; top:0
|
||||||
#git-tutorial .error { color: orangered; }
|
#git-tutorial .error { color: orangered; }
|
||||||
#git-tutorial .newline:after { content: ''; display:inline-block; width:100%; height:0; }
|
#git-tutorial .newline:after { content: ''; display:inline-block; width:100%; height:0; }
|
||||||
#git-tutorial code { word-wrap: break-word; }
|
#git-tutorial code { word-wrap: break-word; }
|
||||||
#git-tutorial article .onlytoc { display: none; }
|
article#git-tutorial .onlytoc { display: none; }
|
||||||
/* #toc .onlytoc { } */
|
/* #toc .onlytoc { } */
|
||||||
#git-tutorial #toc .tocsmall { font-size: smaller; }
|
#git-tutorial #toc .tocsmall { font-size: smaller; }
|
||||||
#git-tutorial #toc .notoc { display: none; }
|
#git-tutorial #toc .notoc { display: none; }
|
||||||
|
|
|
@ -361,7 +361,7 @@ function ___filesystem_to_string(fs) {
|
||||||
+ '<textarea id="elem-'+id+'" disabled="disabled" style="display:none">'
|
+ '<textarea id="elem-'+id+'" disabled="disabled" style="display:none">'
|
||||||
+ ___specialchars(___filesystem_to_printf(fs) || 'echo "Empty filesystem."')
|
+ ___specialchars(___filesystem_to_printf(fs) || 'echo "Empty filesystem."')
|
||||||
+ '</textarea>'
|
+ '</textarea>'
|
||||||
+ "<table>" + entries.join('') + "</table></div>";
|
+ "<table><thead><tr><th>Path</th><th>Contents</th></tr></thead><tbody>" + entries.join('') + "</tbody></table></div>";
|
||||||
}
|
}
|
||||||
function ___textarea_value(elem) {
|
function ___textarea_value(elem) {
|
||||||
if (elem.getValue) {
|
if (elem.getValue) {
|
||||||
|
|
115
index.html
115
index.html
|
@ -65,7 +65,7 @@ function read(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function write(filename, data) {
|
function write(filename, data) {
|
||||||
return filesystem[filename] = ""+data;
|
filesystem[filename] = String(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists(filename) {
|
function exists(filename) {
|
||||||
|
@ -73,11 +73,11 @@ function exists(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkdir(dirname) {
|
function mkdir(dirname) {
|
||||||
return filesystem[dirname] = null;
|
filesystem[dirname] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cd(d) {
|
function cd(dirname) {
|
||||||
current_directory = d;
|
current_directory = dirname;
|
||||||
}
|
}
|
||||||
</textarea>
|
</textarea>
|
||||||
</section>
|
</section>
|
||||||
|
@ -105,8 +105,8 @@ function listdir(dirname) {
|
||||||
<p>Our imaginary user will create a <code>proj</code> directory,
|
<p>Our imaginary user will create a <code>proj</code> directory,
|
||||||
and start filling in some files.</p>
|
and start filling in some files.</p>
|
||||||
<textarea id="in3">
|
<textarea id="in3">
|
||||||
cd('proj');
|
|
||||||
mkdir('proj');
|
mkdir('proj');
|
||||||
|
cd('proj');
|
||||||
write('proj/README', 'This is my Scheme project.\n');
|
write('proj/README', 'This is my Scheme project.\n');
|
||||||
mkdir('proj/src');
|
mkdir('proj/src');
|
||||||
write('proj/src/main.scm', '(map (lambda (x) (+ x 1)) (list 1 2 3))\n');
|
write('proj/src/main.scm', '(map (lambda (x) (+ x 1)) (list 1 2 3))\n');
|
||||||
|
@ -118,7 +118,7 @@ write('proj/src/main.scm', '(map (lambda (x) (+ x 1)) (list 1 2 3))\n');
|
||||||
<p>The first thing to do is to initialize the GIT directory.
|
<p>The first thing to do is to initialize the GIT directory.
|
||||||
For now, only the <code>.git</code> folder is needed, The rest
|
For now, only the <code>.git</code> folder is needed, The rest
|
||||||
of the function implementing <code>git init</code> will be
|
of the function implementing <code>git init</code> will be
|
||||||
implemented later.</p>
|
written later.</p>
|
||||||
<textarea id="in4">
|
<textarea id="in4">
|
||||||
function join_paths(a, b) {
|
function join_paths(a, b) {
|
||||||
return (a == "") ? b : (a + "/" + b);
|
return (a == "") ? b : (a + "/" + b);
|
||||||
|
@ -133,12 +133,11 @@ git_init_mkdir();
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="git-hash-object">
|
<section id="git-hash-object">
|
||||||
<h1><code>git hash-object</code><span class="notoc" (storing a copy of a file in <code>.git</code>)</span></h1>
|
<h1><code>git hash-object</code><span class="notoc"> (storing a copy of a file in <code>.git</code>)</span></h1>
|
||||||
<p>The most basic element of a GIT repository is an object. It is a
|
<p>The most basic element of a GIT repository is an object. It is a
|
||||||
copy of a file that is stored in GIT's database. That copy is
|
copy of a file that is stored in GIT's database. That copy is
|
||||||
stored under a unique name. The unique name is obtained by hashing the
|
stored under a unique name. The unique name is obtained by hashing the
|
||||||
contents of the file. <!-- or have a hash oracle that always returns a
|
contents of the file.</p>
|
||||||
new number. --></p>
|
|
||||||
<textarea id="in5">
|
<textarea id="in5">
|
||||||
function hash_object(must_write, type, is_data, path_or_data) {
|
function hash_object(must_write, type, is_data, path_or_data) {
|
||||||
var data = is_data ? path_or_data : read(current_directory + "/" + path_or_data);
|
var data = is_data ? path_or_data : read(current_directory + "/" + path_or_data);
|
||||||
|
@ -368,6 +367,60 @@ initial_commit = store_commit(
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section id="resolving-references">
|
||||||
|
<h1>resolving references</h1>
|
||||||
|
<textarea>
|
||||||
|
function trim_newline(s) {
|
||||||
|
if (s.endsWith('\n')) { return s.substr(0, s.length-1); } else { return s; }
|
||||||
|
}
|
||||||
|
</textarea>
|
||||||
|
|
||||||
|
<section id="git-symbolic-ref">
|
||||||
|
<h1><code>git symbolic-ref</code></h1>
|
||||||
|
<textarea>
|
||||||
|
function git_symbolic_ref(ref) {
|
||||||
|
var ref_file = join_paths(current_directory, '.git/' + ref);
|
||||||
|
if (exists(ref_file) && read(ref_file).startsWith('ref: ')) {
|
||||||
|
return trim_newline(read(ref_file)).substr('ref: '.length);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</textarea>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="git-rev-parse">
|
||||||
|
<h1><code>git rev-parse</code></h1>
|
||||||
|
<textarea>
|
||||||
|
function git_rev_parse(ref) {
|
||||||
|
var symbolic_ref_target = git_symbolic_ref(ref);
|
||||||
|
if (symbolic_ref_target) {
|
||||||
|
// symbolic ref like "ref: refs/heads/main"
|
||||||
|
return git_rev_parse(symbolic_ref_target);
|
||||||
|
} else if (/[0-9a-f]{40}/.test(ref)) {
|
||||||
|
// hash like "0123456789abcdef0123456789abcdef01234567"
|
||||||
|
return ref;
|
||||||
|
} else if (ref == 'HEAD') {
|
||||||
|
// user-friendly reference like "HEAD"
|
||||||
|
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/' + ref))));
|
||||||
|
} else if (ref.startsWith('refs/') && exists(join_paths(current_directory, '.git/' + ref))) {
|
||||||
|
// user-friendly reference like "refs/heads/main"
|
||||||
|
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/' + ref))));
|
||||||
|
} else if (exists(join_paths(current_directory, '.git/refs/heads/' + ref))) {
|
||||||
|
// user-friendly reference like "main" (a branch)
|
||||||
|
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/refs/heads/' + ref))));
|
||||||
|
} else if (exists(join_paths(current_directory, '.git/refs/tags/' + ref))) {
|
||||||
|
// user-friendly reference like "v1.0" (a branch)
|
||||||
|
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/refs/tags/' + ref))));
|
||||||
|
} else {
|
||||||
|
// unknown ref
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</textarea>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="git-branch">
|
<section id="git-branch">
|
||||||
<h1><code>git branch</code></h1>
|
<h1><code>git branch</code></h1>
|
||||||
<p>A branch is a pointer to a commit, stored in a file in <code>.git/refs/heads/name_of_the_branch</code>.
|
<p>A branch is a pointer to a commit, stored in a file in <code>.git/refs/heads/name_of_the_branch</code>.
|
||||||
|
@ -456,48 +509,6 @@ function advance_head(new_commit_hash) {
|
||||||
}
|
}
|
||||||
</textarea>
|
</textarea>
|
||||||
<textarea>
|
<textarea>
|
||||||
function git_rev_parse(ref) {
|
|
||||||
var symbolic_ref_target = git_symbolic_ref(ref);
|
|
||||||
if (symbolic_ref_target) {
|
|
||||||
// symbolic ref like "ref: refs/heads/main"
|
|
||||||
return git_rev_parse(symbolic_ref_target);
|
|
||||||
} else if (/[0-9a-f]{40}/.test(ref)) {
|
|
||||||
// hash like "0123456789abcdef0123456789abcdef01234567"
|
|
||||||
return ref;
|
|
||||||
} else if (ref == 'HEAD') {
|
|
||||||
// user-friendly reference like "HEAD"
|
|
||||||
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/' + ref))));
|
|
||||||
} else if (ref.startsWith('refs/') && exists(join_paths(current_directory, '.git/' + ref))) {
|
|
||||||
// user-friendly reference like "refs/heads/main"
|
|
||||||
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/' + ref))));
|
|
||||||
} else if (exists(join_paths(current_directory, '.git/refs/heads/' + ref))) {
|
|
||||||
// user-friendly reference like "main" (a branch)
|
|
||||||
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/refs/heads/' + ref))));
|
|
||||||
} else if (exists(join_paths(current_directory, '.git/refs/tags/' + ref))) {
|
|
||||||
// user-friendly reference like "v1.0" (a branch)
|
|
||||||
return git_rev_parse(trim_newline(read(join_paths(current_directory, '.git/refs/tags/' + ref))));
|
|
||||||
} else {
|
|
||||||
// unknown ref
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea>
|
|
||||||
<textarea>
|
|
||||||
function git_symbolic_ref(ref) {
|
|
||||||
var ref_file = join_paths(current_directory, '.git/' + ref);
|
|
||||||
if (exists(ref_file) && read(ref_file).startsWith('ref: ')) {
|
|
||||||
return trim_newline(read(ref_file)).substr('ref: '.length);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea>
|
|
||||||
<textarea>
|
|
||||||
function trim_newline(s) {
|
|
||||||
if (s.endsWith('\n')) { return s.substr(0, s.length-1); } else { return s; }
|
|
||||||
}
|
|
||||||
</textarea>
|
|
||||||
<textarea>
|
|
||||||
write('proj/README', 'This is my Scheme project -- with updates!');
|
write('proj/README', 'This is my Scheme project -- with updates!');
|
||||||
var second_commit = git_commit(['README', 'src/main.scm'], 'Some updates');
|
var second_commit = git_commit(['README', 'src/main.scm'], 'Some updates');
|
||||||
</textarea>
|
</textarea>
|
||||||
|
@ -804,8 +815,8 @@ current_directory = '';
|
||||||
</textarea>
|
</textarea>
|
||||||
|
|
||||||
<textarea id="playground-play">
|
<textarea id="playground-play">
|
||||||
cd('proj');
|
|
||||||
mkdir('proj');
|
mkdir('proj');
|
||||||
|
cd('proj');
|
||||||
write('proj/README', 'This is my implementation of GIT.\n');
|
write('proj/README', 'This is my implementation of GIT.\n');
|
||||||
mkdir('proj/src');
|
mkdir('proj/src');
|
||||||
write('proj/src/main.scm', "(define filesystem '())\n...\n");
|
write('proj/src/main.scm', "(define filesystem '())\n...\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user