diff options
| author | Malf Furious <m@lfurio.us> | 2018-10-09 22:14:41 -0400 | 
|---|---|---|
| committer | Malf Furious <m@lfurio.us> | 2018-10-09 22:14:41 -0400 | 
| commit | 53b619e1c927c518c27150c8ac0a4c99791c61cd (patch) | |
| tree | 962a42d418d04805f2eb20dcade758ed175dc665 /diff.sh | |
| parent | 942d22a2fec76dcadc34225f7c8ce80d286e52df (diff) | |
| download | systrunk-53b619e1c927c518c27150c8ac0a4c99791c61cd.tar.gz systrunk-53b619e1c927c518c27150c8ac0a4c99791c61cd.zip | |
Add diff / shortdiff ops
Diffstat (limited to 'diff.sh')
| -rw-r--r-- | diff.sh | 60 | 
1 files changed, 60 insertions, 0 deletions
| @@ -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" +} | 
