From bacc1c866e2c30b4939292056d273289757f1124 Mon Sep 17 00:00:00 2001
From: Suzanne Soy ' + log.map(function(l) { return l.map(function (x) { return x.toString(); }).join(', '); }).join('\n') + '
'
+ + ___filesystem_to_string(filesystem, false, previous_filesystem);
+}
function ___git_eval(current) {
document.getElementById('hide-eval-' + current).style.display = '';
- var script = '';
+ var script = ___script_log_header;
for (i = 0; i <= current - 1; i++) {
script += ___textarea_value(___global_editors[i]);
}
- script += "\n var ___previous_filesystem = {}; for (k in filesystem) { ___previous_filesystem[k] = filesystem[k]; }\n";
+ script += '\n'
+ + 'var ___previous_filesystem = {};\n'
+ + 'for (k in filesystem) { ___previous_filesystem[k] = filesystem[k]; }\n'
+ + '___log = [];\n';
script += ___textarea_value(___global_editors[current]);
- script += "\n document.getElementById('out' + current).innerHTML = ___filesystem_to_string(filesystem, false, ___previous_filesystem); filesystem;";
+ script += '\n'
+ + '"End of the script";\n'
+ + '\n'
+ + '\n'
+ + 'document.getElementById("out" + current).innerHTML = ___eval_result_to_string(filesystem, ___previous_filesystem, ___log);\n'
+ + 'filesystem;\n';
try {
- global_filesystem = eval(script);
+ document.getElementById('debug').innerText = script;
+ eval(script);
} catch (e) {
+ // Stack traces usually include :line:column
+ var rx = /:([0-9][0-9]*):[0-9][0-9]*/g;
+ var linecol = rx.exec(''+e.stack);
+ var line = null;
+ if (linecol && linecol.length > 0) {
+ line=parseInt(linecol[1]);
+ } else {
+ // Some older versions of Firefox and probably some other browsers use just :line
+ var rx = /:([0-9][0-9]*)*/g;
+ var justline = rx.exec(''+e.stack);
+ if (justline && justline.length > 0) {
+ line=parseInt(justline[1], 10);
+ }
+ }
+ if (typeof(line) == 'number') {
+ var lines = script.split('\n');
+ if (line < lines.length) {
+ var from = Math.max(0, line-2);
+ var to = Math.min(lines.length - 1, line+2+1);
+ var showline = ''
+ + 'Possible location of the error: near line ' + line + '\n'
+ + '\n'
+ + lines.slice(from, to).map(function(l, i) { return '' + (from + i) + ': ' + l; }).join('\n')
+ + '\n'
+ + '\n';
+ }
+ } else {
+ var showline = 'Sorry, this tutorial could not pinpoint precisely\nthe location of the error.\n'
+ + 'The stacktrace below may contain more information.\n'
+ }
var error = ___specialchars("" + e + "\n\n" + e.stack);
- document.getElementById('out' + current).innerHTML = '' + error + '
';
+ document.getElementById('out' + current).innerHTML = '' + showline + error + '
';
}
}
diff --git a/index.html b/index.html
index d53b867..fd9fe40 100644
--- a/index.html
+++ b/index.html
@@ -516,7 +516,16 @@ directly to a commit hash like
or can point to another symbolic reference, in which case the .git/HEAD
file
will contain e.g. refs/heads/main
.
Branches are simple files stored in .git/refs/heads/name-of-the-branch
Branches are simple files stored in .git/refs/heads/name-of-the-branch
+and usually contain a hash like
+0123456789abcdef0123456789abcdef01234567.
Tags are identical to branches in terms of representation. It seems that the only difference
+between tags and branches is the behaviour of git checkout
and similar commands.
+These commands, as explained in the section about git checkout
below,
+normally write ref: refs/heads/name-of-branch
in .git/HEAD
when
+checking out a branch, but write the hash of the target commit when checking out a tag or
+any other non-branch reference.
git rev-parse
git rev-parse