Introduce git-hive
RFC PATCH 1/1 Introduce git-hive
From: Casey Dahlin <[email protected]>
This isn't really what I'd normally call ready for public consumption, but since there's been some minimal list chatter on a similar subject I figured I'd put this out there early.
git-hive is a peer to peer service for exchanging branches. When started it runs a small daemon to publish your repository on a random (or specified) port. Two hive daemons connected to oneanother can exchange branch lists and introduce eachother to more hive daemons to widen the network.
Currently each hive daemon is associated with a project URI to identify what project is being hosted.
Commands introduced are:
git hive start - start the hive daemon and join a network git hive stop - stop the hive daemon
git hive show - list peers and branches
git hive fetch - fetch a branch
As I've said, there's some rough edges around this, so here's some things that I'm very shortly going to be adding:
* Mechanism to track when a peer was last heard about, and re-verify or flush old ones. Also don't forward information about a peer that hasn't been verified recently. This will make things a LOT more robust, and prevent the flaming clusterfuck that happens during netsplits right now (once done netsplits should be an almost uninteresting occurance).
* Commit lines in branch listings. Fairly obvious UI thing that for some reason I only just thought of.
* Improve tolerance of \0 in pkt_line strings as the spec says I should (and take advantage of it! the protocol could be much easier to parse if I used \0 as a separator).
* Right now git-hive links against code from fetch-pack that clearly reaks of abandonment, though not specifically deprecated. Its a conflict of my two concerns 1) make this change uninvasive until people have warmed up to the patch and 2) don't reimplement anything. I'm pretty sure there's a better way to grab fetch functionality.
* Either some more commands for pull/etc. or some way to integrate better with the normal versions of those commands (I thought of a uri helper but I'm not sure what sort of uri you'd use to refer to a hive location that would be clean for the user)
* Peer discovery. I'd like to use Avahi for this if there's no objections.
* Tests :)
--- .gitignore | 1 + Makefile | 5 + hive.c | 1825 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1831 insertions(+), 0 deletions(-) create mode 100644 hive.c
.gitignore +1 -0
@@ -5,6 +5,7 @@ /bin-wrappers/ /git /git-add +/git-hive /git-add--interactive /git-am /git-annotate
Makefile +5 -0
@@ -399,6 +399,7 @@ PROGRAM_OBJS += shell.o PROGRAM_OBJS += show-index.o PROGRAM_OBJS += upload-pack.o PROGRAM_OBJS += http-backend.o +PROGRAM_OBJS += hive.o PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
@@ -449,6 +450,7 @@ BINDIR_PROGRAMS_NEED_X += git-upload-pack BINDIR_PROGRAMS_NEED_X += git-receive-pack BINDIR_PROGRAMS_NEED_X += git-upload-archive BINDIR_PROGRAMS_NEED_X += git-shell +BINDIR_PROGRAMS_NEED_X += git-hive BINDIR_PROGRAMS_NO_X += git-cvsserver
@@ -1893,6 +1895,9 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) +git-hive$X: hive.o $(GITLIBS) builtin/fetch-pack.o + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY) $(QUIET_LNCP)$(RM) $@ && \ ln $< $@ 2>/dev/null || \
hive.c new file +1825 -0
1,825 lines not on this page · raw message
Signature · 1 line
1.7.2.1
Quoted 10 lines · On Mon, Aug 30, 2010 at 8:59 PM, <[email protected]> wrote:
From: Casey Dahlin <[email protected]>
This isn't really what I'd normally call ready for public consumption, but since there's been some minimal list chatter on a similar subject I figured I'd put this out there early.
git-hive is a peer to peer service for exchanging branches. When started it runs a small daemon to publish your repository on a random (or specified) port. Two hive daemons connected to oneanother can exchange branch lists and introduce eachother to more hive daemons to widen the network.
p.s. is there any location where, in diagrammatic form, the
protocol's described?
Quoted 7 lines · Luke Kenneth Casson Leighton
Quoted 6 lines · On Mon, Aug 30, 2010 at 8:59 PM, <[email protected]> wrote:
From: Casey Dahlin <[email protected]>
This isn't really what I'd normally call ready for public consumption, but since there's been some minimal list chatter on a similar subject I figured I'd put this out there early.
Quoted 7 lines
Quoted 4 lines
git-hive is a peer to peer service for exchanging branches. When started it runs a small daemon to publish your repository on a random (or specified) port. Two hive daemons connected to oneanother can exchange branch lists and introduce eachother to more hive daemons to widen the network.
p.s. is there any location where, in diagrammatic form, the protocol's described?
Also a short tutorial how to use it would be nice.
I take it I can put different repositories (say wine.git and git.git) in the hive. When I fetch git.git from the hive, it won't fetch wine.git?
Signature · 1 line
Duy
Quoted 14 lines · Nguyen Thai Ngoc Duy
Quoted 12 lines · Luke Kenneth Casson Leighton
Quoted 10 lines · On Mon, Aug 30, 2010 at 8:59 PM, <[email protected]> wrote:
From: Casey Dahlin <[email protected]>
This isn't really what I'd normally call ready for public consumption, but since there's been some minimal list chatter on a similar subject I figured I'd put this out there early.
git-hive is a peer to peer service for exchanging branches. When started it runs a small daemon to publish your repository on a random (or specified) port. Two hive daemons connected to oneanother can exchange branch lists and introduce eachother to more hive daemons to widen the network.
Quoted 8 lines
Quoted 2 lines
p.s. is there any location where, in diagrammatic form, the protocol's described?
Also a short tutorial how to use it would be nice.
I take it I can put different repositories (say wine.git and git.git) in the hive. When I fetch git.git from the hive, it won't fetch wine.git?
First step to using hive is to set the project uri for your repo (may change this to a different mechanism later).
casey@host_a$ git config --add hive.uri http://myproject.org
This is what prevents the scenario you describe; repos with the same project URI are assumed to be compatible. It can be given as a command line argument to 'git hive start', but this way is much more usable.
Next we start the service for our repo.
casey@host_a$ git hive start --listen-port 21121
Normally the listen port is selected randomly. We specify it here so that other hive users can explicitly connect to us and "bootstrap" themselves into the hive network.
Now to have someone join.
nguyen@host_b$ git config --add hive.uri http://myproject.org nguyen@host_b$ git hive start host_a.com:21121
So from host_b we specify host_a's address and listen port, and we join the network. From here on out anyone who also connects to host_a will get host_b's (randomly selected) listen port automatically and be able to connect to it as well.
So now our two peers can see each other.
casey@host_a$ git hive show --branches Nguyen Thai Ngoc Duy <[email protected]> master for_casey
--- nguyen@host_b$ git hive show --branches Casey Dahlin <[email protected]> master stable v2.1
And we can exchange them
casey@host_a$ git hive fetch nguyen for_casey casey@host_a$ git branch * master stable for_casey
Note that the two arguments in fetch are a regex which searches through user IDs and a branch name, which is why I can abbreviate to just "nguyen" in all lower case.
--CJD
Quoted 9 lines · Casey Dahlin
nguyen@host_b$ git config --add hive.uri http://myproject.org nguyen@host_b$ git hive start host_a.com:21121So from
host_bwe specify host_a's address and listen port, and we join the network. From here on out anyone who also connects tohost_awill get host_b's (randomly selected) listen port automatically and be able to connect to it as well.So now our two peers can see each other.
ok - this only works if the two peers can see each other's ip
addresses. i.e. if the two machines are either on a local subnet or if the two machines are directly on the public internet. ( or if you've forced people to set up a firewall rule and/or UPnP rule, but even then UPnP doesn't solve the entire problem - only one part of it)
... unless (and i haven't reviewed the code closely, i admit) you're
using the following protocol:
* make tcp connection
* send dedicated specific message "please tell me my public IP and port"
* far end does sockaddr lookup of the incoming socket
* far end returns IP and port as response to requestor
in this way, requestors can determine what the "apparent" IP address is as far as having been NAT'd through half a ton of ISP layers performing NAT, local routers performing NAT, laptops such as mine doing NAT sharing of a 3G connection over a netgear router and so on.
so it entirely depends on the scope / scale you're thinking of. if you are aiming hive at "local subnets", it's pretty much perfect, and, much as i hate to say it and you should not _remotely_ consider using it because of the vast and horrific dependencies, i can understand why you were considering avahi, because it is a good "local subnets" solution.
however for "global networking" - for putting hive out onto the public internet - there is one hell of a lot more involved, and all these "filesharing" applications have solved near as damnit every single one of the issues.
so, answering the question you were asking earlier: i believe that you really do need to consider taking the closest c-based bittorrent library/application apart, and use it as the basis for git-hive. if you don't, you will be here forever, reinventing everything that these fileshare-app-writers have spent nearly a decade perfecting.
l.
Quoted 18 lines · Luke Kenneth Casson Leighton
Quoted 9 lines · Casey Dahlin
nguyen@host_b$ git config --add hive.uri http://myproject.org nguyen@host_b$ git hive start host_a.com:21121So from
host_bwe specify host_a's address and listen port, and we join the network. From here on out anyone who also connects tohost_awill get host_b's (randomly selected) listen port automatically and be able to connect to it as well.So now our two peers can see each other.
ok - this only works if the two peers can see each other's ip
addresses. i.e. if the two machines are either on a local subnet or if the two machines are directly on the public internet. ( or if you've forced people to set up a firewall rule and/or UPnP rule, but even then UPnP doesn't solve the entire problem - only one part of it)
Quoted 8 lines
... unless (and i haven't reviewed the code closely, i admit) you're
using the following protocol:* make tcp connection
* send dedicated specific message "please tell me my public IP and port"
* far end does sockaddr lookup of the incoming socket
* far end returns IP and port as response to requestor
Its a bit more primitive right now (a bit broken even) but that's the eventual plan.
Piece you missed though is that the port on the connect end isn't the same as the listen port. Connecting back to it would do no good.
Quoted 5 lines
in this way, requestors can determine what the "apparent" IP address is as far as having been NAT'd through half a ton of ISP layers performing NAT, local routers performing NAT, laptops such as mine doing NAT sharing of a 3G connection over a netgear router and so on.
You can't get back through all those anyway unless they've all been set up to allow it. I don't know what magic you've seen torrent clients do, but the procedure for the ones I always used was:
1) Check to see if it can receive connections on the port it wants.
2) Bitch at user if it can't.
Bittorrent has the luxury of being able to proxy for the poor firewall-bound users since as long as there's one peer exposed to the internet you can have any two other peers connect to him and give him the data they want to exchange, to the benefit of all 3. Git won't work that way because not everyone in the swarm wants all chunks of data, so if you found a proxy node, you might have to make him carry data (possibly lots of data) that he has no personal interest in.
Quoted 6 lines
so, answering the question you were asking earlier: i believe that you really do need to consider taking the closest c-based bittorrent library/application apart, and use it as the basis for git-hive. if you don't, you will be here forever, reinventing everything that these fileshare-app-writers have spent nearly a decade perfecting.
The thing avahi was going to provide was bootstrapping. Bittorrent DHT handles this by having a list of known-good peers stashed away somewhere (bittorrent.org hosts one). Essentially a non-p2p solution to joining the p2p network. That's pretty much the only WAN solution. Local networks on the same subnet have the option of UDP multicast. Avahi can do that. I'd be willing to do it manually or with something else. But yes, for your WAN case its useless.
--CJD
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Kevin Ballard
What about using Bonjour (a.k.a. DNS-SD) on OSes that provide this functionality? A lot of us already have local networks that are designed to let Bonjour propagate across the entire network, but hasn't been tested on simple UDP multicast. And with Bonjour you can even get wide-area Bonjour domains, so for example I could set up git hive on my desktop at home, and then get at it via my MobileMe wide-area Bonjour domain from anywhere else in the world.
-Kevin Ballard
Avahi is Linux's Bonjour implementation ;)
--CJD
Quoted 9 lines · Casey Dahlin
Quoted 4 lines · Kevin Ballard
What about using Bonjour (a.k.a. DNS-SD) on OSes that provide this functionality? A lot of us already have local networks that are designed to let Bonjour propagate across the entire network, but hasn't been tested on simple UDP multicast. And with Bonjour you can even get wide-area Bonjour domains, so for example I could set up git hive on my desktop at home, and then get at it via my MobileMe wide-area Bonjour domain from anywhere else in the world.
-Kevin Ballard
Avahi is Linux's Bonjour implementation ;)
--CJD
Ah hah, now it makes sense. I guess I should have looked up Avahi before just assuming it was some other P2P doohickey. Now, if git-hive is running on OS X, will it still be using a bundled version of Avahi, or will it default to using the system-provided mDNSResponder daemon (e.g. OS X's Bonjour)?
-Kevin Ballard
Quoted 7 lines
Quoted 4 lines
Avahi is Linux's Bonjour implementation ;)
--CJD
Ah hah, now it makes sense. I guess I should have looked up Avahi before just assuming it was some other P2P doohickey. Now, if git-hive is running on OS X, will it still be using a bundled version of Avahi, or will it default to using the system-provided mDNSResponder daemon (e.g. OS X's Bonjour)?
Not sure Avahi will be used at all at this point given present objections. Its hard because although its the same protocol, I believe the api is different, so we'd need additional code. I don't think bundling Avahi on OSX is the right answer to anything regardless.
--CJD
Quoted 1 line · Casey Dahlin
Not sure Avahi will be used at all at this point given present objections. Its
Which objections?
Quoted 3 lines
hard because although its the same protocol, I believe the api is different, so we'd need additional code. I don't think bundling Avahi on OSX is the right answer to anything regardless.
You can code against the mDNSResponder API and on Linux use the Avahi mDNSResponder compatibility layer.
tom
Quoted 5 lines · Tomas Carnecky
Quoted 1 line · Casey Dahlin
Not sure Avahi will be used at all at this point given present objections. Its
Which objections?
I believe Luke outlined some issues earlier, particularly the difficulty of getting avahi on Windows. If others would like to continue that flame without me I'll step in and decide the winner when everyone's tired out :)
Quoted 7 lines
Quoted 3 lines
hard because although its the same protocol, I believe the api is different, so we'd need additional code. I don't think bundling Avahi on OSX is the right answer to anything regardless.
You can code against the mDNSResponder API and on Linux use the Avahi mDNSResponder compatibility layer.
Good to know :)
--CJD
Quoted 7 lines · Casey Dahlin
Bittorrent has the luxury of being able to proxy for the poor firewall-bound users since as long as there's one peer exposed to the internet you can have any two other peers connect to him and give him the data they want to exchange, to the benefit of all 3. Git won't work that way because not everyone in the swarm wants all chunks of data, so if you found a proxy node, you might have to make him carry data (possibly lots of data) that he has no personal interest in.
ah, no you don't.
but - think about it: even if they don't, if they don't want the set
of commits that get you up to a particular HEAD or other tag or branch, what the hell are they doing?? :) from what i can gather, git simply doesn't operate in a way where you can "pick and choose" which commits you are and are not going to keep around, in order to reconstruct the repository.
i hope that's right, because i'm counting on it. i.e i'm counting on
the following being true:
"all copies of all git repositories have exactly the same objects
such that git pack-object on the exact same ref and the exact same object ref will return exactly the same information".
if anyone knows a reason why that is NOT the case, please could you tell me!
l.
Quoted 18 lines · Luke Kenneth Casson Leighton
Quoted 7 lines · Casey Dahlin
Bittorrent has the luxury of being able to proxy for the poor firewall-bound users since as long as there's one peer exposed to the internet you can have any two other peers connect to him and give him the data they want to exchange, to the benefit of all 3. Git won't work that way because not everyone in the swarm wants all chunks of data, so if you found a proxy node, you might have to make him carry data (possibly lots of data) that he has no personal interest in.
ah, no you don't.
but - think about it: even if they don't, if they don't want the set
of commits that get you up to a particular HEAD or other tag or branch, what the hell are they doing?? :) from what i can gather, git simply doesn't operate in a way where you can "pick and choose" which commits you are and are not going to keep around, in order to reconstruct the repository.
Quoted 9 lines
i hope that's right, because i'm counting on it. i.e i'm counting on
the following being true:"all copies of all git repositories have exactly the same objects
such that git pack-object on the exact same ref and the exact same object ref will return exactly the same information".if anyone knows a reason why that is NOT the case, please could you tell me!
Commits are always the same for everyone (though two commits you might think of as "the same commit" may not be in git terms). Branches are pretty much always subsets or supersets of oneanother. Repositories? Essentially snowflakes.
Try the kernel: Linus has a branch. Most individuals' repos are going to have some subset of that branch checked out under various names. Not everyone will have all of the commits though, nor will they necessarily want them just now. Most people will have no ref pointing to the top commit of the Linus branch; it will be a couple of commits down due to new things they've added on top. Refs are NOT resource identifiers, and certainly not global resource identifiers.
Now consider the networking people. They have their own branch. It attaches to the linus branch somewhere below the tip linus has published (probably at a revision tag) and includes several unique commits. All the networking people want those commits. None of the rest of people do. There's a btrfs branch too. Some people want that, some don't. Some will have the networking and btrfs branches. Most will have added commits on top privately.
Now consider share by email, where the same commit may appear in several slightly different forms with different SHA 1s.
In summary, no. Repositories are balls of independently produced content. A good peer to peer network needs to let any one client individually address everything out there, but still take advantage of those instances where lots of people do have copies of the same object.
--CJD
This message was originally rejected from the list due to containing an HTML subpart. Resending as plain text.
---
What about using Bonjour (a.k.a. DNS-SD) on OSes that provide this functionality? A lot of us already have local networks that are designed to let Bonjour propagate across the entire network, but hasn't been tested on simple UDP multicast. And with Bonjour you can even get wide-area Bonjour domains, so for example I could set up git hive on my desktop at home, and then get at it via my MobileMe wide-area Bonjour domain from anywhere else in the world.
-Kevin Ballard
Quoted 3 lines · Casey Dahlin
Local networks on the same
subnet have the option of UDP multicast. Avahi can do that. I'd be willing to do it manually or with something else. But yes, for your WAN case its useless.
Quoted 9 lines · Casey Dahlin
And we can exchange them
casey@host_a$ git hive fetch nguyen for_casey casey@host_a$ git branch * master stable for_casey
Quoted 3 lines
Note that the two arguments in fetch are a regex which searches through user IDs and a branch name, which is why I can abbreviate to just "nguyen" in all lower case.
Any possibilty for adding remote helper for fetching/pulling directly using fetch? You have full-duplex connectivity and Git running on both ends, right[1]?
[1] remote-helper connect command is designed for just these sort of cases.
-Ilari
Quoted 14 lines · Ilari Liusvaara
Quoted 9 lines · Casey Dahlin
And we can exchange them
casey@host_a$ git hive fetch nguyen for_casey casey@host_a$ git branch * master stable for_caseyQuoted 3 lines
Note that the two arguments in fetch are a regex which searches through user IDs and a branch name, which is why I can abbreviate to just "nguyen" in all lower case.
Quoted 7 lines
Any possibilty for adding remote helper for fetching/pulling directly using fetch? You have full-duplex connectivity and Git running on both ends, right[1]?
[1] remote-helper connect command is designed for just these sort of cases.
-Ilari
Yep. This will be patch v2 :)
Quoted 24 lines · Casey Dahlin
So now our two peers can see each other.
casey@host_a$ git hive show --branches Nguyen Thai Ngoc Duy <[email protected]> master for_casey---
nguyen@host_b$ git hive show --branches Casey Dahlin <[email protected]> master stable v2.1And we can exchange them
casey@host_a$ git hive fetch nguyen for_casey casey@host_a$ git branch * master stable for_casey
Quoted 3 lines
Note that the two arguments in fetch are a regex which searches through user IDs and a branch name, which is why I can abbreviate to just "nguyen" in all lower case.
I may be a little late into the discussion, but I must say I very much like the idea. I realize that this is mostly intended for local repo sharing (typically between coworkers), but I suspect the idea could be extended to more general distributed repository, ehrm, distribution.
The only thing I would object to, so far, is hive fetch bringing stuff directly into my local repository. I typically prefer content to remain fenced in its appropriate namespace (e.g. I have issues even with the way tags and notes are imported from remotes). For hives, it might be a better idea to have the hive-fetched branches plop into either refs/remotes or maybe even a new dedicated namespace like refs/hive/ ?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 34 lines · Giuseppe Bilotta
Quoted 24 lines · Casey Dahlin
So now our two peers can see each other.
casey@host_a$ git hive show --branches Nguyen Thai Ngoc Duy <[email protected]> master for_casey---
nguyen@host_b$ git hive show --branches Casey Dahlin <[email protected]> master stable v2.1And we can exchange them
casey@host_a$ git hive fetch nguyen for_casey casey@host_a$ git branch * master stable for_caseyQuoted 3 lines
Note that the two arguments in fetch are a regex which searches through user IDs and a branch name, which is why I can abbreviate to just "nguyen" in all lower case.
I may be a little late into the discussion, but I must say I very much like the idea. I realize that this is mostly intended for local repo sharing (typically between coworkers), but I suspect the idea could be extended to more general distributed repository, ehrm, distribution.
Quoted 6 lines
The only thing I would object to, so far, is hive fetch bringing stuff directly into my local repository. I typically prefer content to remain fenced in its appropriate namespace (e.g. I have issues even with the way tags and notes are imported from remotes). For hives, it might be a better idea to have the hive-fetched branches plop into either refs/remotes or maybe even a new dedicated namespace like refs/hive/ ?
Plan is to kill hive-fetch in favor of a fetch helper so the ordinary git retrieval commands may be used.
--CJD