SUBDIRECTORY_OK=Yes
. git-sh-setup
set_reflog_action "fetch $*"
+cd_to_toplevel ;# probably unnecessary...
-TOP=$(git-rev-parse --show-cdup)
-if test ! -z "$TOP"
-then
- cd "$TOP"
-fi
. git-parse-remote
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
esac
}
-case "$update_head_ok" in
-'')
+# updating the current HEAD with git-fetch in a bare
+# repository is always fine.
+if test -z "$update_head_ok" && test $(is_bare_repository) = false
+then
orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
- ;;
-esac
+fi
# If --tags (and later --heads or --all) is specified, then we are
# not talking about defaults stored in Pull: line of remotes or
;; # we are already done.
*)
( : subshell because we muck with IFS
- pack_lockfile=
IFS=" $LF"
(
- git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref || echo failed "$remote"
+ git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
+ echo failed "$remote"
) |
- while read sha1 remote_name
- do
+ (
+ trap '
+ if test -n "$keepfile" && test -f "$keepfile"
+ then
+ rm -f "$keepfile"
+ fi
+ ' 0
+
+ keepfile=
+ while read sha1 remote_name
+ do
case "$sha1" in
failed)
echo >&2 "Fetch failure: $remote"
pack)
continue ;;
keep)
- pack_lockfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
+ keepfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
continue ;;
esac
found=
append_fetch_head "$sha1" "$remote" \
"$remote_name" "$remote_nick" "$local_name" \
"$not_for_merge" || exit
- done &&
- if [ "$pack_lockfile" ]; then rm -f "$pack_lockfile"; fi
+ done
+ )
) || exit ;;
esac