chiark / gitweb /
test suite: gitattributes: Test that checkout is good too
[dgit.git] / tests / tests / gitattributes
index 286395d6b5e7fd968b334a556580d8300c1abe84..e6089bd9cdda9007c597a7e2c9728cf9a3e90d48 100755 (executable)
@@ -103,22 +103,41 @@ sfmt_setup () {
        cd ..
 }
 
+sums_check () {
+       # caller should cd into working directory, set
+       #   $sums  $branch
+       # and check out $branch
+
+       sha256sum af/* >../$sums.checkout
+       diff -U0 ../sums ../$sums.checkout
+
+       for f in af/*; do
+               git cat-file blob "refs/heads/$branch:$f" \
+                       | sha256sum \
+                       | sed -e 's#-$#'$f'#' \
+               >>../$sums
+       done
+
+       diff -U0 ../sums ../$sums
+}
+
 sfmt_import () {
        inst=$1
        dgitargs=$2
-       refname="import.$sfmt-$inst"
+       branch="import.$sfmt-$inst"
        brkerr=stderr.$sfmt-$inst.broken
        dscf=${p}_${v}.dsc
+       sums=sums.$sfmt-$inst
 
        mkdir $pdb-import-$inst
        cd $pdb-import-$inst
        git init
 
        LC_MESSAGES=C \
-       t-dgit $dgitargs import-dsc ../$dscf +$refname.broken \
+       t-dgit $dgitargs import-dsc ../$dscf +$branch.broken \
                2>&1 |tee ../$brkerr
        fgrep 'warning: source tree contains .gitattributes' ../$brkerr
-       git checkout $refname.broken
+       git checkout $branch.broken
        sha256sum af/* >../$sums.broken
 
        for s in ../sums ../$sums.broken; do
@@ -133,20 +152,13 @@ sfmt_import () {
 
        t-dgit setup-new-tree
 
-       t-dgit $dgitargs import-dsc ../$dscf +$refname
-       git checkout $refname
+       t-dgit $dgitargs import-dsc ../$dscf +$branch
+       git checkout $branch
+       git reset --hard
 
-       sums=sums.$sfmt-$inst
-
-       for f in af/*; do
-               git cat-file blob "refs/heads/$refname:$f" \
-                       | sha256sum \
-                       | sed -e 's#-$#'$f'#' \
-               >>../$sums
-       done
+       sums_check
 
        cd ..
-       diff -U0 sums $sums
 }
 
 : ----- generate the orig -----