[PATCH] git-fetch, git-parse-remote: Cleanup implementation of '.'
As per the mailing list exchanges, this applies the following changes:
- renames the data source from 'builtin' to 'self'.
- renames fetch_packs/fetch_heads to fetch_per_ref and fetch_all_at_once
- processes any remote whose URL is '.' (not only the builtin one) using
native-store (this is tested by t3200-branch.sh).
Signed-Off-By: Paolo Bonzini <bonzini@gnu.org>
---
git-fetch.sh | 33 +++++++++++++--------------------
git-parse-remote.sh | 8 ++++----
2 files changed, 17 insertions(+), 24 deletions(-)
The patch is a cleanup of the one you posted, and it was
appropriately tested with no regression.
I can see now what you meant by the split between fetch and
merge logic making my patch more complicated than necessary.
diff --git a/git-fetch.sh b/git-fetch.sh
index 3b01f06..a650116 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -161,7 +161,7 @@ then
fi
fi
-fetch_packs () {
+fetch_all_at_once () {
eval=$(echo "$1" | git-fetch--tool parse-reflist "-")
eval "$eval"
@@ -169,7 +169,9 @@ fetch_packs () {
( : subshell because we muck with IFS
IFS=" $LF"
(
- if test -f "$remote" ; then
+ if test "$remote" = . ; then
+ git-show-ref $rref || echo failed "$remote"
+ elif test -f "$remote" ; then
test -n "$shallow_depth" &&
die "shallow clone with bundle is not supported"
git-bundle unbundle "$remote" $rref ||
@@ -192,7 +194,7 @@ fetch_packs () {
}
-fetch_heads () {
+fetch_per_ref () {
reflist="$1"
refs=
rref=
@@ -286,10 +288,6 @@ fetch_heads () {
rsync_slurped_objects=t
}
;;
- .)
- local_name=$remote_name
- head=$(git-rev-parse --verify "$local_name")
- ;;
esac
append_fetch_head "$head" "$remote" \
@@ -300,19 +298,14 @@ fetch_heads () {
}
fetch_main () {
- data_source=$(get_data_source "$remote_nick")
- if test "$data_source" = builtin; then
- fetch_heads "$@"
- else
- case "$remote" in
- http://* | https://* | ftp://* | rsync://* )
- fetch_heads "$@"
- ;;
- *)
- fetch_packs "$@"
- ;;
- esac
- fi
+ case "$remote" in
+ http://* | https://* | ftp://* | rsync://* )
+ fetch_per_ref "$@"
+ ;;
+ *)
+ fetch_all_at_once "$@"
+ ;;
+ esac
}
fetch_main "$reflist" || exit
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index a94215d..f25f9c1 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -10,7 +10,7 @@ get_data_source () {
echo ''
;;
.)
- echo builtin
+ echo self
;;
*)
if test "$(git-config --get "remote.$1.url")"
@@ -34,7 +34,7 @@ get_remote_url () {
'')
echo "$1"
;;
- builtin)
+ self)
echo "$1"
;;
config)
@@ -63,7 +63,7 @@ get_default_remote () {
get_remote_default_refs_for_push () {
data_source=$(get_data_source "$1")
case "$data_source" in
- '' | branches | builtin)
+ '' | branches | self)
;; # no default push mapping, just send matching refs.
config)
git-config --get-all "remote.$1.push" ;;
@@ -169,7 +169,7 @@ get_remote_default_refs_for_fetch () {
case "$data_source" in
'')
echo "HEAD:" ;;
- builtin)
+ self)
canon_refs_list_for_fetch -d "$1" \
$(git-show-ref | sed -n 's,.*[ ]\(refs/.*\),\1:,p') ;;
config)