clones over rsync broken?
I have not used rsync remotes in ages, but I was working on the patch for -4/-6 support and decided to test it against rsync.kernel.org
Cloning git.git takes forever and failed with:
$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git Checking connectivity... fatal: bad object ecdc6d8612df80e871ed34bb6c3b01b20b0b82e6 fatal: remote did not send all necessary objects
git.git is gigantic and I haven't looked closely, and that may not be a git bug...
However, trying to clone a smaller repo like pahole.git via rsync fails differently; this looks more like a git bug:
$ git clone rsync://rsync.kernel.org/pub/scm/devel/pahole/pahole.git fatal: Multiple updates for ref 'refs/remotes/origin/master' not allowed.
Using rsync(1) manually to grab pahole.git and inspecting the bare repo with yields no anomalies with "git fsck --full". $GIT_DIR/info/refs and $GIT_DIR/packed-refs both look fine, but perhaps it's confused by the existence of $GIT_DIR/refs/heads/master as a loose ref?
I tried dumping the refnames with the following patch and can see refs/remotes/origin/master is the only duplicated ref:
refs/files-backend.c +2 -0
@@ -3112,6 +3112,8 @@ static int ref_update_reject_duplicates(struct string_list *refnames,int i, n = refnames->nr;assert (err); +for (i =0 ; i < n; i++) +fprintf (stderr,"ref: %s\n" , refnames->items[i].string);for (i =1 ; i < n; i++)if (!strcmp (refnames->items[i -1 ].string, refnames->items[i].string)) {
And the output is:
ref: refs/remotes/origin/master
ref: refs/remotes/origin/master
ref: refs/tags/v1.0
ref: refs/tags/v1.1
ref: refs/tags/v1.10
ref: refs/tags/v1.2
ref: refs/tags/v1.3
ref: refs/tags/v1.4
ref: refs/tags/v1.5
ref: refs/tags/v1.6
ref: refs/tags/v1.7
ref: refs/tags/v1.8
ref: refs/tags/v1.8pre1
ref: refs/tags/v1.9
Not sure what exactly is going on, my git internal API knowledge is not great. Anyways, this is without any of my pending patches, and I was also able to reproduce a slightly different error with the Debian wheezy version (1.7.10.4) with:
fatal: Duplicated ref, and SHA1s don't match: refs/remotes/origin/master
Quoted 4 lines · Eric Wong
I have not used rsync remotes in ages, but I was working on the patch for -4/-6 support and decided to test it against rsync.kernel.org
Cloning git.git takes forever and failed with:
No kidding. There are over 95,000 unreachable loose objects consuming a gigabyte. The rsync transport blindly pulls all of the data over, with no idea that it doesn't need most of it.
Quoted 3 lines
$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git Checking connectivity... fatal: bad object ecdc6d8612df80e871ed34bb6c3b01b20b0b82e6 fatal: remote did not send all necessary objects
All those objects, and we still manage to miss one. :)
Interestingly, that object does not seem to exist at all on the remote! I think this is the same bug as the one below. Read on...
Quoted 11 lines
However, trying to clone a smaller repo like pahole.git via rsync fails differently; this looks more like a git bug:
$ git clone rsync://rsync.kernel.org/pub/scm/devel/pahole/pahole.git fatal: Multiple updates for ref 'refs/remotes/origin/master' not allowed.Using rsync(1) manually to grab pahole.git and inspecting the bare repo with yields no anomalies with "git fsck --full". $GIT_DIR/info/refs and $GIT_DIR/packed-refs both look fine, but perhaps it's confused by the existence of $GIT_DIR/refs/heads/master as a loose ref?
Yes, that's exactly what's going on. In get_refs_via_rsync, we blindly concatenate the list of loose refs and packed refs. But that's not right, and never has been. If the same ref exists in both stores, the loose ref takes precedence (that is how we can write new refs without having to rewrite the whole packed-refs file).
So we erroneously believe that refs/heads/master exists _twice_ on the remote, with two different values (and try to store it twice as refs/remotes/origin/master). But we should be accepting only the loose value.
This explains the git.git problem, too. There are two entries for refs/heads/pu: one loose and one in packed-refs. The latter is a stale, older value, and should never be looked at. But because pu gets rewound, its older values are not necessarily reachable and may even have been pruned!
So no, we do not have ecdc6d86, but neither does the upstream, and nothing is referencing it.
It looks like this has been broken since cd547b4 (fetch/push: readd rsync support, 2007-10-01). The fix is just to ignore packed-refs entries which duplicate loose ones. But given the length of time this has been broken with nobody complaining, I have to wonder if it is simply time to retire the rsync protocol. Even if was made to work, it is a horribly inefficient protocol.
-Peff
Quoted 6 lines · Jeff King
It looks like this has been broken since cd547b4 (fetch/push: readd rsync support, 2007-10-01). The fix is just to ignore packed-refs entries which duplicate loose ones. But given the length of time this has been broken with nobody complaining, I have to wonder if it is simply time to retire the rsync protocol. Even if was made to work, it is a horribly inefficient protocol.
I took a look at whether there would be an easy fix. There are three obvious ways to go about this:
1. Use the loose/packed reading code from refs/files-backend.c.
This would require some refactoring, as we currently assume we are either reading the refs for _this_ repository, or for a submodule. This is sort-of like reading a submodule, but I think there are a few rough edges.
Worse, though, is that the upcoming pluggable refs work will probably require that submodules and the main repo have the same ref backend. I'm a little dubious of that requirement in general, but certainly it would be a show-stopper here.
2. Create a "struct transport" for the tempdir holding the data we rsynced from the other side, and just treat it like a local repo. We already do something like this to handle object "alternates" repositories (and we run "upload-pack" on the other directory and parse it just like a real remote).
Unfortunately, what we bring over in get_refs_via_pack is not enough for this to work. It's _just_ the refs/ directories. We can use "git init" to make it more like a real repo, but ultimately we don't have any objects, so upload-pack will complain.
We could fix that by just rsyncing the objects down at this stage, too. It's not like git is careful enough to do a real "what do we need" walk like it does for dumb-http. But we would end up rsyncing even in cases where we didn't need _any_ objects, though that is probably a vast minority case.
3. Just teach the local ad-hoc loose and packed readers to do the proper deduplication. I started on this, but then realized that we really do implement a from-scratch packed-refs reader here. And it's missing some features, like parsing peeled tags.
So it really would want to call into the regular packed-refs parsing code, which requires more refactoring as in (1).
Of all of these, I think (2) is the closest to sane, because it lets upload-pack do the heavy-lifting, meaning we can understand whatever formats we rsync from the other side. But given that rsync is already naive about what objects it pulls (i.e., it gets everything), I have to really question whether there is any value in using git-over-rsync versus just:
rsync $src tmp/
git clone tmp my-repo ;# will hard-link, no extra space needed! rm -rf $tmp
I guess that doesn't handle subsequent fetches. But really...git-over-rsync is just an awful protocol. Nobody should be using it. Having looked at it in more detail, I'm more in favor than ever of removing it.
-Peff
PATCH 1/1 transport: drop support for git-over-rsync
Quoted 4 lines · Jeff King
I guess that doesn't handle subsequent fetches. But really...git-over-rsync is just an awful protocol. Nobody should be using it. Having looked at it in more detail, I'm more in favor than ever of removing it.
So here it is. I think this hasn't happened before simply because nobody bothered. I tried to dig up relevant discussions; see below.
Also, it's Friday night and I'm reading (and enjoying!) 10-year-old discussions on the git mailing list. That's got to be worth some kind of nerd cred.
-- >8 --
Subject: transport: drop support for git-over-rsync
The git-over-rsync protocol is inefficient and broken, and has been for a long time. It transfers way more objects than it needs (grabbing all of the remote's "objects/", regardless of which objects we need). It does its own ad-hoc parsing of loose and packed refs from the remote, but doesn't properly override packed refs with loose ones, leading to garbage results (e.g., expecting the other side to have an object pointed to by a stale packed-refs entry, or complaining that the other side has two copies of the refs[1]).
This latter breakage means that nobody could have successfully pulled from a moderately active repository since cd547b4 (fetch/push: readd rsync support, 2007-10-01).
We never made an official deprecation notice in the release notes for git's rsync protocol, but the tutorial has marked it as such since 914328a (Update tutorial., 2005-08-30). And on the mailing list as far back as Oct 2005, we can find Junio mentioning it as having "been deprecated for quite some time."[2,3,4]. So it was old news then; cogito had deprecated the transport in July of 2005[5] (though it did come back briefly when Linus broke git-http-pull!).
Of course some people professed their love of rsync through 2006, but Linus clarified in his usual gentle manner[6]:
Quoted 3 lines
Thanks! This is why I still use rsync, even though everybody and their mother tells me "Linus says rsync is deprecated."
No. You're using rsync because you're actively doing something _wrong_.
The deprecation sentiment was reinforced in 2008, with a mention that cloning via rsync is broken (with no fix)[7].
Even the commit porting rsync over to C from shell (cd547b4) lists it as deprecated! So between the 10 years of informal warnings, and the fact that it has been severely broken since 2007, it's probably safe to simply remove it without further deprecation warnings.
[1] http://article.gmane.org/gmane.comp.version-control.git/285101
[2] http://article.gmane.org/gmane.comp.version-control.git/10093
[3] http://article.gmane.org/gmane.comp.version-control.git/17734
[4] http://article.gmane.org/gmane.comp.version-control.git/18911
[5] http://article.gmane.org/gmane.comp.version-control.git/5617
[6] http://article.gmane.org/gmane.comp.version-control.git/19354
[7] http://article.gmane.org/gmane.comp.version-control.git/103635
--- Documentation/config.txt | 2 +- Documentation/git-bundle.txt | 2 +- Documentation/git-clone.txt | 3 +- Documentation/git-repack.txt | 2 +- Documentation/git.txt | 2 - Documentation/gitcore-tutorial.txt | 18 +- Documentation/gittutorial.txt | 2 +- Documentation/urls.txt | 6 +- t/t5510-fetch.sh | 36 ---- transport.c | 332 +------------------------------------ 10 files changed, 10 insertions(+), 395 deletions(-)
Documentation/config.txt +1 -1
@@ -2088,7 +2088,7 @@ pack.indexVersion:: larger than 2 GB. + If you have an old Git that does not understand the version 2 `*.idx` file, -cloning or fetching over a non native protocol (e.g. "http" and "rsync") +cloning or fetching over a non native protocol (e.g. "http") that will copy both `*.pack` file and corresponding `*.idx` file from the other side may give you a repository that cannot be accessed with your older version of Git. If the `*.pack` file is smaller than 2 GB, however,
Documentation/git-bundle.txt +1 -1
@@ -20,7 +20,7 @@ DESCRIPTION Some workflows require that one or more branches of development on one machine be replicated on another machine, but the two machines cannot be directly connected, and therefore the interactive Git protocols (git, -ssh, rsync, http) cannot be used. This command provides support for +ssh, http) cannot be used. This command provides support for 'git fetch' and 'git pull' to operate by packaging objects and references in an archive at the originating machine, then importing those into another repository using 'git fetch' and 'git pull'
Documentation/git-clone.txt +1 -2
@@ -115,8 +115,7 @@ objects from the source repository into a pack in the cloned repository. --quiet:: -q:: Operate quietly. Progress is not reported to the standard - error stream. This flag is also passed to the `rsync' - command when given. + error stream. --verbose:: -v::
Documentation/git-repack.txt +1 -1
@@ -133,7 +133,7 @@ By default, the command passes `--delta-base-offset` option to 'git pack-objects'; this typically results in slightly smaller packs, but the generated packs are incompatible with versions of Git older than version 1.4.4. If you need to share your repository with such ancient Git -versions, either directly or via the dumb http or rsync protocol, then you +versions, either directly or via the dumb http protocol, then you need to set the configuration variable `repack.UseDeltaBaseOffset` to "false" and repack. Access from old Git versions over the native protocol is unaffected by this option as the conversion is performed on the fly
Documentation/git.txt +0 -2
@@ -1123,8 +1123,6 @@ of clones and fetches. - `ssh`: git over ssh (including `host:path` syntax, `git+ssh://`, etc). - - `rsync`: git over rsync - - `http`: git over http, both "smart http" and "dumb http". Note that this does _not_ include `https`; if you want both, you should specify both as `http:https`.
Documentation/gitcore-tutorial.txt +2 -16
@@ -710,7 +710,7 @@ files). Again, this can all be simplified with ---------------- -$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git/ my-git +$ git clone git://git.kernel.org/pub/scm/git/git.git/ my-git $ cd my-git $ git checkout ----------------
@@ -1011,20 +1011,6 @@ $ git fetch <remote-repository> One of the following transports can be used to name the repository to download from: -Rsync:: - `rsync://remote.machine/path/to/repo.git/` -+ -Rsync transport is usable for both uploading and downloading, -but is completely unaware of what git does, and can produce -unexpected results when you download from the public repository -while the repository owner is uploading into it via `rsync` -transport. Most notably, it could update the files under -`refs/` which holds the object name of the topmost commits -before uploading the files in `objects/` -- the downloader would -obtain head commit object name while that object itself is still -not available in the repository. For this reason, it is -considered deprecated. - SSH:: `remote.machine:/path/to/repo.git/` or +
@@ -1430,7 +1416,7 @@ while, depending on how active your project is. When a repository is synchronized via `git push` and `git pull` objects packed in the source repository are usually stored -unpacked in the destination, unless rsync transport is used. +unpacked in the destination. While this allows you to use different packing strategies on both ends, it also means you may need to repack both repositories every once in a while.
Documentation/gittutorial.txt +1 -1
@@ -451,7 +451,7 @@ perform clones and pulls using the ssh protocol: bob$ git clone alice.org:/home/alice/project myrepo ------------------------------------- -Alternatively, Git has a native protocol, or can use rsync or http; +Alternatively, Git has a native protocol, or can use http; see linkgit:git-pull[1] for details. Git can also be used in a CVS-like mode, with a central repository
Documentation/urls.txt +2 -4
@@ -7,9 +7,8 @@ Depending on the transport protocol, some of this information may be absent. Git supports ssh, git, http, and https protocols (in addition, ftp, -and ftps can be used for fetching and rsync can be used for fetching -and pushing, but these are inefficient and deprecated; do not use -them). +and ftps can be used for fetching, but this is inefficient and +deprecated; do not use it). The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.
@@ -20,7 +19,6 @@ The following syntaxes may be used with them: - git://host.xz{startsb}:port{endsb}/path/to/repo.git/ - http{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ - ftp{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ -- rsync://host.xz/path/to/repo.git/ An alternative scp-like syntax may also be used with the ssh protocol:
t/t5510-fetch.sh +0 -36
@@ -314,42 +314,6 @@ test_expect_success 'bundle should be able to create a full history' ' ' -! rsync --help > /dev/null 2> /dev/null && -say 'Skipping rsync tests because rsync was not found' || { -test_expect_success 'fetch via rsync' ' - git pack-refs && - mkdir rsynced && - (cd rsynced && - git init --bare && - git fetch "rsync:../.git" master:refs/heads/master && - git gc --prune && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full) -' - -test_expect_success 'push via rsync' ' - mkdir rsynced2 && - (cd rsynced2 && - git init) && - (cd rsynced && - git push "rsync:../rsynced2/.git" master) && - (cd rsynced2 && - git gc --prune && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full) -' - -test_expect_success 'push via rsync' ' - mkdir rsynced3 && - (cd rsynced3 && - git init) && - git push --all "rsync:rsynced3/.git" && - (cd rsynced3 && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full) -' -} - test_expect_success 'fetch with a non-applying branch.<name>.merge' ' git config branch.master.remote yeti && git config branch.master.merge refs/heads/bigfoot &&
transport.c +1 -331
350 lines not on this page · raw message
Signature · 1 line
2.7.0.485.g87653c0
Re: [PATCH] transport: drop support for git-over-rsync
Quoted 5 lines · Jeff King
Even the commit porting rsync over to C from shell (cd547b4) lists it as deprecated! So between the 10 years of informal warnings, and the fact that it has been severely broken since 2007, it's probably safe to simply remove it without further deprecation warnings.
Obviously it would not be the end of the world to start with a warning("git-over-rsync is going away!") patch, or to mention it in the release notes and hold this patch back for a version or two. But after seeing the extent of the breakage, I can't believe anybody has used it for years. But I'm also open to erring on the conservative side.
Quoted 4 lines
--- Documentation/config.txt | 2 +- Documentation/git-bundle.txt | 2 +- Documentation/git-clone.txt | 3 +-
Quoted 8 lines
Documentation/git-repack.txt | 2 +- Documentation/git.txt | 2 - Documentation/gitcore-tutorial.txt | 18 +- Documentation/gittutorial.txt | 2 +- Documentation/urls.txt | 6 +- t/t5510-fetch.sh | 36 ---- transport.c | 332 +------------------------------------ 10 files changed, 10 insertions(+), 395 deletions(-)
I cleaned up all of the documentation references I could find, except
one: the git-svn manual notes that because SVN metadata is kept outside of refs, you should use rsync for cloning. I'm not sure what to recommend there. I don't eve nthink that "git clone rsync://" would copy that metadata. So perhaps it just meant "rsync the whole thing yourself" (in which case it is OK to leave it).
transport.c struct transport *transport_get(struct remote *remote, const char *url) · line 661
Quoted 10 lines
transport.c +1
-5@@ -984,11 +658,7 @@ struct transport *transport_get(struct remote *remote, const char *url)if (helper) {transport_helper_init (ret, helper); }else if (starts_with (url,"rsync:" )) { -transport_check_allowed ("rsync" ); - ret->get_refs_list = get_refs_via_rsync; - ret->fetch = fetch_objs_via_rsync; - ret->push = rsync_transport_push; - ret->smart_options =NULL ; +die ("git-over-rsync is no longer supported" );
I added this as a convenience to anybody who does try to use it (otherwise they get a more confusing "eh, what is rsync" message).
But if we drop this "if" entirely, then somebody can ship git-remote-rsync, if they really wanted to (you can use it either way as "rsync::whatever" but this blocks the fallback of "rsync:whatever").
-Peff
Re: [PATCH] transport: drop support for git-over-rsync
Quoted 6 lines · Jeff King
Quoted 5 lines · Jeff King
Even the commit porting rsync over to C from shell (cd547b4) lists it as deprecated! So between the 10 years of informal warnings, and the fact that it has been severely broken since 2007, it's probably safe to simply remove it without further deprecation warnings.
I suppose there's a chance some projects are so small they never trigger ref packing; especially if some people are serving .git out of a working directory... *shrug*
But yeah, plain rsync remains usable, of course.
Quoted 6 lines
I cleaned up all of the documentation references I could find, except
one: the git-svn manual notes that because SVN metadata is kept outside of refs, you should use rsync for cloning. I'm not sure what to recommend there. I don't eve nthink that "git clone rsync://" would copy that metadata. So perhaps it just meant "rsync the whole thing yourself" (in which case it is OK to leave it).
Yes, probably "rsync the whole thing yourself". And I should update that since "clone --mirror" supports remotes, nowadays. git-svn metadata is rebuildable anyways (unless somebody made the mistake of disabling it).