* bare --init Vs --init bare @ 2008-05-19 17:53 Luciano Rocha 2008-05-19 19:32 ` Santi Béjar 2008-05-20 19:48 ` [PATCH] git-init: inform user of `git --bare init' option Luciano Rocha 0 siblings, 2 replies; 12+ messages in thread From: Luciano Rocha @ 2008-05-19 17:53 UTC (permalink / raw) To: git [-- Attachment #1: Type: text/plain, Size: 497 bytes --] Hello, This is odd: $ git init --bare usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] $ git --bare init Initialized empty Git repository in /tmp/1/ My git version: $ git --version git version 1.5.5.1.318.gc99b (Has two patches on top of origin's 377d9c409ffe0f0d994b929aeb94716139207b9d, setting default prefix in Makefile.) Regards, Luciano Rocha -- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/> [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: bare --init Vs --init bare 2008-05-19 17:53 bare --init Vs --init bare Luciano Rocha @ 2008-05-19 19:32 ` Santi Béjar 2008-05-19 20:10 ` Luciano Rocha 2008-05-20 19:48 ` [PATCH] git-init: inform user of `git --bare init' option Luciano Rocha 1 sibling, 1 reply; 12+ messages in thread From: Santi Béjar @ 2008-05-19 19:32 UTC (permalink / raw) To: Luciano Rocha; +Cc: git On Mon, May 19, 2008 at 7:53 PM, Luciano Rocha <luciano@eurotux.com> wrote: > > Hello, > > This is odd: > $ git init --bare > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > $ git --bare init > Initialized empty Git repository in /tmp/1/ The first is a flag to the init subcommand (man git-init), and the other is a flag to git (man git). See also: http://www.google.com/search?q=%22git+init+--bare%22+%22git+--bare+init%22 or equivalent http://kerneltrap.org/mailarchive/git/2007/10/15/344050 "should git command and git-command be equivalent?" Santi > > My git version: > $ git --version > git version 1.5.5.1.318.gc99b > > (Has two patches on top of origin's > 377d9c409ffe0f0d994b929aeb94716139207b9d, setting default prefix in > Makefile.) > > Regards, > Luciano Rocha > > -- > Luciano Rocha <luciano@eurotux.com> > Eurotux Informática, S.A. <http://www.eurotux.com/> > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: bare --init Vs --init bare 2008-05-19 19:32 ` Santi Béjar @ 2008-05-19 20:10 ` Luciano Rocha 0 siblings, 0 replies; 12+ messages in thread From: Luciano Rocha @ 2008-05-19 20:10 UTC (permalink / raw) To: Santi Béjar; +Cc: git [-- Attachment #1: Type: text/plain, Size: 1150 bytes --] On Mon, May 19, 2008 at 09:32:21PM +0200, Santi Béjar wrote: > On Mon, May 19, 2008 at 7:53 PM, Luciano Rocha <luciano@eurotux.com> wrote: > > > > Hello, > > > > > This is odd: > > $ git init --bare > > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > > $ git --bare init > > Initialized empty Git repository in /tmp/1/ > > The first is a flag to the init subcommand (man git-init), and the > other is a flag to git (man git). > > See also: > > http://www.google.com/search?q=%22git+init+--bare%22+%22git+--bare+init%22 > > or equivalent > > http://kerneltrap.org/mailarchive/git/2007/10/15/344050 > "should git command and git-command be equivalent?" > Ok, I understand. Still, there's a --bare command to git clone, and I had only tried git init --bare, not the other form, and it always failed. Only today did I learn I could do a git --bare init, from a colleague of mine. I'd suggest allowing git init --bare, or documenting the --bare init option. Regards, Luciano Rocha -- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/> [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] git-init: inform user of `git --bare init' option 2008-05-19 17:53 bare --init Vs --init bare Luciano Rocha 2008-05-19 19:32 ` Santi Béjar @ 2008-05-20 19:48 ` Luciano Rocha 2008-05-23 6:02 ` Junio C Hamano 1 sibling, 1 reply; 12+ messages in thread From: Luciano Rocha @ 2008-05-20 19:48 UTC (permalink / raw) To: git Creation of a bare repository isn't consistent: $ git init --bare usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] $ git --bare init Initialized empty Git repository in ... Document the second option, and show an error informing of it if the user calls `git-init' with a `--bare' option. Signed-off-by: Luciano Rocha <strange@nsk.pt> --- Documentation/git-init.txt | 2 ++ builtin-init-db.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index b17ae84..bb87e58 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -84,6 +84,8 @@ Running `git-init` in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning `git-init` is to pick up newly added templates. +For creating a bare repository, use the form `git --bare init`. + Note that `git-init` is the same as `git-init-db`. The command was primarily meant to initialize the object database, but over time it has become responsible for setting up the other aspects diff --git a/builtin-init-db.c b/builtin-init-db.c index a76f5d3..65454b1 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -334,6 +334,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) template_dir = arg+11; else if (!strcmp(arg, "--shared")) shared_repository = PERM_GROUP; + else if (!strcmp(arg, "--bare")) + die("Run `git --bare init' instead to create a bare repository"); else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet")) -- 1.5.5.1.317.ge7bcb.dirty ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: inform user of `git --bare init' option 2008-05-20 19:48 ` [PATCH] git-init: inform user of `git --bare init' option Luciano Rocha @ 2008-05-23 6:02 ` Junio C Hamano 2008-05-23 14:24 ` Luciano Rocha 2008-05-28 18:51 ` [PATCH] git-init: treat option `--bare' Luciano Rocha 0 siblings, 2 replies; 12+ messages in thread From: Junio C Hamano @ 2008-05-23 6:02 UTC (permalink / raw) To: Luciano Rocha; +Cc: git Luciano Rocha <luciano@eurotux.com> writes: > Creation of a bare repository isn't consistent: > > $ git init --bare > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > $ git --bare init > Initialized empty Git repository in ... The examples do not demonstrate that "it isn't consistent". It just demonstrates that it is easy for people to forget that --bare option is an option to the "git" potty itself and not an option to "git init". > diff --git a/builtin-init-db.c b/builtin-init-db.c > index a76f5d3..65454b1 100644 > --- a/builtin-init-db.c > +++ b/builtin-init-db.c > @@ -334,6 +334,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) > template_dir = arg+11; > else if (!strcmp(arg, "--shared")) > shared_repository = PERM_GROUP; > + else if (!strcmp(arg, "--bare")) > + die("Run `git --bare init' instead to create a bare repository"); > else if (!prefixcmp(arg, "--shared=")) > shared_repository = git_config_perm("arg", arg+9); > else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet")) Given that you are adding a special case support for "git init --bare" anyway, a better approach to help people out of this easy confusion (and we have to admit that the confusion is very easy!) would be to make "git init --bare" pretend/behave as if the user said "git --bare init", don't you think? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: inform user of `git --bare init' option 2008-05-23 6:02 ` Junio C Hamano @ 2008-05-23 14:24 ` Luciano Rocha 2008-05-28 18:51 ` [PATCH] git-init: treat option `--bare' Luciano Rocha 1 sibling, 0 replies; 12+ messages in thread From: Luciano Rocha @ 2008-05-23 14:24 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 1231 bytes --] On Thu, May 22, 2008 at 11:02:59PM -0700, Junio C Hamano wrote: > Luciano Rocha <luciano@eurotux.com> writes: > > > Creation of a bare repository isn't consistent: > > > > $ git init --bare > > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > > $ git --bare init > > Initialized empty Git repository in ... > > The examples do not demonstrate that "it isn't consistent". It just > demonstrates that it is easy for people to forget that --bare option is an > option to the "git" potty itself and not an option to "git init". Well, "git --help init" works the same as "git init --help", so "--bare" not working depending on its position isn't very consistent... <patch snipped> > Given that you are adding a special case support for "git init --bare" > anyway, a better approach to help people out of this easy confusion (and > we have to admit that the confusion is very easy!) would be to make "git > init --bare" pretend/behave as if the user said "git --bare init", don't > you think? Yes, but this was easy for me to do. The proper way, however, will take me more time. -- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/> [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] git-init: treat option `--bare' 2008-05-23 6:02 ` Junio C Hamano 2008-05-23 14:24 ` Luciano Rocha @ 2008-05-28 18:51 ` Luciano Rocha 2008-05-28 18:53 ` Luciano Rocha 1 sibling, 1 reply; 12+ messages in thread From: Luciano Rocha @ 2008-05-28 18:51 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 2594 bytes --] Currently, passing the `--bare' option to git-init proper doesn't work, and gives no indication that `git --bare init' would work instead: $ git init --bare usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] Treat the `--bare' option internally in builtin-init-db. Also, fix the usage string, synchronising it with the synopsis in the documentation. --- Documentation/git-init.txt | 7 ++++++- builtin-init-db.c | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) Parsing the --bare option correctly (AFAICS) was easier than I expected. diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index b17ae84..b48c312 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one SYNOPSIS -------- -'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]] +'git-init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] OPTIONS @@ -20,6 +20,11 @@ OPTIONS Only print error and warning messages, all other output will be suppressed. +--bare:: + +Create a bare repository. If GIT_DIR environment is not set, it is set to the +current working directory. + --template=<template_directory>:: Provide the directory from which templates will be used. The default template diff --git a/builtin-init-db.c b/builtin-init-db.c index d8bdf92..e23b843 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -364,7 +364,7 @@ static int guess_repository_type(const char *git_dir) } static const char init_db_usage[] = -"git-init [-q | --quiet] [--template=<template-directory>] [--shared]"; +"git-init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]"; /* * If you want to, you can share the DB area with any number of branches. @@ -383,7 +383,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *arg = argv[1]; if (!prefixcmp(arg, "--template=")) template_dir = arg+11; - else if (!strcmp(arg, "--shared")) + else if (!strcmp(arg, "--bare")) { + static char git_dir[PATH_MAX+1]; + is_bare_repository_cfg = 1; + setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, + sizeof(git_dir)), 0); + } else if (!strcmp(arg, "--shared")) shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); -- 1.5.6.rc0.41.gabae7.dirty [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: treat option `--bare' 2008-05-28 18:51 ` [PATCH] git-init: treat option `--bare' Luciano Rocha @ 2008-05-28 18:53 ` Luciano Rocha 2008-05-29 0:55 ` Junio C Hamano 0 siblings, 1 reply; 12+ messages in thread From: Luciano Rocha @ 2008-05-28 18:53 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 2684 bytes --] Currently, passing the `--bare' option to git-init proper doesn't work, and gives no indication that `git --bare init' would work instead: $ git init --bare usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] Treat the `--bare' option internally in builtin-init-db. Also, fix the usage string, synchronising it with the synopsis in the documentation. Signed-off-by: Luciano Rocha <strange@nsk.pt> --- Documentation/git-init.txt | 7 ++++++- builtin-init-db.c | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) Parsing the --bare option correctly (AFAICS) was easier than I expected. Sorry, forgot the Signed-off-by line. diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index b17ae84..b48c312 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one SYNOPSIS -------- -'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]] +'git-init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] OPTIONS @@ -20,6 +20,11 @@ OPTIONS Only print error and warning messages, all other output will be suppressed. +--bare:: + +Create a bare repository. If GIT_DIR environment is not set, it is set to the +current working directory. + --template=<template_directory>:: Provide the directory from which templates will be used. The default template diff --git a/builtin-init-db.c b/builtin-init-db.c index d8bdf92..e23b843 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -364,7 +364,7 @@ static int guess_repository_type(const char *git_dir) } static const char init_db_usage[] = -"git-init [-q | --quiet] [--template=<template-directory>] [--shared]"; +"git-init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]"; /* * If you want to, you can share the DB area with any number of branches. @@ -383,7 +383,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *arg = argv[1]; if (!prefixcmp(arg, "--template=")) template_dir = arg+11; - else if (!strcmp(arg, "--shared")) + else if (!strcmp(arg, "--bare")) { + static char git_dir[PATH_MAX+1]; + is_bare_repository_cfg = 1; + setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, + sizeof(git_dir)), 0); + } else if (!strcmp(arg, "--shared")) shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); -- 1.5.6.rc0.41.gabae7.dirty [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: treat option `--bare' 2008-05-28 18:53 ` Luciano Rocha @ 2008-05-29 0:55 ` Junio C Hamano 2008-05-29 9:10 ` Luciano Rocha 2008-05-29 13:51 ` Johannes Schindelin 0 siblings, 2 replies; 12+ messages in thread From: Junio C Hamano @ 2008-05-29 0:55 UTC (permalink / raw) To: git; +Cc: Luciano Rocha Luciano Rocha <luciano@eurotux.com> writes: > Currently, passing the `--bare' option to git-init proper doesn't work, and > gives no indication that `git --bare init' would work instead: > > $ git init --bare > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > > Treat the `--bare' option internally in builtin-init-db. > > Also, fix the usage string, synchronising it with the synopsis in the > documentation. > > Signed-off-by: Luciano Rocha <strange@nsk.pt> It could be argued that this kind of "special casing to help common mistake situation" would in the long run hamper the new users in understanding what --bare means, because one who uses "git init --bare" will not realize that --bare is an option to "git" potty in general and can be given when invoking other git commands. On the other hand, many commands do work sensibly inside a bare repository already, and "init" is truly special in that it cannot inspect the surroundings to guess if the user wants to create a bare repository or one with a work-tree because there isn't a repository yet. In that sense, probably people not learning "git --bare" is not such a loss after all. In general, I am not particularly fond of this kind of special casing, but initializing a bare repository would be a common enough operation that I personally think it is probably Ok to take this as an exception. Opinions? Breakages? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: treat option `--bare' 2008-05-29 0:55 ` Junio C Hamano @ 2008-05-29 9:10 ` Luciano Rocha 2008-05-29 13:51 ` Johannes Schindelin 1 sibling, 0 replies; 12+ messages in thread From: Luciano Rocha @ 2008-05-29 9:10 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 3358 bytes --] On Wed, May 28, 2008 at 05:55:46PM -0700, Junio C Hamano wrote: > Luciano Rocha <luciano@eurotux.com> writes: > > > Currently, passing the `--bare' option to git-init proper doesn't work, and > > gives no indication that `git --bare init' would work instead: > > > > $ git init --bare > > usage: git-init [-q | --quiet] [--template=<template-directory>] [--shared] > > > > Treat the `--bare' option internally in builtin-init-db. > > > > Also, fix the usage string, synchronising it with the synopsis in the > > documentation. > > > > Signed-off-by: Luciano Rocha <strange@nsk.pt> > > It could be argued that this kind of "special casing to help common > mistake situation" would in the long run hamper the new users in > understanding what --bare means, because one who uses "git init --bare" > will not realize that --bare is an option to "git" potty in general and > can be given when invoking other git commands. On the other hand, many > commands do work sensibly inside a bare repository already, and "init" is > truly special in that it cannot inspect the surroundings to guess if the > user wants to create a bare repository or one with a work-tree because > there isn't a repository yet. In that sense, probably people not learning > "git --bare" is not such a loss after all. > > In general, I am not particularly fond of this kind of special casing, but > initializing a bare repository would be a common enough operation that I > personally think it is probably Ok to take this as an exception. > > Opinions? Breakages? > Personally, my first experience with bare repositories, was when I decided to have local mirrors of several projects. As I weren't going to do work over then, I considered copies without a checkout. Reading the documentation for git-clone, I found the '--bare' option, and found that the commands that I mattered about worked transparently (log, diff, archive). Much later, when trying to create a public mirror of some of my projects, I tried to create a bare copy. However, as I didn't have access from the remote server to my working copy, I had to push my changes to the remote server. But 'git init --bare' didn't work, so I resorted to: mirror$ git init personal$ git push mirror:copy mirror$ git clone --bare copy public Only some time later, in a discussion with a friend, did I learn that 'git --bare init' worked (and thus this thread was started). In my defence, the usage displayed when running just "git" hides the '--bare' option, as my terminals usually have 24 lines. And the transparently way that the other commands I cared about worked inside a bare repository eliminated any need of mine to search for a way to specify that I was working with a bare repository to all git commands. All in all, you are right when you say that 'this kind of "special casing" ... would in the long run hamper the new users ... [by not realizing ] that --bare is an option to "git" potty in general', as is attested by my ignorance of it. But as there is a valid reason for the '--bare' option to git-clone, there is one for git-init. But the '--bare' option for "git" must be at least mentioned in the documentation for those two commands. -- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/> [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: treat option `--bare' 2008-05-29 0:55 ` Junio C Hamano 2008-05-29 9:10 ` Luciano Rocha @ 2008-05-29 13:51 ` Johannes Schindelin 2008-05-29 18:31 ` Junio C Hamano 1 sibling, 1 reply; 12+ messages in thread From: Johannes Schindelin @ 2008-05-29 13:51 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Luciano Rocha Hi, On Wed, 28 May 2008, Junio C Hamano wrote: > In general, I am not particularly fond of this kind of special casing, > but initializing a bare repository would be a common enough operation > that I personally think it is probably Ok to take this as an exception. I like the Perl way (having multiple options to do the same thing), and do not like the Python way ("there is only one way to do one thing"). > Opinions? Breakages? I like the intent of the patch. It will definitely make initializing bare Git repositories easier for new users. Also keep in mind that "git --bare <some-command-other-than-init" is _really_ rare, at least in my experience. I had to use it exactly _twice_ since I started using Git. Ciao, Dscho ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] git-init: treat option `--bare' 2008-05-29 13:51 ` Johannes Schindelin @ 2008-05-29 18:31 ` Junio C Hamano 0 siblings, 0 replies; 12+ messages in thread From: Junio C Hamano @ 2008-05-29 18:31 UTC (permalink / raw) To: Johannes Schindelin; +Cc: git, Luciano Rocha Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > Also keep in mind that "git --bare <some-command-other-than-init" is > _really_ rare, at least in my experience. I had to use it exactly _twice_ > since I started using Git. Exactly. That is really the contributing factor that I am in favor of this (perhaps redundant from theoretical point of view) addition. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-05-29 18:32 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-05-19 17:53 bare --init Vs --init bare Luciano Rocha 2008-05-19 19:32 ` Santi Béjar 2008-05-19 20:10 ` Luciano Rocha 2008-05-20 19:48 ` [PATCH] git-init: inform user of `git --bare init' option Luciano Rocha 2008-05-23 6:02 ` Junio C Hamano 2008-05-23 14:24 ` Luciano Rocha 2008-05-28 18:51 ` [PATCH] git-init: treat option `--bare' Luciano Rocha 2008-05-28 18:53 ` Luciano Rocha 2008-05-29 0:55 ` Junio C Hamano 2008-05-29 9:10 ` Luciano Rocha 2008-05-29 13:51 ` Johannes Schindelin 2008-05-29 18:31 ` Junio C Hamano
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).