summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-04-28 01:39:38 -0400
committerMalf Furious <m@lfurio.us>2017-04-28 01:39:38 -0400
commitc9c0749416f848d07f33feb2b37bc09c97caf73d (patch)
treed96f8fc5f2e5e06c499146e85756de4033b8560c
parent9ada601ecdbe5b03b15385e9e65d98ad3aad7ff7 (diff)
downloadsystrunk-c9c0749416f848d07f33feb2b37bc09c97caf73d.tar.gz
systrunk-c9c0749416f848d07f33feb2b37bc09c97caf73d.zip
Add init module
-rw-r--r--init.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/init.sh b/init.sh
new file mode 100644
index 0000000..b772015
--- /dev/null
+++ b/init.sh
@@ -0,0 +1,39 @@
+##
+# init_wktree <unused> <unused> [<remote>] <path>
+#
+# Assert that the repository at <path> exists, then setup the
+# .systr directory at the CWD.
+##
+function init_wktree
+{
+ if [ $# -gt 3 ]; then
+ remote=$3
+ shift
+ else
+ remote=""
+ fi
+
+ path=$3
+
+ # local repository #
+ if [[ "$remote" == "" ]]; then
+ if [ ! -f "$path/HEAD" ]; then
+ echo "Error: $path is not a repository"
+ exit 1
+ fi
+
+ mkdir -p .systr/
+
+ echo "" >.systr/remote
+ echo "$path" >.systr/path
+ echo "NULL" >.systr/BASE
+ echo "NULL" >.systr/TRAC
+
+ echo "Setup worktree at $(pwd)"
+
+ # remote repository #
+ else
+ exit 1
+
+ fi
+}