diff options
Diffstat (limited to 'comp2041/tigger/tigger-init')
| -rwxr-xr-x | comp2041/tigger/tigger-init | 39 |
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 |
