ref: 2d24dea30ee375b9f0e0690e544c5feccff26cb8
parent: 45b972bb1fc2c45267e5188498d493c800c7be83
author: Michael Forney <[email protected]>
date: Tue Sep 27 20:16:23 EDT 2022
git: add range tests
--- a/cmd/git/mkfile
+++ b/cmd/git/mkfile
@@ -5,6 +5,7 @@
basic\
export\
lca\
- merge
+ merge\
+ range
<../../regress
--- /dev/null
+++ b/cmd/git/range.rc
@@ -1,0 +1,75 @@
+#!/bin/rc
+
+. ../util.rc
+
+rm -fr scratch
+mkdir -p scratch
+cd scratch
+
+fn commit {
+ git/save -n regress -e regress $* f
+}
+
+# h→g→f
+# ↓ ↓
+# e→d→c→b→a
+echo @@ test range @@
+@{
+ q git/init a
+ cd a
+ touch f
+
+ a=`{commit -m a}
+ b=`{commit -m b -p $a}
+ c=`{commit -m c -p $b}
+ d=`{commit -m d -p $c}
+ e=`{commit -m e -p $d}
+ f=`{commit -m f -p $c}
+ g=`{commit -m g -p $f}
+ h=`{commit -m h -p $e -p $g}
+ map='
+ s/^'$a'$/a/
+ s/^'$b'$/b/
+ s/^'$c'$/c/
+ s/^'$d'$/d/
+ s/^'$e'$/e/
+ s/^'$f'$/f/
+ s/^'$g'$/g/
+ s/^'$h'$/h/
+ '
+
+ diff -u <{echo d; echo e; echo g; echo h} \
+ <{git/query $f..$h | sed -e $map} || die range
+}
+
+# b
+# ↙ ↖
+# f←e←d a
+# ↖ ↙
+# c
+echo @@ test range 2 @@
+@{
+ q git/init b
+ cd b
+ touch f
+
+ a=`{commit -m a}
+ b=`{commit -m b -p $a}
+ c=`{commit -m c -p $a}
+ d=`{commit -m d -p $b -p $c}
+ e=`{commit -m e -p $d}
+ f=`{commit -m f -p $e}
+ map='
+ s/^'$a'$/a/
+ s/^'$b'$/b/
+ s/^'$c'$/c/
+ s/^'$d'$/d/
+ s/^'$e'$/e/
+ s/^'$f'$/f/
+ '
+
+ diff -u <{echo c; echo d; echo e; echo f} \
+ <{git/query $b..$f | sed -e $map} || die range
+ diff -u <{echo b; echo d; echo e; echo f} \
+ <{git/query $c..$f | sed -e $map} || die range
+}