summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git/diff
blob: 64206c4a72d200fef08d8f60ab412a5f62e9517a (plain)
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
#!/bin/rc
rfork ne
. /sys/lib/git/common.rc

gitup

flagfmt='c:commit branch, s:summarize'; args='[file ...]'
eval `''{aux/getflags $*} || exec aux/usage

if(~ $#commit 0)
	commit=HEAD

files=()
if(! ~ $#* 0)
	files=`{cleanname -d $gitrel $*}

branch=`{git/query -p $commit}
if(~ $summarize 1){
	git/walk -fMAR $files
	exit
}

fn lsdirty {
	git/walk -c -fRMA $files
	if(! ~ $commit HEAD)
		git/query -c $commit HEAD | subst '^..'
}

mntgen /mnt/scratch
bind $branch/tree/ /mnt/scratch/a
bind . /mnt/scratch/b
echo diff `{git/query $commit} uncommitted
for(f in `$nl{lsdirty | sort | uniq}){
	cd /mnt/scratch
	if(! test -f a/$f)
		orig=/dev/null
	if(! test -f b/$f)
		f=/dev/null
	diff -u a/$f b/$f
}
exit ''