git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-init: treat option `--bare'

From
LRLuciano Rocha <luciano@eurotux.com>
Date
May 28, 2008, 18:53 UTC
Message-ID
<20080528185357.GB4431@bit.office.eurotux.com>
In-Reply-To
<20080528185103.GA4431@bit.office.eurotux.com>

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
Previous: Luciano RochaNext: Junio C Hamano
Message 8 of 12 in “bare --init Vs --init bare”
  1. Luciano RochaMay 19, 2008
  2. Santi BéjarMay 19, 2008
  3. Luciano RochaMay 19, 2008
  4. git-init: inform user of `git --bare init' optionLuciano Rocha, May 20, 2008
  5. Junio C HamanoMay 23, 2008
  6. Luciano RochaMay 23, 2008
  7. git-init: treat option `--bare'Luciano Rocha, May 28, 2008
  8. Luciano RochaMay 28, 2008
  9. Junio C HamanoMay 29, 2008
  10. Luciano RochaMay 29, 2008
  11. Johannes SchindelinMay 29, 2008
  12. Junio C HamanoMay 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.