+# Clean up on exit
+
+cleanup_index=
+cleanup_worktree=
+
+cleanup()
+{
+ [ "$cleanup_index" ] && rm -f "$GIT_INDEX_FILE"
+ [ "$cleanup_worktree" ] && find "$GIT_WORK_TREE" -mindepth 1 -delete
+}
+
+trap cleanup EXIT
+
+# Set up index file, makes testing easier
+[ -z "$GIT_INDEX_FILE" ] && {
+ export GIT_INDEX_FILE="$GIT_DIR/import-pk3-index"
+ cleanup_index=t
+}
+