chiark / gitweb /
tests/lib: break out t-untar and use it in t-worktree
[dgit.git] / tests / lib
index fb6b2fc..2dffdac 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -39,9 +39,19 @@ fail () {
        exit 1
 }
 
+t-untar () {
+       local tarfile=$1.tar
+       local edittree=$1.edit
+       if test -d "$edittree"; then
+               cp -al "$edittree"/* .
+       else
+               tar xf "$tarfile"
+       fi
+}
+
 t-worktree () {
        rm -rf $p
-       tar xf $troot/worktrees/${p}_$1.tar
+       t-untar $troot/worktrees/${p}_$1
 }
 
 t-git () {
@@ -49,11 +59,7 @@ t-git () {
        v=$2
        mkdir -p $tmp/git
        local gs=$troot/git-srcs/${p}_$v.git
-       if test -f $gs.edit; then
-               cp -al $gs.edit $tmp/git/${p}.git
-       else
-               (set -e; cd $tmp/git; tar xf $gs.tar)
-       fi
+       (set -e; cd $tmp/git; t-untar $gs)
 }
 
 t-git-none () {