Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-23 08:28:33 +0400
committerJunio C Hamano <junkio@cox.net>2005-08-25 03:50:52 +0400
commitae2da40690a3f3f101de5780a7799781b09e2e05 (patch)
tree5624b582634f64ab16f3853bbd11f5e59f662084
parent6687f8fea22e1e43ab163a8fe180155a0a0a956a (diff)
[PATCH] "git fetch --force".
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>
-rwxr-xr-xgit-fetch-script45
1 files changed, 37 insertions, 8 deletions
diff --git a/git-fetch-script b/git-fetch-script
index a70909e4ff..dc7f4d6e44 100755
--- a/git-fetch-script
+++ b/git-fetch-script
@@ -6,19 +6,32 @@ _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"
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=
@@ -60,7 +73,16 @@ fast_forward_local () {
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"
@@ -81,9 +103,16 @@ fast_forward_local () {
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"