summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6687f8f)
raw | patch | inline | side by side (parent: 6687f8f)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 23 Aug 2005 04:28:33 +0000 (21:28 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 24 Aug 2005 23:50:52 +0000 (16:50 -0700) |
Just like "git push" can forcibly update a ref to a value that is not
a fast-forward, teach "git fetch" to do so as well.
Signed-off-by: Junio C Hamano <junkio@cox.net>
a fast-forward, teach "git fetch" to do so as well.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-fetch-script | patch | blob | history |
diff --git a/git-fetch-script b/git-fetch-script
index a70909e4ff15035d135eed061de8b4ea70ac5060..dc7f4d6e44e9a597a2ed778bc89a3e4693a7fa27 100755 (executable)
--- a/git-fetch-script
+++ b/git-fetch-script
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
append=
+force=
+while case "$#" in 0) break ;; esac
+do
+ case "$1" in
+ -a|--a|--ap|--app|--appe|--appen|--append)
+ append=t
+ shift
+ ;;
+ -f|--f|--fo|--for|--forc|--force)
+ force=t
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
case "$#" in
0)
test -f "$GIT_DIR/branches/origin" ||
test -f "$GIT_DIR/remotes/origin" ||
die "Where do you want to fetch from?"
set origin ;;
-*)
- case "$1" in
- -a|--a|--ap|--app|--appe|--appen|--append)
- append=t
- shift ;;
- esac
esac
+
remote_nick="$1"
remote=$(get_remote_url "$@")
refs=
refs/tags/*)
# Tags need not be pointing at commits so there
# is no way to guarantee "fast-forward" anyway.
+ if test -f "$GIT_DIR/$1"
+ then
+ echo >&2 "* $1: updating with $4"
+ echo >&2 " from $3."
+ else
+ echo >&2 "* $1: storing $4"
+ echo >&2 " from $3."
+ fi
echo "$2" >"$GIT_DIR/$1" ;;
+
refs/heads/*)
# NEEDSWORK: use the same cmpxchg protocol here.
echo "$2" >"$GIT_DIR/$1.lock"
false
;;
esac || {
- mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1.remote"
echo >&2 "* $1: does not fast forward to $4"
- echo >&2 " from $3; leaving it in '$1.remote'"
+ case "$force" in
+ t)
+ echo >&2 " from $3; forcing update."
+ ;;
+ *)
+ mv "$GIT_DIR/$1.lock" "$GIT_DIR/$1.remote"
+ echo >&2 " from $3; leaving it in '$1.remote'"
+ ;;
+ esac
}
else
echo >&2 "* $1: storing $4"