{"thread":{"id":"19133","subject":"[PATCH] git config: error when editing a repo config and not being in one","startedAt":"2009-04-29T22:25:39Z","lastAt":"2009-04-30T09:21:46Z","messageCount":8,"participants":["Felipe Contreras","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"112712","messageId":"1241043939-29013-1-git-send-email-felipe.contreras@gmail.com","threadId":"19133","inReplyTo":null,"subject":"[PATCH] git config: error when editing a repo config and not being in one","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2009-04-29T22:25:39Z","receivedAt":"2009-04-29T22:25:39Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Let's throw an error on this specific case. If the user specifies the\nconfig file, he must know what he is doing.\n\nTeemu Likonen pointed this out.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin-config.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex d8da72c..6e936e1 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n+\t\tif (!config_exclusive_filename && !is_inside_git_dir())\n+\t\t\tdie(\"not in a git directory\");\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\n \t\t\t      config_exclusive_filename : git_path(\"config\"),\n-- \n1.6.3.rc3.12.gb7937.dirty\n"},{"id":"112716","messageId":"alpine.DEB.1.00.0904300043030.10279@pacific.mpi-cbg.de","threadId":"19133","inReplyTo":"1241043939-29013-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-29T22:44:25Z","receivedAt":"2009-04-29T22:44:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 30 Apr 2009, Felipe Contreras wrote:\n\n> diff --git a/builtin-config.c b/builtin-config.c\n> index d8da72c..6e936e1 100644\n> --- a/builtin-config.c\n> +++ b/builtin-config.c\n> @@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n>  \t}\n>  \telse if (actions == ACTION_EDIT) {\n>  \t\tcheck_argc(argc, 0, 0);\n> +\t\tif (!config_exclusive_filename && !is_inside_git_dir())\n> +\t\t\tdie(\"not in a git directory\");\n\nWhy not use the nongit variable?\n\nCiao,\nDscho\n"},{"id":"112717","messageId":"1241045387-30181-1-git-send-email-felipe.contreras@gmail.com","threadId":"19133","inReplyTo":"alpine.DEB.1.00.0904300043030.10279@pacific.mpi-cbg.de","subject":"[PATCH] git config: error when editing a repo config and not being in one","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2009-04-29T22:49:47Z","receivedAt":"2009-04-29T22:49:47Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Let's throw an error on this specific case. If the user specifies the\nconfig file, he must know what he is doing.\n\nTeemu Likonen pointed this out.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin-config.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex d8da72c..a81bc8b 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n+\t\tif (!config_exclusive_filename && nongit)\n+\t\t\tdie(\"not in a git directory\");\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\n \t\t\t      config_exclusive_filename : git_path(\"config\"),\n-- \n1.6.3.rc3.13.g195b.dirty\n"},{"id":"112718","messageId":"7vws935ak8.fsf@gitster.siamese.dyndns.org","threadId":"19133","inReplyTo":"1241043939-29013-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-29T23:01:27Z","receivedAt":"2009-04-29T23:01:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Let's throw an error on this specific case. If the user specifies the\n> config file, he must know what he is doing.\n>\n> Teemu Likonen pointed this out.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  builtin-config.c |    2 ++\n>  1 files changed, 2 insertions(+), 0 deletions(-)\n>\n> diff --git a/builtin-config.c b/builtin-config.c\n> index d8da72c..6e936e1 100644\n> --- a/builtin-config.c\n> +++ b/builtin-config.c\n> @@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n>  \t}\n>  \telse if (actions == ACTION_EDIT) {\n>  \t\tcheck_argc(argc, 0, 0);\n> +\t\tif (!config_exclusive_filename && !is_inside_git_dir())\n> +\t\t\tdie(\"not in a git directory\");\n>  \t\tgit_config(git_default_config, NULL);\n>  \t\tlaunch_editor(config_exclusive_filename ?\n>  \t\t\t      config_exclusive_filename : git_path(\"config\"),\n\nHow could this be correct?\n\nWhen you are inside a work tree controlled by a git repository, and you\nwant to edit the configuration file that belongs to the repository, I do\nnot think is_inside_git_dir() is true.\n\nWhat you are trying to catch is if $GIT_DIR exists (not in the sense that\n\"is it a non-empty string?\", but in the sense that \"does it point at an\nexisting directory?\"), I think.\n\nSo perhaps you want to say something like this instead?\n\nNo, I did not test it.\n\n builtin-config.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex d8da72c..a4bd516 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -390,6 +390,12 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n+\t\tif (!config_exclusive_filename) {\n+\t\t\tconst char *git = get_git_dir();\n+\t\t\tstruct stat sb;\n+\t\t\tif (!git || stat(git, &sb) || !S_ISDIR(sb.st_mode))\n+\t\t\t\tdie(\"not in a git directory\");\n+\t\t}\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\n \t\t\t      config_exclusive_filename : git_path(\"config\"),\n"},{"id":"112723","messageId":"7v1vrb59ki.fsf@gitster.siamese.dyndns.org","threadId":"19133","inReplyTo":"alpine.DEB.1.00.0904300043030.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-29T23:22:53Z","receivedAt":"2009-04-29T23:22:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Thu, 30 Apr 2009, Felipe Contreras wrote:\n>\n>> diff --git a/builtin-config.c b/builtin-config.c\n>> index d8da72c..6e936e1 100644\n>> --- a/builtin-config.c\n>> +++ b/builtin-config.c\n>> @@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n>>  \t}\n>>  \telse if (actions == ACTION_EDIT) {\n>>  \t\tcheck_argc(argc, 0, 0);\n>> +\t\tif (!config_exclusive_filename && !is_inside_git_dir())\n>> +\t\t\tdie(\"not in a git directory\");\n>\n> Why not use the nongit variable?\n\nGood; makes a lot more sense.\n"},{"id":"112747","messageId":"alpine.DEB.1.00.0904301036380.6621@intel-tinevez-2-302","threadId":"19133","inReplyTo":"1241045387-30181-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-30T08:37:12Z","receivedAt":"2009-04-30T08:37:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 30 Apr 2009, Felipe Contreras wrote:\n\n> Let's throw an error on this specific case. If the user specifies the\n> config file, he must know what he is doing.\n> \n> Teemu Likonen pointed this out.\n> \n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n\nI would have Acked it, but Junio already applied it ;-)\n\nCiao,\nDscho\n"},{"id":"112751","messageId":"94a0d4530904300211j57903a3ei782b4e3e2f967c8a@mail.gmail.com","threadId":"19133","inReplyTo":"alpine.DEB.1.00.0904301036380.6621@intel-tinevez-2-302","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2009-04-30T09:11:57Z","receivedAt":"2009-04-30T09:11:57Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 30, 2009 at 11:37 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Thu, 30 Apr 2009, Felipe Contreras wrote:\n>\n>> Let's throw an error on this specific case. If the user specifies the\n>> config file, he must know what he is doing.\n>>\n>> Teemu Likonen pointed this out.\n>>\n>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n>\n> I would have Acked it, but Junio already applied it ;-)\n\n:)\n\nJust for the record, where is people supposed to learn about 'nongit'?\nApparently it's not mentioned in the documentation.\n\n-- \nFelipe Contreras\n"},{"id":"112752","messageId":"alpine.DEB.1.00.0904301117040.6621@intel-tinevez-2-302","threadId":"19133","inReplyTo":"94a0d4530904300211j57903a3ei782b4e3e2f967c8a@mail.gmail.com","subject":"Re: [PATCH] git config: error when editing a repo config and not being in one","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-30T09:21:46Z","receivedAt":"2009-04-30T09:21:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 30 Apr 2009, Felipe Contreras wrote:\n\n> On Thu, Apr 30, 2009 at 11:37 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>\n> > On Thu, 30 Apr 2009, Felipe Contreras wrote:\n> >\n> >> Let's throw an error on this specific case. If the user specifies the \n> >> config file, he must know what he is doing.\n> >>\n> >> Teemu Likonen pointed this out.\n> >>\n> >> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> >\n> > I would have Acked it, but Junio already applied it ;-)\n> \n> :)\n> \n> Just for the record, where is people supposed to learn about 'nongit'? \n> Apparently it's not mentioned in the documentation.\n\nIt's not about 'nongit'.  It is about setting up the git directory \n\"gently\", i.e you can ask for a setup _if possible_ using \nsetup_git_directory_gently(), which will not fail if we're not in any \nrepository.\n\nTo require a repository, call setup_git_directory().  This will die() if \nthere is no repository.\n\nAs we already ask via _gently() in cmd_config(), it appeared natural to me \nto reuse that information rather than redoing the discovery.\n\nCiao,\nDscho\n"}]}