summaryrefslogtreecommitdiffstats
path: root/diff.sh
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 /diff.sh
parent942d22a2fec76dcadc34225f7c8ce80d286e52df (diff)
parentb61e56981dd705b56496090972d085a8b77d5366 (diff)
downloadsystrunk-master.tar.gz
systrunk-master.zip
Merge branch 'diff'HEADv0.2master
Diffstat (limited to 'diff.sh')
-rw-r--r--diff.sh60
1 files changed, 60 insertions, 0 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"
+}