From 5fc7e504cec89ceec6ddbb37c326e74fe3d4e705 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C4=81nis=20R=C5=ABcis?= Date: Mon, 16 Aug 2010 15:36:19 +0300 Subject: [PATCH] import-pk3: use a separate index file --- misc/tools/git-import-pk3 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/misc/tools/git-import-pk3 b/misc/tools/git-import-pk3 index a2c243a4..f9680ac7 100755 --- a/misc/tools/git-import-pk3 +++ b/misc/tools/git-import-pk3 @@ -66,11 +66,29 @@ message() echo -e "Import $pk3name\n" | cat - "$changes" 2> /dev/null } +# 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 +} + # Extract the PK3 (the -n suppresses prompting in an edge case) -# FIXME: perhaps the caller should handle extraction and clean up unzip -n -qq "$pk3path" -d "$GIT_WORK_TREE" || die "couldn't extract PK3 contents" -trap 'find "$GIT_WORK_TREE" -mindepth 1 -delete' EXIT +cleanup_worktree=t # Note the refs and the common ancestor master=refs/heads/master -- 2.39.2