summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2018-10-09 22:30:34 -0400
committerMalf Furious <m@lfurio.us>2018-10-09 22:30:34 -0400
commit9f3b98c7cc7e04369367e97a9cb328443ad9f0c0 (patch)
treeed288c392509ad87e1e112faf695c09b0c73f555
parent942d22a2fec76dcadc34225f7c8ce80d286e52df (diff)
parentb61e56981dd705b56496090972d085a8b77d5366 (diff)
downloadsystrunk-0.2.tar.gz
systrunk-0.2.zip
Merge branch 'diff'HEADv0.2master
-rw-r--r--diff.sh60
-rw-r--r--main.sh4
-rwxr-xr-xmake.sh2
-rw-r--r--repo-access.sh10
4 files changed, 73 insertions, 3 deletions
diff --git a/diff.sh b/diff.sh
new file mode 100644
index 0000000..9f3480c
--- /dev/null
+++ b/diff.sh
@@ -0,0 +1,60 @@
+##
+# systrunk diff [<from>=BASE] [<to>=WKTREE]
+#
+# Perform a unified diff (diff -u) between <from> and <to>, which
+# should be two revisions in the repository. If not supplied, <to>
+# will be the worktree. Otherwise, there is no way to specify the
+# worktree.
+##
+function systr_diff
+{
+ if [ $# -lt 2 ]; then
+ to="."
+ else
+ to=$(systr_repo_resolve_reference "$2")
+ to="$path/revs/$to/"
+ fi
+
+ if [ $# -lt 1 ]; then
+ from="$BASE"
+ else
+ from=$(systr_repo_resolve_reference "$1")
+ fi
+
+ from="$path/revs/$from/"
+
+ diff -ruNd --color=auto --exclude='*.systr' "$from" "$to"
+}
+
+##
+# systrunk shortdiff [<from>=BASE] [<to>=WKTREE]
+#
+# Indicate only names of files that have been changed, added,
+# or removed between <from> and <to>, which should be two
+# revisions in the repository. If not supplied, <to> will be
+# the worktree. Otherwise, there is no way to specify the
+# worktree.
+##
+function systr_short_diff
+{
+ if [ $# -lt 2 ]; then
+ to="."
+ else
+ to=$(systr_repo_resolve_reference "$2")
+ to="$path/revs/$to/"
+ fi
+
+ if [ $# -lt 1 ]; then
+ from="$BASE"
+ else
+ from=$(systr_repo_resolve_reference "$1")
+ fi
+
+ if [[ "$from" == "NULL" ]]; then
+ exit
+ fi
+
+ from="$path/revs/$from/"
+
+ diff -qr --exclude='*.systr' "$from" "$to"
+}
diff --git a/main.sh b/main.sh
index f5a2df7..63c43ff 100644
--- a/main.sh
+++ b/main.sh
@@ -55,6 +55,10 @@ function main
systr_short_log "$@"
elif [[ "$cmd" == "log" ]]; then
systr_log "$@"
+ elif [[ "$cmd" == "shortdiff" ]]; then
+ systr_short_diff "$@"
+ elif [[ "$cmd" == "diff" ]]; then
+ systr_diff "$@"
elif [[ "$cmd" == "merge" ]]; then
systr_merge "$@"
elif [[ "$cmd" == "update" ]]; then
diff --git a/make.sh b/make.sh
index 7c40920..0ba5124 100755
--- a/make.sh
+++ b/make.sh
@@ -1,5 +1,5 @@
#!/usr/bin/bash
echo "#!/usr/bin/bash -e" >systrunk
cat rsync.sh repo-access.sh repo-mutate.sh >>systrunk
-cat checkout.sh commit.sh merge.sh main.sh >>systrunk
+cat checkout.sh commit.sh merge.sh diff.sh main.sh >>systrunk
chmod +x systrunk
diff --git a/repo-access.sh b/repo-access.sh
index 3e9fa8d..3685318 100644
--- a/repo-access.sh
+++ b/repo-access.sh
@@ -193,12 +193,13 @@ function systr_init
}
##
-# systrunk status
+# systrunk status [-d]
#
# View current information such as which branch your worktree is
# TRACking, which commit it is BASEd on, and how far out-of-date
# it is. Additionally, report whether a merge or update operation
-# is currently in-progress.
+# is currently in-progress. If '-d' is given, status will be
+# accompanied by a shortdiff of pending, uncommitted changes.
##
function systr_status
{
@@ -237,4 +238,9 @@ function systr_status
echo "Behind $dist commits"
fi
fi
+
+ if [[ "$1" == "-d" ]]; then
+ echo ""
+ systrunk shortdiff && echo "No pending changes"
+ fi
}