Skip to content

Commit

Permalink
filter-branch.sh: remove temporary directory on failure
Browse files Browse the repository at this point in the history
One of the first things filter-branch does is to create a temporary
directory. This directory is eventually removed by the script during
normal operation, but is not removed if the script encounters an error.

Set a trap to remove it when the script terminates for any reason.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
drafnel authored and gitster committed Jan 30, 2008
1 parent 0eab8ca commit def16e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions git-filter-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ cd "$tempdir/t" &&
workdir="$(pwd)" ||
die ""

# Remove tempdir on exit
trap 'cd ../..; rm -rf "$tempdir"' 0

# Make sure refs/original is empty
git for-each-ref > "$tempdir"/backup-refs
while read sha1 type name
Expand Down Expand Up @@ -406,6 +409,8 @@ fi
cd ../..
rm -rf "$tempdir"

trap - 0

unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
test -z "$ORIG_GIT_WORK_TREE" || GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
Expand Down

0 comments on commit def16e7

Please sign in to comment.