summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.sh4
-rw-r--r--rsync.sh22
2 files changed, 26 insertions, 0 deletions
diff --git a/main.sh b/main.sh
index 5593dd8..f5a2df7 100644
--- a/main.sh
+++ b/main.sh
@@ -21,6 +21,8 @@ function main
systr_checkout "$@"
elif [[ "$cmd" == "init" ]]; then
systr_init "$@"
+ elif [[ "$cmd" == "clone" ]]; then
+ systr_clone "$@"
else
echo "Fatal: not in a worktree" >&2
exit 1
@@ -39,6 +41,8 @@ function main
systr_status "$@"
elif [[ "$cmd" == "init" ]]; then
systr_init "$@"
+ elif [[ "$cmd" == "clone" ]]; then
+ systr_clone "$@"
elif [[ "$cmd" == "checkout" ]]; then
systr_checkout "$@"
elif [[ "$cmd" == "commit" ]]; then
diff --git a/rsync.sh b/rsync.sh
index 165d360..d94677b 100644
--- a/rsync.sh
+++ b/rsync.sh
@@ -105,3 +105,25 @@ function systr_rsync_merge
rsync -azb --suffix='*' --exclude='*.systr' \
"$src" "$dst"
}
+
+##
+# systrunk clone <source> <destination>
+#
+# Recursively create a complete copy of a directory tree
+# which, presumabally, contains systrunk repositories.
+# This copy preserves all underlying hard-links as to
+# preserve the disk space saved by systrunk commit. Note:
+# --delete is passed to rsync!
+##
+function systr_clone
+{
+ if [ $# -lt 2 ]; then
+ echo "Fatal: too few args to clone" >&2
+ exit 1
+ fi
+
+ src="$1"
+ dst="$2"
+
+ rsync -azH --info=progress2 --info=stats2 --delete "$src" "$dst"
+}