]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/git/diff
64206c4a72d200fef08d8f60ab412a5f62e9517a
[plan9front.git] / sys / src / cmd / git / diff
1 #!/bin/rc
2 rfork ne
3 . /sys/lib/git/common.rc
4
5 gitup
6
7 flagfmt='c:commit branch, s:summarize'; args='[file ...]'
8 eval `''{aux/getflags $*} || exec aux/usage
9
10 if(~ $#commit 0)
11         commit=HEAD
12
13 files=()
14 if(! ~ $#* 0)
15         files=`{cleanname -d $gitrel $*}
16
17 branch=`{git/query -p $commit}
18 if(~ $summarize 1){
19         git/walk -fMAR $files
20         exit
21 }
22
23 fn lsdirty {
24         git/walk -c -fRMA $files
25         if(! ~ $commit HEAD)
26                 git/query -c $commit HEAD | subst '^..'
27 }
28
29 mntgen /mnt/scratch
30 bind $branch/tree/ /mnt/scratch/a
31 bind . /mnt/scratch/b
32 echo diff `{git/query $commit} uncommitted
33 for(f in `$nl{lsdirty | sort | uniq}){
34         cd /mnt/scratch
35         if(! test -f a/$f)
36                 orig=/dev/null
37         if(! test -f b/$f)
38                 f=/dev/null
39         diff -u a/$f b/$f
40 }
41 exit ''