--- /dev/null
+#!/bin/sh
+#
+# Copyright (c) 2007 Karl Hasselström
+#
+
+test_description='Make sure that we can use old StGIT repositories'
+
+. ./test-lib.sh
+
+for ver in 0.12 0.8; do
+
+ tar zxf ../t4000-upgrade/$ver.tar.gz
+ cd $ver
+
+ test_expect_success \
+ "v$ver: Check the list of applied and unapplied patches" '
+ [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
+ [ "$(echo $(stg unapplied))" = "p3 p4" ]
+ '
+
+ test_expect_success \
+ "v$ver: Make sure the 'description' file is no longer there" '
+ [ ! -e .git/patches/master/description ] &&
+ [ "$(echo $(git config branch.master.description))" = "cool branch" ]
+ '
+
+ test_expect_success \
+ "v$ver: Make sure the 'current' file is no longer there" '
+ [ ! -e .git/patches/master/current ]
+ '
+
+ test_expect_success \
+ "v$ver: Make sure the base ref is no longer there" '
+ ! git show-ref --verify --quiet refs/bases/master
+ '
+
+ cd ..
+done
+
+test_done
--- /dev/null
+# This script makes several versions of a small test repository that
+# can be used for testing the format version upgrade code.
+
+LANG=C
+LC_ALL=C
+PAGER=cat
+TZ=UTC
+export LANG LC_ALL PAGER TZ
+unset AUTHOR_DATE
+unset AUTHOR_EMAIL
+unset AUTHOR_NAME
+unset COMMIT_AUTHOR_EMAIL
+unset COMMIT_AUTHOR_NAME
+unset GIT_ALTERNATE_OBJECT_DIRECTORIES
+unset GIT_AUTHOR_DATE
+GIT_AUTHOR_EMAIL=author@example.com
+GIT_AUTHOR_NAME='A U Thor'
+unset GIT_COMMITTER_DATE
+GIT_COMMITTER_EMAIL=committer@example.com
+GIT_COMMITTER_NAME='C O Mitter'
+unset GIT_DIFF_OPTS
+unset GIT_DIR
+unset GIT_EXTERNAL_DIFF
+unset GIT_INDEX_FILE
+unset GIT_OBJECT_DIRECTORY
+unset SHA1_FILE_DIRECTORIES
+unset SHA1_FILE_DIRECTORY
+export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
+
+for ver in 0.12 0.8; do
+ if [ -e $ver.tar.gz ]; then continue; fi
+
+ # Get the required stgit version.
+ (
+ cd ../..
+ git archive --format=tar --prefix=stgit-$ver/ v$ver
+ ) | tar xf -
+
+ # Set up a repository.
+ mkdir $ver
+ cd $ver
+ git init
+ touch foo
+ git add foo
+ git commit -m 'Initial commit'
+
+ # Use the old stgit.
+ (
+ pwd
+ PATH=../stgit-$ver:$PATH
+
+ stg --version
+ stg init
+ echo 'cool branch' > .git/patches/master/description
+
+ for i in 0 1 2 3 4; do
+ stg new p$i -m "Patch $i"
+ echo "Line $i" >> foo
+ stg refresh
+ done
+ stg pop -n 2
+ )
+
+ # Reduce the number of small files.
+ git gc
+
+ # Make a tarball.
+ cd ..
+ tar zcf $ver.tar.gz $ver
+done