Skip to content

Commit 41ff7a1

Browse files
cworth-ghJunio C Hamano
authored andcommitted
Trap exit to clean up created directory if clone fails.
Signed-off-by: Carl Worth <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent babfaf8 commit 41ff7a1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git-clone.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ dir="$2"
118118
[ -e "$dir" ] && echo "$dir already exists." && usage
119119
mkdir -p "$dir" &&
120120
D=$(cd "$dir" && pwd) &&
121+
trap 'err=$?; rm -r $D; exit $err' exit
121122
case "$bare" in
122123
yes) GIT_DIR="$D" ;;
123124
*) GIT_DIR="$D/.git" ;;
@@ -255,3 +256,6 @@ Pull: $head_points_at:$origin" &&
255256
git checkout
256257
esac
257258
fi
259+
260+
trap - exit
261+

0 commit comments

Comments
 (0)