From 53b619e1c927c518c27150c8ac0a4c99791c61cd Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 9 Oct 2018 22:14:41 -0400 Subject: Add diff / shortdiff ops --- diff.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 diff.sh (limited to 'diff.sh') 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 [=BASE] [=WKTREE] +# +# Perform a unified diff (diff -u) between and , which +# should be two revisions in the repository. If not supplied, +# 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 [=BASE] [=WKTREE] +# +# Indicate only names of files that have been changed, added, +# or removed between and , which should be two +# revisions in the repository. If not supplied, 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" +} -- cgit v1.2.3