Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/root/sys/src/cmd/git/test/diff.rc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

. ./util.rc

nl='
'
rm -fr scratch
mkdir -p scratch/subdir/subdir2
mkdir -p scratch/subdir3

echo @@git diff -s relative@@
@{
	cd scratch
	q git/init
	echo hello > file.txt
	echo hello1 > subdir/file1.txt
	echo hello2 > subdir/subdir2/file2.txt
	echo hello3 > subdir3/file3.txt
	q git/add file.txt subdir/file1.txt subdir/subdir2/file2.txt subdir3/file3.txt
	q git/commit -m initial .
	echo >file.txt
	echo >subdir/file1.txt
	echo >subdir/subdir2/file2.txt
	echo >subdir3/file3.txt

	ifs=$nl {
		out=`{git/diff -s . | awk '{ print $2 }'}
	}
	~ $out(1) file.txt && ~ $out(2) subdir/file1.txt && ~ $out(3) subdir/subdir2/file2.txt \
		~ $out(4) subdir3/file3.txt || die 'base level fail'

	cd subdir
	ifs=$nl {
		out=`{git/diff -s .. | awk '{ print $2 }'}
	}
	~ $out(1) ../file.txt && ~ $out(2) file1.txt && ~ $out(3) subdir2/file2.txt \
		~ $out(4) ../subdir3/file3.txt || die 'subdir1 level fail'

	cd subdir2
	ifs=$nl {
		out=`{git/diff -s ../.. | awk '{ print $2 }'}
	}
	~ $out(1) ../../file.txt && ~ $out(2) ../file1.txt && ~ $out(3) file2.txt \
		~ $out(4) ../../subdir3/file3.txt || die 'subdir2 level fail'

	cd ../../subdir3
	ifs=$nl {
		out=`{git/diff -s .. | awk '{ print $2 }'}
	}
	~ $out(1) ../file.txt && ~ $out(2) ../subdir/file1.txt && ~ $out(3) ../subdir/subdir2/file2.txt \
		~ $out(4) file3.txt || die 'subdir3 level fail'

	! git/diff -s ../.. >[2]/dev/null
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.