]> git.lizzy.rs Git - plan9front.git/commitdiff
git/diff: clean up diffs
authorOri Bernstein <ori@eigenstate.org>
Mon, 23 Aug 2021 01:22:04 +0000 (01:22 +0000)
committerOri Bernstein <ori@eigenstate.org>
Mon, 23 Aug 2021 01:22:04 +0000 (01:22 +0000)
We were overzealous about showing the changed
header, as well as setting a junk variable for
files that didn't exist; fix both.

sys/src/cmd/git/diff

index 64206c4a72d200fef08d8f60ab412a5f62e9517a..28e69d660c8abe80d3dbac925b1133ea0635c214 100644 (file)
@@ -26,16 +26,22 @@ fn lsdirty {
                git/query -c $commit HEAD | subst '^..'
 }
 
+showed=()
 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}){
+       if(~ $#showed 0){
+               echo diff `{git/query $commit} uncommitted
+               showed=1
+       }
        cd /mnt/scratch
+       a=a/$f
+       b=b/$f
        if(! test -f a/$f)
-               orig=/dev/null
+               a=/dev/null
        if(! test -f b/$f)
-               f=/dev/null
-       diff -u a/$f b/$f
+               b=/dev/null
+       diff -u $a $b
 }
 exit ''