shithub: git9

Download patch

ref: 72fbfa9bb7a264e1c7a2175cb36a06effb628cf7
parent: f28cb3a880a38864884e8c5e791c191dd477cd97
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 28 22:20:07 EST 2020

git/diff: show each file once (thanks Igor Boehm)

git/diff listed all files changed in tree, as well
as any files changed compared to the branch being
diffed against; this could lead to duplicates in
the list of changed files.

This change sorts and uniqs them, which both gives
a stable order and removes duplicates.

--- a/diff
+++ b/diff
@@ -9,18 +9,24 @@
 
 if(~ $#commit 0)
 	commit=HEAD
+
 files=()
 if(! ~ $#* 0)
 	files=`{cleanname $gitrel/$*}
+
 branch=`{git/query -p $commit}
 if(~ $summarize 1){
 	git/walk -fMAR $files
 	exit
 }
-dirty=`$nl{git/walk -c -fRMA $files}
-if(! ~ $commit HEAD)
-	dirty=($dirty `$nl{git/query -c $commit HEAD | subst '^..'})
-for(f in $dirty){
+
+fn lsdirty {
+	git/walk -c -fRMA $files
+	if(! ~ $commit HEAD)
+		git/query -c $commit HEAD | subst '^..'
+}
+
+for(f in `$nl{lsdirty | sort | uniq}){
 	orig=$branch/tree/$f
 	if(! test -f $orig)
 		orig=/dev/null