summaryrefslogtreecommitdiff
path: root/git-fetch-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-07-16 07:16:24 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-16 16:23:06 (GMT)
commitf170e4b39d87365cda17b80436ba6db4a2044e88 (patch)
treedb95f53ae73c341922700257c15443080e176054 /git-fetch-script
parent02d57da4a5c238eff7ea115c69d2e5c977bf1adb (diff)
downloadgit-f170e4b39d87365cda17b80436ba6db4a2044e88.zip
git-f170e4b39d87365cda17b80436ba6db4a2044e88.tar.gz
git-f170e4b39d87365cda17b80436ba6db4a2044e88.tar.bz2
[PATCH] fetch/pull: short-hand notation for remote repositories.
Since pull and fetch are done often against the same remote repository repeatedly, keeping the URL to pull from along with the name of the head to use in $GIT_DIR/branches/$name makes a lot of sense. Adopt that convention from Cogito, and try to be compatible when possible; storing a partial URL and completing it with a trailing path may not be understood by Cogito. While we are at it, fix pulling a tag. Earlier, we updated only refs/tags/$tag without updating FETCH_HEAD, and called resolve-script using a stale (or absent) FETCH_HEAD. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'git-fetch-script')
-rwxr-xr-xgit-fetch-script36
1 files changed, 21 insertions, 15 deletions
diff --git a/git-fetch-script b/git-fetch-script
index acb1e56..fce43e6 100755
--- a/git-fetch-script
+++ b/git-fetch-script
@@ -1,33 +1,39 @@
#!/bin/sh
#
-destination=FETCH_HEAD
-
-merge_repo=$1
-merge_name=${2:-HEAD}
-if [ "$2" = "tag" ]; then
- merge_name="refs/tags/$3"
- destination="$merge_name"
-fi
-
. git-sh-setup-script || die "Not a git archive"
+. git-parse-remote "$@"
+merge_repo="$_remote_repo"
+merge_head="$_remote_head"
+merge_store="$_remote_store"
TMP_HEAD="$GIT_DIR/TMP_HEAD"
case "$merge_repo" in
http://*)
- head=$(wget -q -O - "$merge_repo/$merge_name") || exit 1
- echo Fetching $head using http
- git-http-pull -v -a "$head" "$merge_repo/"
+ head=$(wget -q -O - "$merge_repo/$merge_head") || exit 1
+ echo Fetching "$merge_head" using http
+ git-http-pull -v -a "$merge_head" "$merge_repo/"
;;
rsync://*)
- rsync -L "$merge_repo/$merge_name" "$TMP_HEAD" || exit 1
+ rsync -L "$merge_repo/$merge_head" "$TMP_HEAD" || exit 1
head=$(git-rev-parse TMP_HEAD)
rm -f "$TMP_HEAD"
rsync -avz --ignore-existing "$merge_repo/objects/" "$GIT_OBJECT_DIRECTORY/"
;;
*)
- head=$(git-fetch-pack "$merge_repo" "$merge_name")
+ head=$(git-fetch-pack "$merge_repo" "$merge_head")
;;
esac || exit 1
+
git-rev-parse --verify "$head" > /dev/null || exit 1
-echo "$head" > "$GIT_DIR/$destination"
+
+case "$merge_store" in
+'')
+ echo "$head" > "$GIT_DIR/$merge_store"
+esac &&
+
+# FETCH_HEAD is fed to git-resolve-script which will eventually be
+# passed to git-commit-tree as one of the parents. Make sure we do
+# not give a tag object ID.
+
+git-rev-parse "$head^0" >"$GIT_DIR/FETCH_HEAD"