git-fetch: remove .keep file at the end.
Removal of them is needed regardless of errors. The original code had the removal outside of the process which sets the flag to tell the later step what to remove, but it runs as a downstream of a pipeline and its effect was lost. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 1, 2007 at 12:24 UTC
ac9c1108d8915f0937795e354ad72c4ae6890a3f
1 file changed
+16
-7
git-fetch.sh
+16
-7
@@ -382,13 +382,22 @@ fetch_main () {
382
;; # we are already done.
383
*)
384
( : subshell because we muck with IFS
385
- pack_lockfile=
385
IFS=" $LF"
386
(
388
- git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref || echo failed "$remote"
387
+ git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
388
+ echo failed "$remote"
389
) |
390
- while read sha1 remote_name
391
- do
390
+ (
391
+ trap '
392
+ if test -n "$keepfile" && test -f "$keepfile"
393
+ then
394
+ rm -f "$keepfile"
395
+ fi
396
+ ' 0
397
+
398
+ keepfile=
399
+ while read sha1 remote_name
400
+ do
401
case "$sha1" in
402
failed)
403
echo >&2 "Fetch failure: $remote"
@@ -397,7 +406,7 @@ fetch_main () {
406
pack)
407
continue ;;
408
keep)
400
- pack_lockfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
409
+ keepfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
410
continue ;;
411
esac
412
found=
@@ -429,8 +438,8 @@ fetch_main () {
438
append_fetch_head "$sha1" "$remote" \
439
"$remote_name" "$remote_nick" "$local_name" \
440
"$not_for_merge" || exit
432
- done &&
433
- if [ "$pack_lockfile" ]; then rm -f "$pack_lockfile"; fi
441
+ done
442
+ )
443
) || exit ;;
444
esac
445