{"thread":{"id":"43220","subject":"Re: [PATCH] Provide more meaningful output from 'git init-db'.","startedAt":"2006-12-15T02:43:08Z","lastAt":"2006-12-15T14:59:00Z","messageCount":4,"participants":["Shawn Pearce","Shawn O. Pearce","Nicolas Pitre","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294706","messageId":"Pine.LNX.4.64.0612142141420.18171@xanadu.home","threadId":"43220","inReplyTo":"20061215022543.GL26202@spearce.org","subject":"Re: [PATCH] Stop telling users we are 'defaulting to local storage area'.","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-12-15T02:43:08Z","receivedAt":"2006-12-15T02:43:08Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 14 Dec 2006, Shawn Pearce wrote:\n\n> Nicolas Pitre <nico@cam.org> wrote:\n> > On Thu, 14 Dec 2006, Shawn O. Pearce wrote:\n> > > It also breaks from our normal behavior of not printing\n> > > anything if the command was successful.\n> \n> > I really don't think this is a good rule.\n> > \n> > NOte that I'm not against commands that are silent by default.  I really \n> > think that git-add should remain silent on success by default when \n> > successful.\n> > \n> > But the rule of thumb should be about the importance of the action \n> > performed by the command.\n> > But git-init-db is really important.  \n> \n> A very reasonable argument, butchered for my evil quoting needs.  :-)\n> \n> If we want to keep letting git-init-db output something, then\n> the output should be a lot more meaningful to the average English\n> speaking new Git user than \"defaulting to local storage area\".\n\nAbsolutely!\n\n> BTW, I almost also submitted a patch to remove the \"Committing\n> initial tree ...\" message in git-commit-tree, but thought twice about\n> it as committing an initial tree is sort of an important difference\n> from normal activity that we should highlight it somehow...\n\nPlease ignore that one.  I'm working on a patch to handle the commit \ncase (need to update the tutorial accordingly).\n\n\n"},{"id":"294238","messageId":"20061215054458.GA27750@spearce.org","threadId":"43220","inReplyTo":"Pine.LNX.4.64.0612142141420.18171@xanadu.home","subject":"[PATCH] Provide more meaningful output from 'git init-db'.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-15T05:44:58Z","receivedAt":"2006-12-15T05:44:58Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Back in the old days of Git when people messed around with their\nGIT_DIR environment variable more often it was nice to know whether\nor not git-init-db created a .git directory or used GIT_DIR.\nAs most users at that time were rather technical UNIXy folk the\nmessage \"defaulting to local storage area\" made sense to some and\nseemed reasonable.\n\nBut it doesn't really convey any meaning to the new Git user,\nas they don't know what a 'local storage area is' nor do they\nknow enough about Git to care.  It also really doesn't tell the\nexperienced Git user a whole lot about the command they just ran,\nespecially if they might be reinitializing an existing repository\n(e.g. to update hooks).\n\nSo now we print out what we did (\"Initialized empty\" or\n\"Reinitialized existing\"), what type of repository (\"\" or \"shared\"),\nand what location the repository will be in (\"$GIT_DIR\").\n\nSuggested in part by Andy Parkins in his Git 'niggles' list\n(<200612132237.10051.andyparkins@gmail.com>).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n Documentation/core-tutorial.txt |    2 +-\n Documentation/tutorial-2.txt    |    2 +-\n Documentation/tutorial.txt      |    2 +-\n builtin-init-db.c               |   21 ++++++++++++++-------\n 4 files changed, 17 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt\nindex 47505aa..abe74a7 100644\n--- a/Documentation/core-tutorial.txt\n+++ b/Documentation/core-tutorial.txt\n@@ -57,7 +57,7 @@ $ git-init-db\n to which git will reply\n \n ----------------\n-defaulting to local storage area\n+Initialized empty Git repository in .git/\n ----------------\n \n which is just git's way of saying that you haven't been doing anything\ndiff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt\nindex 6389de5..7a692d7 100644\n--- a/Documentation/tutorial-2.txt\n+++ b/Documentation/tutorial-2.txt\n@@ -18,7 +18,7 @@ Let's start a new project and create a small amount of history:\n $ mkdir test-project\n $ cd test-project\n $ git init-db\n-defaulting to local storage area\n+Initialized empty Git repository in .git/\n $ echo 'hello world' > file.txt\n $ git add .\n $ git commit -a -m \"initial commit\"\ndiff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt\nindex 02dede3..cb808d9 100644\n--- a/Documentation/tutorial.txt\n+++ b/Documentation/tutorial.txt\n@@ -38,7 +38,7 @@ $ git init-db\n Git will reply\n \n ------------------------------------------------\n-defaulting to local storage area\n+Initialized empty Git repository in .git/\n ------------------------------------------------\n \n You've now initialized the working directory--you may notice a new\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 235a0ee..8f2b750 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -164,13 +164,14 @@ static void copy_templates(const char *git_dir, int len, const char *template_di\n \tclosedir(dir);\n }\n \n-static void create_default_files(const char *git_dir, const char *template_path)\n+static int create_default_files(const char *git_dir, const char *template_path)\n {\n \tunsigned len = strlen(git_dir);\n \tstatic char path[PATH_MAX];\n \tunsigned char sha1[20];\n \tstruct stat st1;\n \tchar repo_version_string[10];\n+\tint reinit;\n \n \tif (len > sizeof(path)-50)\n \t\tdie(\"insane git directory %s\", git_dir);\n@@ -218,7 +219,8 @@ static void create_default_files(const char *git_dir, const char *template_path)\n \t * branch, if it does not exist yet.\n \t */\n \tstrcpy(path + len, \"HEAD\");\n-\tif (read_ref(\"HEAD\", sha1) < 0) {\n+\treinit = !read_ref(\"HEAD\", sha1);\n+\tif (!reinit) {\n \t\tif (create_symref(\"HEAD\", \"refs/heads/master\") < 0)\n \t\t\texit(1);\n \t}\n@@ -239,6 +241,8 @@ static void create_default_files(const char *git_dir, const char *template_path)\n \t\tgit_config_set(\"core.filemode\",\n \t\t\t       filemode ? \"true\" : \"false\");\n \t}\n+\n+\treturn reinit;\n }\n \n static const char init_db_usage[] =\n@@ -256,7 +260,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tconst char *sha1_dir;\n \tconst char *template_dir = NULL;\n \tchar *path;\n-\tint len, i;\n+\tint len, i, reinit;\n \n \tfor (i = 1; i < argc; i++, argv++) {\n \t\tconst char *arg = argv[1];\n@@ -274,10 +278,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t * Set up the default .git directory contents\n \t */\n \tgit_dir = getenv(GIT_DIR_ENVIRONMENT);\n-\tif (!git_dir) {\n+\tif (!git_dir)\n \t\tgit_dir = DEFAULT_GIT_DIR_ENVIRONMENT;\n-\t\tfprintf(stderr, \"defaulting to local storage area\\n\");\n-\t}\n \tsafe_create_dir(git_dir, 0);\n \n \t/* Check to see if the repository version is right.\n@@ -287,7 +289,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t */\n \tcheck_repository_format();\n \n-\tcreate_default_files(git_dir, template_dir);\n+\treinit = create_default_files(git_dir, template_dir);\n \n \t/*\n \t * And set up the object store.\n@@ -314,5 +316,10 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t\tgit_config_set(\"receive.denyNonFastforwards\", \"true\");\n \t}\n \n+\tprintf(\"%s%s Git repository in %s/\\n\",\n+\t\treinit ? \"Reinitialized existing\" : \"Initialized empty\",\n+\t\tshared_repository ? \" shared\" : \"\",\n+\t\tgit_dir);\n+\n \treturn 0;\n }\n-- \n"},{"id":"297683","messageId":"eluaf0$v7q$2@sea.gmane.org","threadId":"43220","inReplyTo":"20061215054458.GA27750@spearce.org","subject":"Re: [PATCH] Provide more meaningful output from 'git init-db'.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-15T14:14:15Z","receivedAt":"2006-12-15T14:14:15Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Shawn O. Pearce wrote:\n\n> So now we print out what we did (\"Initialized empty\" or\n> \"Reinitialized existing\"), what type of repository (\"\" or \"shared\"),\n> and what location the repository will be in (\"$GIT_DIR\").\n\n>  ----------------\n> -defaulting to local storage area\n> +Initialized empty Git repository in .git/\n>  ----------------\n\n> +     printf(\"%s%s Git repository in %s/\\n\",\n> +             reinit ? \"Reinitialized existing\" : \"Initialized empty\",\n> +             shared_repository ? \" shared\" : \"\",\n> +             git_dir);\n\nIt seems like this lack this \" in \" part you have mentioned in\ncommit message and in tutorial.\n\n+1. Very nice. Making git more newbie-friendly.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"294059","messageId":"20061215145900.GA17860@spearce.org","threadId":"43220","inReplyTo":"eluaf0$v7q$2@sea.gmane.org","subject":"Re: [PATCH] Provide more meaningful output from 'git init-db'.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-15T14:59:00Z","receivedAt":"2006-12-15T14:59:00Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Shawn O. Pearce wrote:\n> \n> > So now we print out what we did (\"Initialized empty\" or\n> > \"Reinitialized existing\"), what type of repository (\"\" or \"shared\"),\n> > and what location the repository will be in (\"$GIT_DIR\").\n> \n> >  ----------------\n> > -defaulting to local storage area\n> > +Initialized empty Git repository in .git/\n> >  ----------------\n> \n> > +     printf(\"%s%s Git repository in %s/\\n\",\n\n-------------------------------------^^^^\n\n> It seems like this lack this \" in \" part you have mentioned in\n> commit message and in tutorial.\n\nUh, no it doesn't.  See above.\n\n-- \n"}]}