All of lore.kernel.org
 help / color / mirror / Atom feed
* TODO: git should be able to init a remote repo
@ 2010-04-13 17:30 Jay Soffian
  2010-04-13 19:58 ` Ilari Liusvaara
  2010-04-14  9:40 ` Jeff King
  0 siblings, 2 replies; 6+ messages in thread
From: Jay Soffian @ 2010-04-13 17:30 UTC (permalink / raw)
  To: git

[Mostly I'm sending this so I can add a "TODO" label to it in my gmail.] :-)

With modern git, setting up a remote bare repo that you can push to is
finally down to a reasonable number of commands:

$ ssh remote git init --bare myproject.git
$ git remote add -m master origin remote:myproject.git
$ git push -u origin master

But we can do better. I was thinking something like:

$ git remote init [--push] [--mirror] <name> <ssh_url>

This would perform all of the steps above, except for the push itself,
unless given --push (in which case, that too). This is meant to
simplify what I believe is the common case of setting up remote repos.

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: TODO: git should be able to init a remote repo
  2010-04-13 17:30 TODO: git should be able to init a remote repo Jay Soffian
@ 2010-04-13 19:58 ` Ilari Liusvaara
  2010-04-13 21:42   ` Jay Soffian
  2010-04-14  9:40 ` Jeff King
  1 sibling, 1 reply; 6+ messages in thread
From: Ilari Liusvaara @ 2010-04-13 19:58 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

On Tue, Apr 13, 2010 at 01:30:44PM -0400, Jay Soffian wrote:
> [Mostly I'm sending this so I can add a "TODO" label to it in my gmail.] :-)
> 
> With modern git, setting up a remote bare repo that you can push to is
> finally down to a reasonable number of commands:
> 
> $ ssh remote git init --bare myproject.git
> $ git remote add -m master origin remote:myproject.git
> $ git push -u origin master
> 
> But we can do better. I was thinking something like:
> 
> $ git remote init [--push] [--mirror] <name> <ssh_url>
> 
> This would perform all of the steps above, except for the push itself,
> unless given --push (in which case, that too). This is meant to
> simplify what I believe is the common case of setting up remote repos.

Couple of concerns:

- That seems awfully ssh-specific[1]...
- How remote end could deny the operation, modify paths and/or 
get post-creation notification?
- How to handle systems that would autocreate the repository anyway
if push was attempted?

[1] Well, its not like one would want to do that with gits:// anyway,
since there's probably gitolite install on other end anyway...

-Ilari

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: TODO: git should be able to init a remote repo
  2010-04-13 19:58 ` Ilari Liusvaara
@ 2010-04-13 21:42   ` Jay Soffian
  0 siblings, 0 replies; 6+ messages in thread
From: Jay Soffian @ 2010-04-13 21:42 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: git

On Tue, Apr 13, 2010 at 3:58 PM, Ilari Liusvaara
<ilari.liusvaara@elisanet.fi> wrote:
> Couple of concerns:
>
> - That seems awfully ssh-specific[1]...

Of course it is. It's not meant to cover every scenario, just what I
feel is a common one.

> - How remote end could deny the operation, modify paths and/or
> get post-creation notification?

Huh? Obviously this only works if you've got remote shell access, and
that's the only scenario it's intended to cover. As I said, it just
simplifies 3 commands down to 1.

> - How to handle systems that would autocreate the repository anyway
> if push was attempted?

Again, that is not the use case "git remote init" is for.

> [1] Well, its not like one would want to do that with gits:// anyway,
> since there's probably gitolite install on other end anyway...

And this isn't for that scenario.

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: TODO: git should be able to init a remote repo
  2010-04-13 17:30 TODO: git should be able to init a remote repo Jay Soffian
  2010-04-13 19:58 ` Ilari Liusvaara
@ 2010-04-14  9:40 ` Jeff King
  2010-04-14 13:28   ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Jeff King @ 2010-04-14  9:40 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

On Tue, Apr 13, 2010 at 01:30:44PM -0400, Jay Soffian wrote:

> $ ssh remote git init --bare myproject.git
> $ git remote add -m master origin remote:myproject.git
> $ git push -u origin master
> 
> But we can do better. I was thinking something like:
> 
> $ git remote init [--push] [--mirror] <name> <ssh_url>

I just reviewed the giant thread from last time this came up:

  http://thread.gmane.org/gmane.comp.version-control.git/111799

A few things I noticed were:

  1. People seemed to want "git push --create". I think integrating it
     with git-remote would be more convenient for most of my use cases,
     but I can also see people wanting a one-off push-create without
     worrying about configured remotes (e.g., because it is just a drop
     point that they are going to delete later). So any code could
     hopefully be used for both cases.

  2. We talked about an "init-serve" program back then. These days, "git
     init $dir" works, so I don't see the need for one. There was some
     concern about having administrators turn this feature on
     explicitly, in case their site needs extra configuration. Thinking
     on it more, I don't know that we need to do anything special there.

     If a user has shell access, then there is no point in protecting the
     site from them. They can already log in and run "git init". For
     restricted users running "git shell", running "git init" is already
     disallowed. We could add an option to enable it (defaulting to
     off), and optionally translate "git init" invocations to something
     else (so a site with special needs could intercept "git init" to
     run their own script which would do whatever site-specific things
     they wanted, as long as a repo existed in the end).

     Similarly, git-daemon and smart http could probably support the
     same thing, defaulting to off.

     So while it looks ssh-specific, I suspect it could actually be
     transport-agnostic. It's just that most transports wouldn't have it
     turned on by default.

Two questions/reservations looking at your prototype:

  1. Should it push just master, or perhaps --all? Should it actually be
     two separate options to "git remote add" (--push and --init?).

  2. The "git init $dir" syntax is what makes it reasonably transport
     agnostic. But that syntax was not introduced until 1.6.5, so you
     will run into problems with remotes running older versions of git.
     I think it is OK to say that this feature is not supported on older
     versions (otherwise we _must_ be ssh-specific), but I'm not sure
     how graceful the failure will be.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: TODO: git should be able to init a remote repo
  2010-04-14  9:40 ` Jeff King
@ 2010-04-14 13:28   ` Junio C Hamano
  2010-04-14 13:46     ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-04-14 13:28 UTC (permalink / raw)
  To: Jeff King; +Cc: Jay Soffian, git

Jeff King <peff@peff.net> writes:

> On Tue, Apr 13, 2010 at 01:30:44PM -0400, Jay Soffian wrote:
>
>> $ ssh remote git init --bare myproject.git
>> $ git remote add -m master origin remote:myproject.git
>> $ git push -u origin master
>> 
>> But we can do better. I was thinking something like:
>> 
>> $ git remote init [--push] [--mirror] <name> <ssh_url>
>
> I just reviewed the giant thread from last time this came up:
>
>   http://thread.gmane.org/gmane.comp.version-control.git/111799

Thanks for a pointer to an amusing read.

> A few things I noticed were:
>
>   1. People seemed to want "git push --create". I think integrating it
>      with git-remote would be more convenient for most of my use cases,
>      but I can also see people wanting a one-off push-create without
>      worrying about configured remotes (e.g., because it is just a drop
>      point that they are going to delete later). So any code could
>      hopefully be used for both cases.

I think it is fine to have all of the following, triggering the same
underlying mechanism:

	git init over.there.com:myproject.git
        git remote add --create another over.there.com:myproject.git
        git push --create over.there.com:myproject.git master

Even though I'll say that we probably shouldn't have the second one in the
later part of this message.

>   2. We talked about an "init-serve" program back then. These days, "git
>      init $dir" works, so I don't see the need for one.

I don't get this; the primary point of init-serve was _not_ about the lack
of an internal mkdir in "git init", but was about having an interface to
trigger "git init" in a transport agnostic way.  The implementation of the
remote side mechanism could use "git init $dir" instead of "mkdir $dir &&
cd $dir && git init" these days, but I think that is a very minor point.

> Two questions/reservations looking at your prototype:
>
>   1. Should it push just master, or perhaps --all? Should it actually be
>      two separate options to "git remote add" (--push and --init?).

I would say "git remote add --create ..." shouldn't even have push option;
rather, don't put --create in "git remote".

"git push --create" would behave just like normal "push", and the above
question does not even come into the picture.  "push" will push whatever
it would normally push if the repository existed, period.

Also, wouldn't this sequence be more natural?

	git remote add another over.there.com:myproject.git
        git push another

That is, (1) "git remote add" would happily allow creating a local
description for a remote repository to be created; and optionally (2) "git
push" into a configured remote may not need an explicit "--create" (we may
still want to insist on --create to avoid a mistyped URL---I dunno).

>   2. The "git init $dir" syntax is what makes it reasonably transport
>      agnostic.

I am not sure what you are getting at here.  Are you suggesting that $dir
could be a URL (i.e. "git init over.there.com:myproject.git")?  Or are you
still thinking in terms of how "init-serve" (or its equivalent that is
either run directly via ssh or from transports supported by git) is
implemented using "git init"?  It seems the latter judging from this,...

>      ... But that syntax was not introduced until 1.6.5, so you
>      will run into problems with remotes running older versions of git.

... but then I don't see what it has to do with the "transport agnostic"
part of your comment.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: TODO: git should be able to init a remote repo
  2010-04-14 13:28   ` Junio C Hamano
@ 2010-04-14 13:46     ` Jeff King
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2010-04-14 13:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jay Soffian, git

On Wed, Apr 14, 2010 at 06:28:54AM -0700, Junio C Hamano wrote:

> >   2. We talked about an "init-serve" program back then. These days, "git
> >      init $dir" works, so I don't see the need for one.
> 
> I don't get this; the primary point of init-serve was _not_ about the lack
> of an internal mkdir in "git init", but was about having an interface to
> trigger "git init" in a transport agnostic way.  The implementation of the
> remote side mechanism could use "git init $dir" instead of "mkdir $dir &&
> cd $dir && git init" these days, but I think that is a very minor point.

Yeah, my explanation was a bit confused. What I meant was that back
then, we needed some wrapper, because you can't tell git-shell "mkdir x
&& cd x && git init". But these days, "git init" could serve as that
wrapper.

Which leaves the question of whether we need a _separate_ git program to
do init serving. I'm not sure we do. For regular shell users, there is
no point in restricting them; they could just run "git init" themselves.
And by using "git init" directly without any configuration from the
remote site, things will just work for such users.

For users of a restricted shell, the site administrator would have to
configure git-shell to allow "git init". But I think it makes sense for
git-shell to support redirecting "git init" to "git-my-custom-init"
internally. So the client end knows it just needs to say "git init"
whether it is a real shell or a restricted git shell. The lingua franca
for "make me a new repository" is "git init $dir".

> > Two questions/reservations looking at your prototype:
> >
> >   1. Should it push just master, or perhaps --all? Should it actually be
> >      two separate options to "git remote add" (--push and --init?).
> 
> I would say "git remote add --create ..." shouldn't even have push option;
> rather, don't put --create in "git remote".
> 
> "git push --create" would behave just like normal "push", and the above
> question does not even come into the picture.  "push" will push whatever
> it would normally push if the repository existed, period.

Yeah, that is much more natural, I think, and resolves all of the "what
should I push" questions. And it keeps remote's job to "manipulate
config for remotes" which is the direction it has been going on (e.g.,
the recent conversion of "git remote update" to "git fetch --all").

> >   2. The "git init $dir" syntax is what makes it reasonably transport
> >      agnostic.
> 
> I am not sure what you are getting at here.  Are you suggesting that $dir
> could be a URL (i.e. "git init over.there.com:myproject.git")?  Or are you
> still thinking in terms of how "init-serve" (or its equivalent that is
> either run directly via ssh or from transports supported by git) is
> implemented using "git init"?  It seems the latter judging from this,...

The latter. Really, I was conflating two issues: how the ssh transport
can handle both regular and restricted shells, and how other transports
handle it. The first I discussed above in a hopefully more clear way.
For the latter, on thinking more, it is really irrelevant. What the
git-daemon refers to as the "init" service does not necessarily have to
map to a command. So it is not really important.

> >      ... But that syntax was not introduced until 1.6.5, so you
> >      will run into problems with remotes running older versions of git.
> 
> ... but then I don't see what it has to do with the "transport agnostic"
> part of your comment.

Again, me conflating issues. What I meant to say was that for the blind
run-this-command-over-ssh transport, this will not work with older
versions of git on the remote side. But if you make it truly
ssh-specific, you can do "mkdir $dir && cd $dir && git init" which would
work with any version.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-14 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-13 17:30 TODO: git should be able to init a remote repo Jay Soffian
2010-04-13 19:58 ` Ilari Liusvaara
2010-04-13 21:42   ` Jay Soffian
2010-04-14  9:40 ` Jeff King
2010-04-14 13:28   ` Junio C Hamano
2010-04-14 13:46     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.