aboutsummaryrefslogtreecommitdiff
path: root/comp2041/tigger/tigger-init
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
commit98cef5e9a772602d42acfcf233838c760424db9a (patch)
tree5277fa1d7cc0a69a0f166fcbf10fd320f345f049 /comp2041/tigger/tigger-init
initial commit
Diffstat (limited to 'comp2041/tigger/tigger-init')
-rwxr-xr-xcomp2041/tigger/tigger-init39
1 files changed, 39 insertions, 0 deletions
diff --git a/comp2041/tigger/tigger-init b/comp2041/tigger/tigger-init
new file mode 100755
index 0000000..cee1a77
--- /dev/null
+++ b/comp2041/tigger/tigger-init
@@ -0,0 +1,39 @@
+#!/bin/dash
+
+# We will create a new file in .tigger called "branch.tig" with our current
+# branch. By default this should be master. All future ops should read this.
+
+# Commits will be contained in files starting at 0...n inside our branch dir.
+# Our directory heirarchy might look like:
+# .tigger/
+# branch.tig // current branch
+# commit_count.tig // see the below comment @ echo "0"...
+# master/
+# 0/
+# commit/
+# staged/
+# message.tig // because we have a message, it's a finished commit
+# 1/
+# commit/
+# staged/
+
+if [ -d ".tigger/" ]; then
+ printf "tigger-init: error: .tigger already exists\n" >&2
+ exit 1
+fi
+
+branch="master" # in future should be ~ branch=$(cat ./.tigger/branch.tig)
+mkdir --parents ".tigger/$branch"
+echo "$branch" > ".tigger/branch.tig"
+
+# This is necessary because their implementation of git branch considers a
+# global commit count as opposed to a (more logical) per branch commit count.
+# Whenever we do any commit we have to increment this value (which is only
+# used for printing so that we are compliant with their autotests).
+echo "0" > .tigger/commit_count.tig
+
+mkdir --parents ".tigger/$branch/0/commit"
+mkdir --parents ".tigger/$branch/0/staged"
+
+printf "Initialized empty tigger repository in .tigger\n"
+exit 0