From: Shawn Pearce <spearce@spearce.org>
To: git@vger.kernel.org
Subject: [PATCH] Added --mirror-all to git-fetch.
Date: Tue, 19 Sep 2006 19:28:51 -0400 [thread overview]
Message-ID: <20060919232851.GA12195@spearce.org> (raw)
The --mirror-all option to git-fetch can be used to obtain a copy of
every available remote ref into the current repository. This can be
a rather destructive update as the local repository will have its
HEAD ref overwritten, as well as any ref which it shares in common
with the remote repository. On the other hand it can be useful if
all you want to do is have this repository track another repository,
such as if you are providing Git repository hosting and mirroring
source repositories on other systems.
Currently local refs are not deleted even if they do not exist in the
remote repository. This may be taken as either a feature or a bug.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
pasky was asking about this on #git. So here it is.
Documentation/fetch-options.txt | 7 ++++++
git-fetch.sh | 43 ++++++++++++++++++++++++++++++++++++---
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 13f34d3..5ed9b4f 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -30,6 +30,13 @@
flag lets all tags and their associated objects be
downloaded.
+\--mirror-all::
+ All refs and tags on the remote side are downloaded to
+ the local side. This option is not intendend for user
+ repositories as it will overwrite every local ref,
+ including HEAD. You probably don't mean to use this
+ option.
+
-k, \--keep::
Keep downloaded pack.
diff --git a/git-fetch.sh b/git-fetch.sh
index 09a5d6c..d22c560 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -14,6 +14,7 @@ IFS="$LF"
rloga=fetch
no_tags=
tags=
+mirror_all=
append=
force=
verbose=
@@ -36,6 +37,9 @@ do
-f|--f|--fo|--for|--forc|--force)
force=t
;;
+ --mirror-all)
+ mirror_all=t
+ ;;
-t|--t|--ta|--tag|--tags)
tags=t
;;
@@ -216,12 +220,45 @@ case "$update_head_ok" in
;;
esac
-# If --tags (and later --heads or --all) is specified, then we are
-# not talking about defaults stored in Pull: line of remotes or
+# If --tags or -mirror_all (and later --heads) 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 "$mirror_all"
+then
+ tags=0; # tags are implied in all
+ reflist=`IFS=" " &&
+ (
+ git-ls-remote $upload_pack "$remote" ||
+ echo fail ouch
+ ) |
+ while read sha1 name
+ do
+ case "$sha1" in
+ fail)
+ exit 1
+ esac
+ case "$name" in
+ *^*) continue ;;
+ esac
+ if git-check-ref-format "$name"
+ then
+ echo ".+${name}:${name}"
+ else
+ if test "x$name" = xHEAD
+ then
+ echo ".+${name}:${name}"
+ else
+ echo >&2 "warning: malformed ref ${name} ignored"
+ fi
+ fi
+ done` || exit
+else
+ # Not using all; do what we always have done.
+ reflist=$(get_remote_refs_for_fetch "$@")
+fi
+
if test "$tags"
then
taglist=`IFS=" " &&
--
1.4.2.1.g832e
next reply other threads:[~2006-09-19 23:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-19 23:28 Shawn Pearce [this message]
2006-09-19 23:41 ` [PATCH] Added --mirror-all to git-fetch Petr Baudis
2006-09-20 16:06 ` Junio C Hamano
2006-09-20 16:14 ` Petr Baudis
2006-09-20 16:21 ` Shawn Pearce
2006-09-20 16:34 ` Junio C Hamano
2006-09-20 16:49 ` Shawn Pearce
2006-09-20 17:13 ` Junio C Hamano
2006-09-20 17:31 ` Shawn Pearce
2006-09-20 17:50 ` Junio C Hamano
2006-09-20 18:42 ` A Large Angry SCM
2006-09-20 21:36 ` Junio C Hamano
2006-09-20 21:42 ` Shawn Pearce
2006-09-20 18:29 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060919232851.GA12195@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).