summaryrefslogtreecommitdiffstats
path: root/diff.sh
blob: 9f3480c418a89e27239999acb27e7f9a6bd9581f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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"
}