Skip to content

Commit

Permalink
Trap exit to clean up created directory if clone fails.
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Carl Worth authored and Junio C Hamano committed Feb 18, 2006
1 parent babfaf8 commit 41ff7a1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dir="$2"
[ -e "$dir" ] && echo "$dir already exists." && usage
mkdir -p "$dir" &&
D=$(cd "$dir" && pwd) &&
trap 'err=$?; rm -r $D; exit $err' exit
case "$bare" in
yes) GIT_DIR="$D" ;;
*) GIT_DIR="$D/.git" ;;
Expand Down Expand Up @@ -255,3 +256,6 @@ Pull: $head_points_at:$origin" &&
git checkout
esac
fi

trap - exit

0 comments on commit 41ff7a1

Please sign in to comment.