Commit def16e71 authored by Brandon Casey's avatar Brandon Casey Committed by Junio C Hamano remove temporary directory on failure

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: default avatarBrandon Casey <>
Acked-by: Johannes Schindelin's avatarJohannes Schindelin <>
Signed-off-by: default avatarJunio C Hamano <>
parent 0eab8ca6
......@@ -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
......@@ -406,6 +409,8 @@ fi
cd ../..
rm -rf "$tempdir"
trap - 0
test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment