* [9front] Git multiple remotes
@ 2022-01-03 15:20 Benjamin Riefenstahl
2022-01-03 16:59 ` Philip Silva
0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Riefenstahl @ 2022-01-03 15:20 UTC (permalink / raw)
To: 9front
Hi all,
Is it possible in 9front's Git to have multiple remotes? I find this
often usefull but I can't make it work. The Git commands do not seem to
work with additional remotes in .git/config, they require explicit URLs.
But even then it is not clear to me how to e.g. git/pull from an extenal
repo. The connection is made, output happens, but the local repo seems
not changed in any way?
TIA, benny
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-03 15:20 [9front] Git multiple remotes Benjamin Riefenstahl
@ 2022-01-03 16:59 ` Philip Silva
2022-01-03 19:47 ` Benjamin Riefenstahl
0 siblings, 1 reply; 7+ messages in thread
From: Philip Silva @ 2022-01-03 16:59 UTC (permalink / raw)
To: 9front
Yes you can edit the .git/config and add a new section. Probably there's already a remote "origin" configured so you can just copy that, give it a new name and probably change the fetch accordingly. Then you can git/pull -u remotename and git/push -u remotename!
Greetings, Philip
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-03 16:59 ` Philip Silva
@ 2022-01-03 19:47 ` Benjamin Riefenstahl
2022-01-04 0:20 ` Philip Silva
2022-01-04 16:37 ` ori
0 siblings, 2 replies; 7+ messages in thread
From: Benjamin Riefenstahl @ 2022-01-03 19:47 UTC (permalink / raw)
To: Philip Silva; +Cc: 9front
Hi Philip.
Thanks for confirming what I thought. So this is what I did (slightly
edited):
term% cat /.git/config
[core]
repositoryformatversion = p9.0
[remote "origin"]
url=gits://git.9front.org/plan9front/plan9front
[remote "host"]
url=ssh://benny@host/home/benny/Projects/plan9front
This URL works from the host with "host" replaced with the actual IP
address. The SSH access from my 9front VM also works with "ssh
benny@host hostname".
term% git/pull -u host
git/query: resolve: invalid ref remotes/host/front
git/query: resolve: invalid ref remotes/host/front
git/query: resolve: invalid ref remotes/host/front
ours: facb0e757ac63f763bd942a2714f979538b99eb0
git/query: resolve: invalid ref remotes/host/front
theirs:
git/query: resolve: invalid ref remotes/host/front
common:
git/merge remotes/host/front
term% git/branch -a
heads/front
remotes/THEM/front
remotes/origin/front
I expected remotes/host/front in that list. git/pull also seems to
expect that, s.a.
term% git/query origin/front front host/front
git/query: resolve: invalid ref host/front
term% git/query origin/front front
acc504c319a4b4188479cfa602e40cb6851c0528
facb0e757ac63f763bd942a2714f979538b99eb0
Note that host/front is actually at f63d1d3ce at this time.
I try an explict fetch:
term% cd /
term% git/fetch -u host ssh://benny@host/home/benny/Projects/plan9front
uri: "ssh://benny@host/home/benny/Projects/plan9front"
symref HEAD refs/heads/front
But this does not change anything.
Anything else I could try or add?
TIA, benny
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-03 19:47 ` Benjamin Riefenstahl
@ 2022-01-04 0:20 ` Philip Silva
2022-01-04 12:44 ` Benjamin Riefenstahl
2022-01-04 16:37 ` ori
1 sibling, 1 reply; 7+ messages in thread
From: Philip Silva @ 2022-01-04 0:20 UTC (permalink / raw)
To: Benjamin Riefenstahl; +Cc: 9front
Ah ok I use it with https:// and hjgit:// so far. Maybe it's easier to try in separate directories before setting up multiple remotes in one. Also I use the fetch=... without the [core] section like so:
[remote "origin"]
url=gits://git.9front.org/plan9front/plan9front
fetch=+refs/heads/*:refs/remotes/origin/*
[remote "host"]
url=ssh://benny@host/home/benny/Projects/plan9front
fetch=+refs/heads/*:refs/remotes/host/*
Not sure if the fetch is really needed though
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-04 0:20 ` Philip Silva
@ 2022-01-04 12:44 ` Benjamin Riefenstahl
0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Riefenstahl @ 2022-01-04 12:44 UTC (permalink / raw)
To: Philip Silva; +Cc: 9front
Hi Philip,
Philip Silva writes:
> Also I use the fetch=... without the [core] section like so:
>
> [remote "origin"]
> url=gits://git.9front.org/plan9front/plan9front
> fetch=+refs/heads/*:refs/remotes/origin/*
> [remote "host"]
> url=ssh://benny@host/home/benny/Projects/plan9front
> fetch=+refs/heads/*:refs/remotes/host/*
>
> Not sure if the fetch is really needed though
I did not use that before, but adding it does not seem to make a
difference.
> Maybe it's easier to try in separate directories before setting up
> multiple remotes in one.
That mostly defeats the purpose, I think. The puropse being, to
exchange commits without via import/export and copying patches back and
forth.
Maybe another way would be to go the other direction, serve the Git repo
in my 9front VM, so I can access it from the host. I'll try that next,
https://orib.dev/githosting.html gives an example that I might be able
to follow.
Thanks so far, benny
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-03 19:47 ` Benjamin Riefenstahl
2022-01-04 0:20 ` Philip Silva
@ 2022-01-04 16:37 ` ori
2022-01-04 19:14 ` Benjamin Riefenstahl
1 sibling, 1 reply; 7+ messages in thread
From: ori @ 2022-01-04 16:37 UTC (permalink / raw)
To: 9front, philip.silva; +Cc: 9front
Quoth Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>:
> Hi Philip.
>
> Thanks for confirming what I thought. So this is what I did (slightly
> edited):
>
> term% cat /.git/config
> [core]
> repositoryformatversion = p9.0
> [remote "origin"]
> url=gits://git.9front.org/plan9front/plan9front
> [remote "host"]
> url=ssh://benny@host/home/benny/Projects/plan9front
>
> This URL works from the host with "host" replaced with the actual IP
> address. The SSH access from my 9front VM also works with "ssh
> benny@host hostname".
>
> term% git/pull -u host
> git/query: resolve: invalid ref remotes/host/front
> git/query: resolve: invalid ref remotes/host/front
> git/query: resolve: invalid ref remotes/host/front
> ours: facb0e757ac63f763bd942a2714f979538b99eb0
> git/query: resolve: invalid ref remotes/host/front
> theirs:
> git/query: resolve: invalid ref remotes/host/front
> common:
> git/merge remotes/host/front
>
> term% git/branch -a
> heads/front
> remotes/THEM/front
> remotes/origin/front
>
> I expected remotes/host/front in that list. git/pull also seems to
> expect that, s.a.
>
> term% git/query origin/front front host/front
> git/query: resolve: invalid ref host/front
>
> term% git/query origin/front front
> acc504c319a4b4188479cfa602e40cb6851c0528
> facb0e757ac63f763bd942a2714f979538b99eb0
>
> Note that host/front is actually at f63d1d3ce at this time.
>
> I try an explict fetch:
>
> term% cd /
> term% git/fetch -u host ssh://benny@host/home/benny/Projects/plan9front
> uri: "ssh://benny@host/home/benny/Projects/plan9front"
> symref HEAD refs/heads/front
>
> But this does not change anything.
>
> Anything else I could try or add?
>
> TIA, benny
>
by default, we don't fetch all remote branches;
there was a diff that went in a while ago to improve
this, but it got backed out because it encounters a
bug in upstream git -- the spec says that a single
ACK should be sent when not using multi-ack modes,
but they send back multiple ones. I've got an
apparent workaround to fix that, but it's not yet
tested enough to commit.
Here's the work in progress -- if you can apply it
@{cd / && ape/patch -p1} < $patch
and let me know if that improves things, that'd be
appreciated. There's a chance I may just need to put
in a heuristic for when the pack starts, or bite the
bullet and implement multi-ack.
diff f63d1d3ced81702e0eadf56228a54a467278b0d4 uncommitted
--- a/sys/src/cmd/git/fetch.c
+++ b/sys/src/cmd/git/fetch.c
@@ -186,6 +186,7 @@
int nref, refsz, first;
int i, n, req, pfd;
vlong packsz;
+ Objset hadobj;
Object *o;
nref = 0;
@@ -246,13 +247,19 @@
req = 1;
}
flushpkt(c);
+ osinit(&hadobj);
for(i = 0; i < nref; i++){
- if(hasheq(&have[i], &Zhash))
+ if(hasheq(&have[i], &Zhash) || oshas(&hadobj, have[i]))
continue;
+ if((o = readobject(have[i])) == nil)
+ sysfatal("missing object we should have: %H", have[i]);
+ osadd(&hadobj, o);
+ unref(o);
n = snprint(buf, sizeof(buf), "have %H\n", have[i]);
if(writepkt(c, buf, n + 1) == -1)
sysfatal("could not send have for %H", have[i]);
}
+ osclear(&hadobj);
if(!req)
flushpkt(c);
@@ -260,7 +267,7 @@
if(writepkt(c, buf, n) == -1)
sysfatal("write: %r");
if(!req)
- return 0;
+ goto showrefs;
if(readphase(c) == -1)
sysfatal("read: %r");
if((n = readpkt(c, buf, sizeof(buf))) == -1)
--- a/sys/src/cmd/git/pull
+++ b/sys/src/cmd/git/pull
@@ -7,13 +7,10 @@
upstream=$2
url=$3
dir=$4
- bflag=()
dflag=()
- if(! ~ $#branch 0)
- bflag=(-b $branch)
if(! ~ $#debug 0)
dflag='-d'
- {git/fetch $dflag $bflag -u $upstream $url >[2=3] || die $status} | awk '
+ {git/fetch $dflag -u $upstream $url >[2=3] || die $status} | awk '
/^remote/{
if($2=="HEAD")
next
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9front] Git multiple remotes
2022-01-04 16:37 ` ori
@ 2022-01-04 19:14 ` Benjamin Riefenstahl
0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Riefenstahl @ 2022-01-04 19:14 UTC (permalink / raw)
To: ori; +Cc: 9front, philip.silva
> by default, we don't fetch all remote branches;
I see.
> I've got an apparent workaround to fix that, but it's not yet tested
> enough to commit.
>
> Here's the work in progress -- if you can apply it
>
> @{cd / && ape/patch -p1} < $patch
Cool, that works (after compiling obviously ;-).
Thanks a lot. I will run with that and let you know if I encounter any
problems.
so long, benny
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-04 19:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 15:20 [9front] Git multiple remotes Benjamin Riefenstahl
2022-01-03 16:59 ` Philip Silva
2022-01-03 19:47 ` Benjamin Riefenstahl
2022-01-04 0:20 ` Philip Silva
2022-01-04 12:44 ` Benjamin Riefenstahl
2022-01-04 16:37 ` ori
2022-01-04 19:14 ` Benjamin Riefenstahl
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).