]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/git/diff
git/diff: clean up diffs
[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 showed=()
30 mntgen /mnt/scratch
31 bind $branch/tree/ /mnt/scratch/a
32 bind . /mnt/scratch/b
33 for(f in `$nl{lsdirty | sort | uniq}){
34         if(~ $#showed 0){
35                 echo diff `{git/query $commit} uncommitted
36                 showed=1
37         }
38         cd /mnt/scratch
39         a=a/$f
40         b=b/$f
41         if(! test -f a/$f)
42                 a=/dev/null
43         if(! test -f b/$f)
44                 b=/dev/null
45         diff -u $a $b
46 }
47 exit ''