[PATCH] Allow "+remote:local" refspec to cause --force when fetching.
With this we could say: Pull: master:ko-master +pu:ko-pu to mean "fast forward ko-master with master, overwrite ko-pu with pu", and the latter one does not require the remote "pu" to be descendant of local "ko-pu". Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -104,8 +104,8 @@ fast_forward_local () {
|
|||||||
;;
|
;;
|
||||||
esac || {
|
esac || {
|
||||||
echo >&2 "* $1: does not fast forward to $4"
|
echo >&2 "* $1: does not fast forward to $4"
|
||||||
case "$force" in
|
case "$force,$single_force" in
|
||||||
t)
|
t,* | *,t)
|
||||||
echo >&2 " from $3; forcing update."
|
echo >&2 " from $3; forcing update."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -130,6 +130,13 @@ do
|
|||||||
|
|
||||||
# These are relative path from $GIT_DIR, typically starting at refs/
|
# These are relative path from $GIT_DIR, typically starting at refs/
|
||||||
# but may be HEAD
|
# but may be HEAD
|
||||||
|
if expr "$ref" : '\+' >/dev/null
|
||||||
|
then
|
||||||
|
single_force=t
|
||||||
|
ref=$(expr "$ref" : '\+\(.*\)')
|
||||||
|
else
|
||||||
|
single_force=
|
||||||
|
fi
|
||||||
remote_name=$(expr "$ref" : '\([^:]*\):')
|
remote_name=$(expr "$ref" : '\([^:]*\):')
|
||||||
local_name=$(expr "$ref" : '[^:]*:\(.*\)')
|
local_name=$(expr "$ref" : '[^:]*:\(.*\)')
|
||||||
|
|
||||||
@ -175,9 +182,14 @@ http://* | https://* | rsync://* )
|
|||||||
while read sha1 remote_name
|
while read sha1 remote_name
|
||||||
do
|
do
|
||||||
found=
|
found=
|
||||||
|
single_force=
|
||||||
for ref in $refs
|
for ref in $refs
|
||||||
do
|
do
|
||||||
case "$ref" in
|
case "$ref" in
|
||||||
|
+$remote_name:*)
|
||||||
|
single_force=t
|
||||||
|
found="$ref"
|
||||||
|
break ;;
|
||||||
$remote_name:*)
|
$remote_name:*)
|
||||||
found="$ref"
|
found="$ref"
|
||||||
break ;;
|
break ;;
|
||||||
@ -185,7 +197,7 @@ http://* | https://* | rsync://* )
|
|||||||
done
|
done
|
||||||
|
|
||||||
local_name=$(expr "$found" : '[^:]*:\(.*\)')
|
local_name=$(expr "$found" : '[^:]*:\(.*\)')
|
||||||
append_fetch_head "$sha1" "$remote" "$remote_name" "$remote_nick" "$local_name"
|
append_fetch_head "$sha1" "$remote" "$remote_name" "$remote_nick" "$local_name"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
get_data_source () {
|
get_data_source () {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*/*)
|
*/*)
|
||||||
# Not so fast. This could be the partial URL shorthand...
|
# Not so fast. This could be the partial URL shorthand...
|
||||||
token=$(expr "$1" : '\([^/]*\)/')
|
token=$(expr "$1" : '\([^/]*\)/')
|
||||||
remainder=$(expr "$1" : '[^/]*/\(.*\)')
|
remainder=$(expr "$1" : '[^/]*/\(.*\)')
|
||||||
if test -f "$GIT_DIR/branches/$token"
|
if test -f "$GIT_DIR/branches/$token"
|
||||||
@ -69,6 +69,13 @@ get_remote_default_refs_for_push () {
|
|||||||
canon_refs_list_for_fetch () {
|
canon_refs_list_for_fetch () {
|
||||||
for ref
|
for ref
|
||||||
do
|
do
|
||||||
|
force=
|
||||||
|
case "$ref" in
|
||||||
|
+*)
|
||||||
|
ref=$(expr "$ref" : '\+\(.*\)')
|
||||||
|
force=+
|
||||||
|
;;
|
||||||
|
esac
|
||||||
expr "$ref" : '.*:' >/dev/null || ref="${ref}:"
|
expr "$ref" : '.*:' >/dev/null || ref="${ref}:"
|
||||||
remote=$(expr "$ref" : '\([^:]*\):')
|
remote=$(expr "$ref" : '\([^:]*\):')
|
||||||
local=$(expr "$ref" : '[^:]*:\(.*\)')
|
local=$(expr "$ref" : '[^:]*:\(.*\)')
|
||||||
@ -80,7 +87,7 @@ canon_refs_list_for_fetch () {
|
|||||||
'') local= ;;
|
'') local= ;;
|
||||||
*) local="refs/heads/$local" ;;
|
*) local="refs/heads/$local" ;;
|
||||||
esac
|
esac
|
||||||
echo "${remote}:${local}"
|
echo "${force}${remote}:${local}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,12 +139,12 @@ get_remote_refs_for_fetch () {
|
|||||||
else
|
else
|
||||||
case "$ref" in
|
case "$ref" in
|
||||||
tag)
|
tag)
|
||||||
tag_just_seen=yes
|
tag_just_seen=yes
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
canon_refs_list_for_fetch "$ref"
|
canon_refs_list_for_fetch "$ref"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user