2005-05-22 18:03:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-12-13 22:30:31 +00:00
|
|
|
|
|
|
|
USAGE='<fetch-options> <repository> <refspec>...'
|
2006-12-14 08:36:23 +00:00
|
|
|
SUBDIRECTORY_OK=Yes
|
2005-11-24 08:12:11 +00:00
|
|
|
. git-sh-setup
|
2006-12-28 07:34:48 +00:00
|
|
|
set_reflog_action "fetch $*"
|
2007-01-12 20:49:05 +00:00
|
|
|
cd_to_toplevel ;# probably unnecessary...
|
2006-12-28 07:34:48 +00:00
|
|
|
|
2005-09-08 00:26:23 +00:00
|
|
|
. git-parse-remote
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
_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"
|
|
|
|
|
2005-10-11 06:22:02 +00:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
IFS="$LF"
|
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
no_tags=
|
2005-09-29 21:35:15 +00:00
|
|
|
tags=
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
append=
|
2005-08-23 04:28:33 +00:00
|
|
|
force=
|
2005-11-18 16:31:55 +00:00
|
|
|
verbose=
|
2005-08-26 01:15:32 +00:00
|
|
|
update_head_ok=
|
2006-01-20 18:05:24 +00:00
|
|
|
exec=
|
2006-11-01 22:06:22 +00:00
|
|
|
keep=
|
2006-10-30 19:09:53 +00:00
|
|
|
shallow_depth=
|
2007-02-20 02:01:44 +00:00
|
|
|
no_progress=
|
|
|
|
test -t 1 || no_progress=--no-progress
|
2007-02-25 21:13:17 +00:00
|
|
|
quiet=
|
2007-09-23 20:42:08 +00:00
|
|
|
while test $# != 0
|
2005-08-23 04:28:33 +00:00
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-a|--a|--ap|--app|--appe|--appen|--append)
|
|
|
|
append=t
|
|
|
|
;;
|
2006-01-27 02:11:06 +00:00
|
|
|
--upl|--uplo|--uploa|--upload|--upload-|--upload-p|\
|
|
|
|
--upload-pa|--upload-pac|--upload-pack)
|
2006-01-20 18:05:24 +00:00
|
|
|
shift
|
2007-01-23 08:51:53 +00:00
|
|
|
exec="--upload-pack=$1"
|
|
|
|
;;
|
|
|
|
--upl=*|--uplo=*|--uploa=*|--upload=*|\
|
|
|
|
--upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
|
2007-01-30 18:11:49 +00:00
|
|
|
exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
|
2007-01-23 08:51:53 +00:00
|
|
|
shift
|
2006-01-20 18:05:24 +00:00
|
|
|
;;
|
2005-08-23 04:28:33 +00:00
|
|
|
-f|--f|--fo|--for|--forc|--force)
|
|
|
|
force=t
|
2005-08-26 01:15:32 +00:00
|
|
|
;;
|
2005-09-29 21:35:15 +00:00
|
|
|
-t|--t|--ta|--tag|--tags)
|
|
|
|
tags=t
|
|
|
|
;;
|
2006-01-07 08:48:04 +00:00
|
|
|
-n|--n|--no|--no-|--no-t|--no-ta|--no-tag|--no-tags)
|
|
|
|
no_tags=t
|
|
|
|
;;
|
2005-08-26 01:15:32 +00:00
|
|
|
-u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
|
|
|
|
--update-he|--update-hea|--update-head|--update-head-|\
|
|
|
|
--update-head-o|--update-head-ok)
|
|
|
|
update_head_ok=t
|
2005-08-23 04:28:33 +00:00
|
|
|
;;
|
2007-02-25 21:13:17 +00:00
|
|
|
-q|--q|--qu|--qui|--quie|--quiet)
|
|
|
|
quiet=--quiet
|
|
|
|
;;
|
2005-11-18 16:31:55 +00:00
|
|
|
-v|--verbose)
|
2007-05-23 21:31:13 +00:00
|
|
|
verbose="$verbose"Yes
|
2005-11-18 16:31:55 +00:00
|
|
|
;;
|
2006-01-11 01:50:19 +00:00
|
|
|
-k|--k|--ke|--kee|--keep)
|
2006-11-01 22:06:25 +00:00
|
|
|
keep='-k -k'
|
2006-01-11 01:50:19 +00:00
|
|
|
;;
|
2006-10-30 19:09:53 +00:00
|
|
|
--depth=*)
|
2014-04-16 17:29:50 +00:00
|
|
|
shallow_depth="--depth=$(expr "z$1" : 'z-[^=]*=\(.*\)')"
|
2006-10-30 19:09:53 +00:00
|
|
|
;;
|
|
|
|
--depth)
|
|
|
|
shift
|
|
|
|
shallow_depth="--depth=$1"
|
|
|
|
;;
|
2005-12-13 22:30:31 +00:00
|
|
|
-*)
|
|
|
|
usage
|
|
|
|
;;
|
2005-08-23 04:28:33 +00:00
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
2005-08-26 01:15:32 +00:00
|
|
|
shift
|
2005-08-23 04:28:33 +00:00
|
|
|
done
|
|
|
|
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
case "$#" in
|
|
|
|
0)
|
2006-09-23 10:05:43 +00:00
|
|
|
origin=$(get_default_remote)
|
|
|
|
test -n "$(get_remote_url ${origin})" ||
|
|
|
|
die "Where do you want to fetch from today?"
|
|
|
|
set x $origin ; shift ;;
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
esac
|
2005-08-23 04:28:33 +00:00
|
|
|
|
2007-01-25 04:45:39 +00:00
|
|
|
if test -z "$exec"
|
|
|
|
then
|
|
|
|
# No command line override and we have configuration for the remote.
|
|
|
|
exec="--upload-pack=$(get_uploadpack $1)"
|
|
|
|
fi
|
|
|
|
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
remote_nick="$1"
|
|
|
|
remote=$(get_remote_url "$@")
|
|
|
|
refs=
|
|
|
|
rref=
|
|
|
|
rsync_slurped_objects=
|
|
|
|
|
|
|
|
if test "" = "$append"
|
|
|
|
then
|
2005-10-05 16:58:10 +00:00
|
|
|
: >"$GIT_DIR/FETCH_HEAD"
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
fi
|
|
|
|
|
2006-11-23 05:57:14 +00:00
|
|
|
# Global that is reused later
|
2007-01-23 08:51:53 +00:00
|
|
|
ls_remote_result=$(git ls-remote $exec "$remote") ||
|
2006-12-18 20:16:58 +00:00
|
|
|
die "Cannot get the repository state from $remote"
|
2006-11-23 05:57:14 +00:00
|
|
|
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
append_fetch_head () {
|
2007-01-16 08:23:24 +00:00
|
|
|
flags=
|
2007-03-18 23:16:23 +00:00
|
|
|
test -n "$verbose" && flags="$flags$LF-v"
|
|
|
|
test -n "$force$single_force" && flags="$flags$LF-f"
|
2007-01-16 08:23:24 +00:00
|
|
|
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
|
2007-07-03 05:52:14 +00:00
|
|
|
git fetch--tool $flags append-fetch-head "$@"
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 10:17:52 +00:00
|
|
|
# updating the current HEAD with git-fetch in a bare
|
|
|
|
# repository is always fine.
|
|
|
|
if test -z "$update_head_ok" && test $(is_bare_repository) = false
|
|
|
|
then
|
2007-07-03 05:52:14 +00:00
|
|
|
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
2007-01-07 10:17:52 +00:00
|
|
|
fi
|
2005-08-26 01:15:32 +00:00
|
|
|
|
2010-04-19 23:31:25 +00:00
|
|
|
# Allow --tags/--notags from remote.$1.tagopt
|
2007-02-15 09:46:27 +00:00
|
|
|
case "$tags$no_tags" in
|
|
|
|
'')
|
2007-07-03 05:52:14 +00:00
|
|
|
case "$(git config --get "remote.$1.tagopt")" in
|
2010-04-19 23:31:25 +00:00
|
|
|
--tags)
|
|
|
|
tags=t ;;
|
2007-02-15 09:46:27 +00:00
|
|
|
--no-tags)
|
|
|
|
no_tags=t ;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
2005-09-29 21:35:15 +00:00
|
|
|
# If --tags (and later --heads or --all) is specified, then we are
|
|
|
|
# not talking about defaults stored in Pull: line of remotes or
|
|
|
|
# branches file, and just fetch those and refspecs explicitly given.
|
|
|
|
# Otherwise we do what we always did.
|
|
|
|
|
|
|
|
reflist=$(get_remote_refs_for_fetch "$@")
|
|
|
|
if test "$tags"
|
|
|
|
then
|
2015-12-22 14:10:24 +00:00
|
|
|
taglist=$(IFS=' ' &&
|
2006-11-23 05:57:14 +00:00
|
|
|
echo "$ls_remote_result" |
|
2007-07-03 05:52:14 +00:00
|
|
|
git show-ref --exclude-existing=refs/tags/ |
|
2006-01-06 03:42:12 +00:00
|
|
|
while read sha1 name
|
|
|
|
do
|
2007-02-11 21:41:23 +00:00
|
|
|
echo ".${name}:${name}"
|
2015-12-22 14:10:24 +00:00
|
|
|
done) || exit
|
2005-09-29 21:35:15 +00:00
|
|
|
if test "$#" -gt 1
|
|
|
|
then
|
|
|
|
# remote URL plus explicit refspecs; we need to merge them.
|
2005-10-11 06:22:02 +00:00
|
|
|
reflist="$reflist$LF$taglist"
|
2005-09-29 21:35:15 +00:00
|
|
|
else
|
|
|
|
# No explicit refspecs; fetch tags only.
|
|
|
|
reflist=$taglist
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
fetch_all_at_once () {
|
2007-01-16 10:31:36 +00:00
|
|
|
|
2007-07-03 05:52:14 +00:00
|
|
|
eval=$(echo "$1" | git fetch--tool parse-reflist "-")
|
2007-01-16 10:31:36 +00:00
|
|
|
eval "$eval"
|
2007-01-16 06:56:34 +00:00
|
|
|
|
|
|
|
( : subshell because we muck with IFS
|
|
|
|
IFS=" $LF"
|
|
|
|
(
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
if test "$remote" = . ; then
|
2007-07-03 05:52:14 +00:00
|
|
|
git show-ref $rref || echo failed "$remote"
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
elif test -f "$remote" ; then
|
2007-03-14 08:40:19 +00:00
|
|
|
test -n "$shallow_depth" &&
|
|
|
|
die "shallow clone with bundle is not supported"
|
2007-07-03 05:52:14 +00:00
|
|
|
git bundle unbundle "$remote" $rref ||
|
2007-03-14 08:40:19 +00:00
|
|
|
echo failed "$remote"
|
|
|
|
else
|
2007-04-05 10:22:55 +00:00
|
|
|
if test -d "$remote" &&
|
|
|
|
|
|
|
|
# The remote might be our alternate. With
|
|
|
|
# this optimization we will bypass fetch-pack
|
|
|
|
# altogether, which means we cannot be doing
|
|
|
|
# the shallow stuff at all.
|
|
|
|
test ! -f "$GIT_DIR/shallow" &&
|
|
|
|
test -z "$shallow_depth" &&
|
|
|
|
|
|
|
|
# See if all of what we are going to fetch are
|
|
|
|
# connected to our repository's tips, in which
|
|
|
|
# case we do not have to do any fetch.
|
2007-04-23 19:26:26 +00:00
|
|
|
theirs=$(echo "$ls_remote_result" | \
|
2007-07-03 05:52:14 +00:00
|
|
|
git fetch--tool -s pick-rref "$rref" "-") &&
|
2007-04-05 10:22:55 +00:00
|
|
|
|
|
|
|
# This will barf when $theirs reach an object that
|
|
|
|
# we do not have in our repository. Otherwise,
|
|
|
|
# we already have everything the fetch would bring in.
|
2007-07-03 05:52:14 +00:00
|
|
|
git rev-list --objects $theirs --not --all \
|
2007-04-05 10:22:55 +00:00
|
|
|
>/dev/null 2>/dev/null
|
|
|
|
then
|
2007-04-23 19:26:26 +00:00
|
|
|
echo "$ls_remote_result" | \
|
2007-07-03 05:52:14 +00:00
|
|
|
git fetch--tool pick-rref "$rref" "-"
|
2007-04-05 10:22:55 +00:00
|
|
|
else
|
2007-05-23 21:31:13 +00:00
|
|
|
flags=
|
|
|
|
case $verbose in
|
|
|
|
YesYes*)
|
|
|
|
flags="-v"
|
|
|
|
;;
|
|
|
|
esac
|
2007-04-05 10:22:55 +00:00
|
|
|
git-fetch-pack --thin $exec $keep $shallow_depth \
|
2007-05-23 21:31:13 +00:00
|
|
|
$quiet $no_progress $flags "$remote" $rref ||
|
2007-04-05 10:22:55 +00:00
|
|
|
echo failed "$remote"
|
|
|
|
fi
|
2007-03-14 08:40:19 +00:00
|
|
|
fi
|
2007-01-16 06:56:34 +00:00
|
|
|
) |
|
|
|
|
(
|
2007-01-16 09:53:29 +00:00
|
|
|
flags=
|
|
|
|
test -n "$verbose" && flags="$flags -v"
|
|
|
|
test -n "$force" && flags="$flags -f"
|
|
|
|
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
|
2007-07-03 05:52:14 +00:00
|
|
|
git fetch--tool $flags native-store \
|
2007-02-24 12:35:31 +00:00
|
|
|
"$remote" "$remote_nick" "$refs"
|
2007-01-16 06:56:34 +00:00
|
|
|
)
|
|
|
|
) || exit
|
|
|
|
|
|
|
|
}
|
|
|
|
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
fetch_per_ref () {
|
2006-01-07 08:48:04 +00:00
|
|
|
reflist="$1"
|
|
|
|
refs=
|
2006-09-29 18:05:40 +00:00
|
|
|
rref=
|
2005-07-16 07:16:24 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
for ref in $reflist
|
|
|
|
do
|
|
|
|
refs="$refs$LF$ref"
|
2005-07-16 07:16:24 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
# These are relative path from $GIT_DIR, typically starting at refs/
|
|
|
|
# but may be HEAD
|
2006-04-13 22:01:24 +00:00
|
|
|
if expr "z$ref" : 'z\.' >/dev/null
|
2006-01-07 08:48:04 +00:00
|
|
|
then
|
|
|
|
not_for_merge=t
|
2006-04-13 22:01:24 +00:00
|
|
|
ref=$(expr "z$ref" : 'z\.\(.*\)')
|
2006-01-07 08:48:04 +00:00
|
|
|
else
|
|
|
|
not_for_merge=
|
|
|
|
fi
|
2006-04-14 02:05:38 +00:00
|
|
|
if expr "z$ref" : 'z+' >/dev/null
|
2006-01-07 08:48:04 +00:00
|
|
|
then
|
|
|
|
single_force=t
|
2006-04-14 02:05:38 +00:00
|
|
|
ref=$(expr "z$ref" : 'z+\(.*\)')
|
2006-01-07 08:48:04 +00:00
|
|
|
else
|
|
|
|
single_force=
|
|
|
|
fi
|
2006-04-13 22:01:24 +00:00
|
|
|
remote_name=$(expr "z$ref" : 'z\([^:]*\):')
|
|
|
|
local_name=$(expr "z$ref" : 'z[^:]*:\(.*\)')
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
rref="$rref$LF$remote_name"
|
2005-09-17 18:56:41 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
# There are transports that can fetch only one head at a time...
|
|
|
|
case "$remote" in
|
2006-09-14 02:24:04 +00:00
|
|
|
http://* | https://* | ftp://*)
|
2006-10-30 19:09:53 +00:00
|
|
|
test -n "$shallow_depth" &&
|
|
|
|
die "shallow clone with http not supported"
|
2014-04-16 17:29:50 +00:00
|
|
|
proto=$(expr "$remote" : '\([^:]*\):')
|
2006-01-07 08:48:04 +00:00
|
|
|
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
|
|
|
|
curl_extra_args="-k"
|
|
|
|
fi
|
2006-09-29 00:10:44 +00:00
|
|
|
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
|
2014-04-16 17:29:50 +00:00
|
|
|
"$(git config --bool http.noEPSV)" = true ]; then
|
2006-09-29 00:10:44 +00:00
|
|
|
noepsv_opt="--disable-epsv"
|
|
|
|
fi
|
2006-11-23 06:24:09 +00:00
|
|
|
|
|
|
|
# Find $remote_name from ls-remote output.
|
2007-04-23 19:26:26 +00:00
|
|
|
head=$(echo "$ls_remote_result" | \
|
2007-07-03 05:52:14 +00:00
|
|
|
git fetch--tool -s pick-rref "$remote_name" "-")
|
2006-04-13 22:01:24 +00:00
|
|
|
expr "z$head" : "z$_x40\$" >/dev/null ||
|
2006-11-23 06:24:09 +00:00
|
|
|
die "No such ref $remote_name at $remote"
|
2006-10-25 10:03:06 +00:00
|
|
|
echo >&2 "Fetching $remote_name from $remote using $proto"
|
2007-02-25 21:13:17 +00:00
|
|
|
case "$quiet" in '') v=-v ;; *) v= ;; esac
|
2007-04-09 06:27:22 +00:00
|
|
|
git-http-fetch $v -a "$head" "$remote" || exit
|
2006-01-07 08:48:04 +00:00
|
|
|
;;
|
|
|
|
rsync://*)
|
2006-10-30 19:09:53 +00:00
|
|
|
test -n "$shallow_depth" &&
|
|
|
|
die "shallow clone with rsync not supported"
|
2006-01-07 08:48:04 +00:00
|
|
|
TMP_HEAD="$GIT_DIR/TMP_HEAD"
|
|
|
|
rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
|
2007-07-03 05:52:14 +00:00
|
|
|
head=$(git rev-parse --verify TMP_HEAD)
|
2006-01-07 08:48:04 +00:00
|
|
|
rm -f "$TMP_HEAD"
|
2007-02-25 21:13:17 +00:00
|
|
|
case "$quiet" in '') v=-v ;; *) v= ;; esac
|
2006-01-07 08:48:04 +00:00
|
|
|
test "$rsync_slurped_objects" || {
|
2007-02-25 21:13:17 +00:00
|
|
|
rsync -a $v --ignore-existing --exclude info \
|
2006-01-07 08:48:04 +00:00
|
|
|
"$remote/objects/" "$GIT_OBJECT_DIRECTORY/" || exit
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
# Look at objects/info/alternates for rsync -- http will
|
|
|
|
# support it natively and git native ones will do it on
|
|
|
|
# the remote end. Not having that file is not a crime.
|
|
|
|
rsync -q "$remote/objects/info/alternates" \
|
|
|
|
"$GIT_DIR/TMP_ALT" 2>/dev/null ||
|
|
|
|
rm -f "$GIT_DIR/TMP_ALT"
|
|
|
|
if test -f "$GIT_DIR/TMP_ALT"
|
|
|
|
then
|
|
|
|
resolve_alternates "$remote" <"$GIT_DIR/TMP_ALT" |
|
|
|
|
while read alt
|
|
|
|
do
|
|
|
|
case "$alt" in 'bad alternate: '*) die "$alt";; esac
|
|
|
|
echo >&2 "Getting alternate: $alt"
|
|
|
|
rsync -av --ignore-existing --exclude info \
|
|
|
|
"$alt" "$GIT_OBJECT_DIRECTORY/" || exit
|
|
|
|
done
|
|
|
|
rm -f "$GIT_DIR/TMP_ALT"
|
|
|
|
fi
|
|
|
|
rsync_slurped_objects=t
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
2005-07-16 07:16:24 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
append_fetch_head "$head" "$remote" \
|
2006-11-25 09:04:28 +00:00
|
|
|
"$remote_name" "$remote_nick" "$local_name" "$not_for_merge" || exit
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
|
2006-01-07 08:48:04 +00:00
|
|
|
done
|
|
|
|
|
2007-01-16 06:56:34 +00:00
|
|
|
}
|
2006-01-07 08:48:04 +00:00
|
|
|
|
2007-01-16 06:56:34 +00:00
|
|
|
fetch_main () {
|
|
|
|
case "$remote" in
|
|
|
|
http://* | https://* | ftp://* | rsync://* )
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
fetch_per_ref "$@"
|
2007-01-16 06:56:34 +00:00
|
|
|
;;
|
|
|
|
*)
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 08:23:20 +00:00
|
|
|
fetch_all_at_once "$@"
|
2007-01-16 06:56:34 +00:00
|
|
|
;;
|
|
|
|
esac
|
2006-01-07 08:48:04 +00:00
|
|
|
}
|
|
|
|
|
2006-11-25 09:04:28 +00:00
|
|
|
fetch_main "$reflist" || exit
|
2006-01-07 08:48:04 +00:00
|
|
|
|
|
|
|
# automated tag following
|
|
|
|
case "$no_tags$tags" in
|
|
|
|
'')
|
2006-02-22 21:10:37 +00:00
|
|
|
case "$reflist" in
|
|
|
|
*:refs/*)
|
|
|
|
# effective only when we are following remote branch
|
|
|
|
# using local tracking branch.
|
2006-12-18 01:57:19 +00:00
|
|
|
taglist=$(IFS=' ' &&
|
2006-11-23 05:57:14 +00:00
|
|
|
echo "$ls_remote_result" |
|
2007-07-03 05:52:14 +00:00
|
|
|
git show-ref --exclude-existing=refs/tags/ |
|
2006-02-22 21:10:37 +00:00
|
|
|
while read sha1 name
|
|
|
|
do
|
2007-07-03 05:52:14 +00:00
|
|
|
git cat-file -t "$sha1" >/dev/null 2>&1 || continue
|
2006-02-22 21:10:37 +00:00
|
|
|
echo >&2 "Auto-following $name"
|
|
|
|
echo ".${name}:${name}"
|
|
|
|
done)
|
|
|
|
esac
|
2006-01-07 08:48:04 +00:00
|
|
|
case "$taglist" in
|
|
|
|
'') ;;
|
|
|
|
?*)
|
2006-11-24 14:59:12 +00:00
|
|
|
# do not deepen a shallow tree when following tags
|
|
|
|
shallow_depth=
|
2006-11-25 09:04:28 +00:00
|
|
|
fetch_main "$taglist" || exit ;;
|
2006-01-07 08:48:04 +00:00
|
|
|
esac
|
[PATCH] Multi-head fetch.
Traditionally, fetch takes these forms:
$ git fetch <remote>
$ git fetch <remote> <head>
$ git fetch <remote> tag <tag>
This patch updates it to take
$ git fetch <remote> <refspec>...
where:
- A <refspec> of form "<src>:<dst>" is to fetch the objects
needed for the remote ref that matches <src>, and if <dst>
is not empty, store it as a local <dst>.
- "tag" followed by <next> is just an old way of saying
"refs/tags/<next>:refs/tags/<next>"; this mimics the
current behaviour of the third form above and means "fetch
that tag and store it under the same name".
- A single token <refspec> without colon is a shorthand for
"<refspec>:" That is, "fetch that ref but do not store
anywhere".
- when there is no <refspec> specified
- if <remote> is the name of a file under $GIT_DIR/remotes/
(i.e. a new-style shorthand), then it is the same as giving
the <refspec>s listed on Pull: line in that file.
- if <remote> is the name of a file under $GIT_DIR/branches/
(i.e. an old-style shorthand, without trailing path), then it
is the same as giving a single <refspec>
"<remote-name>:refs/heads/<remote>" on the command line, where
<remote-name> is the remote branch name (defaults to HEAD, but
can be overridden by .git/branches/<remote> file having the
URL fragment notation). That is, "fetch that branch head and
store it in refs/heads/<remote>".
- otherwise, it is the same as giving a single <refspec>
that is "HEAD:".
The SHA1 object names of fetched refs are stored in FETCH_HEAD,
one name per line, with a comment to describe where it came from.
This is later used by "git resolve" and "git octopus".
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-20 09:54:34 +00:00
|
|
|
esac
|
2005-08-26 01:15:32 +00:00
|
|
|
|
|
|
|
# If the original head was empty (i.e. no "master" yet), or
|
|
|
|
# if we were told not to worry, we do not have to check.
|
2006-10-11 05:29:02 +00:00
|
|
|
case "$orig_head" in
|
|
|
|
'')
|
2005-08-26 01:15:32 +00:00
|
|
|
;;
|
2006-10-11 05:29:02 +00:00
|
|
|
?*)
|
2007-07-03 05:52:14 +00:00
|
|
|
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
2005-08-26 01:15:32 +00:00
|
|
|
if test "$curr_head" != "$orig_head"
|
|
|
|
then
|
2007-07-03 05:52:14 +00:00
|
|
|
git update-ref \
|
2006-12-28 07:34:48 +00:00
|
|
|
-m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \
|
2006-07-11 03:38:35 +00:00
|
|
|
HEAD "$orig_head"
|
2005-08-26 01:15:32 +00:00
|
|
|
die "Cannot fetch into the current branch."
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|