{"thread":{"id":"17482","subject":"[PATCH] builtin-config: add --exec-editor for use in scripts","startedAt":"2009-02-01T02:53:52Z","lastAt":"2009-02-03T06:30:58Z","messageCount":5,"participants":["Eric Wong","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102746","messageId":"20090201025349.GA22160@dcvr.yhbt.net","threadId":"17482","inReplyTo":null,"subject":"[PATCH] builtin-config: add --exec-editor for use in scripts","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-02-01T02:53:52Z","receivedAt":"2009-02-01T02:53:52Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This exposes the launch_editor() library function for use by\nvarious scripting languages.  This allows the ensure consistent\nhandling of GIT_EDITOR/VISUAL/EDITOR environment variables as\nwell as the handling of special characters such as spaces in the\nvarious environment variables.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\n I'm not sure if git-config is the best place to stick it.  I plan to\n start using this in git-svn but I don't want to implement Git::Editor\n in Perl and have to keep track of editor.c.  Of course this also makes\n the logic/rules used in libgit usable to any other scripting language\n capable of launching other programs.\n\n I'll probably also do something like this with setup_pager(), too...\n\n Documentation/git-config.txt |   10 ++++++++++\n builtin-config.c             |    6 +++++-\n 2 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-config.txt b/Documentation/git-config.txt\nindex 19a8917..2dd9f1c 100644\n--- a/Documentation/git-config.txt\n+++ b/Documentation/git-config.txt\n@@ -22,6 +22,7 @@ SYNOPSIS\n 'git config' [<file-option>] [-z|--null] -l | --list\n 'git config' [<file-option>] --get-color name [default]\n 'git config' [<file-option>] --get-colorbool name [stdout-is-tty]\n+'git config' [<file-option>] --exec-editor filename\n \n DESCRIPTION\n -----------\n@@ -157,6 +158,15 @@ See also <<FILES>>.\n \toutput.  The optional `default` parameter is used instead, if\n \tthere is no color configured for `name`.\n \n+--exec-editor filename::\n+\n+\tExecutes the editor on filename as configured by the\n+\tGIT_EDITOR/VISUAL/EDITOR environment variables (in that order).\n+\tThis exposes the launch_editor() library function for use with\n+\tscripting languages that may not have C bindings.  The\n+\tlaunch_editor() function takes into account special characters\n+\tsuch as spaces in the editor argument.\n+\n [[FILES]]\n FILES\n -----\ndiff --git a/builtin-config.c b/builtin-config.c\nindex f710162..1c805da 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -3,7 +3,7 @@\n #include \"color.h\"\n \n static const char git_config_set_usage[] =\n-\"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]\";\n+\"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty] | --exec-editor filename\";\n \n static char *key;\n static regex_t *key_regexp;\n@@ -362,6 +362,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\treturn get_color(argc-2, argv+2);\n \t\t} else if (!strcmp(argv[1], \"--get-colorbool\")) {\n \t\t\treturn get_colorbool(argc-2, argv+2);\n+\t\t} else if (!strcmp(argv[1], \"--exec-editor\")) {\n+\t\t\tif (argc != 3)\n+\t\t\t\tusage(git_config_set_usage);\n+\t\t\treturn launch_editor(argv[2], NULL, NULL);\n \t\t} else\n \t\t\tbreak;\n \t\targc--;\n-- \nEric Wong\n"},{"id":"102812","messageId":"7v4ozdo7yt.fsf@gitster.siamese.dyndns.org","threadId":"17482","inReplyTo":"20090201025349.GA22160@dcvr.yhbt.net","subject":"Re: [PATCH] builtin-config: add --exec-editor for use in scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T03:04:10Z","receivedAt":"2009-02-02T03:04:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> This exposes the launch_editor() library function for use by\n> various scripting languages.  This allows the ensure consistent\n> handling of GIT_EDITOR/VISUAL/EDITOR environment variables as\n> well as the handling of special characters such as spaces in the\n> various environment variables.\n>\n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n>\n>  I'm not sure if git-config is the best place to stick it.  I plan to\n>  start using this in git-svn but I don't want to implement Git::Editor\n>  in Perl and have to keep track of editor.c.  Of course this also makes\n>  the logic/rules used in libgit usable to any other scripting language\n>  capable of launching other programs.\n\nI agree that git-config is probably a wrong place.  A separate command\n\"git editor\" (or \"git user-preference --editor\", if you extend it to pager\nand others) perhaps?\n\nI also agree that something like this would make scripting Porcelains a\nmuch pleasant experience.\n"},{"id":"102849","messageId":"m3pri1w484.fsf@localhost.localdomain","threadId":"17482","inReplyTo":"7v4ozdo7yt.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] builtin-config: add --exec-editor for use in scripts","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-02-02T09:56:57Z","receivedAt":"2009-02-02T09:56:57Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> Eric Wong <normalperson@yhbt.net> writes:\n> \n> > This exposes the launch_editor() library function for use by\n> > various scripting languages.  This allows the ensure consistent\n> > handling of GIT_EDITOR/VISUAL/EDITOR environment variables as\n> > well as the handling of special characters such as spaces in the\n> > various environment variables.\n> >\n> > Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> > ---\n> >\n> >  I'm not sure if git-config is the best place to stick it.  I plan to\n> >  start using this in git-svn but I don't want to implement Git::Editor\n> >  in Perl and have to keep track of editor.c.  Of course this also makes\n> >  the logic/rules used in libgit usable to any other scripting language\n> >  capable of launching other programs.\n> \n> I agree that git-config is probably a wrong place.  A separate command\n> \"git editor\" (or \"git user-preference --editor\", if you extend it to pager\n> and others) perhaps?\n> \n> I also agree that something like this would make scripting Porcelains a\n> much pleasant experience.\n\nI don't think this is something that should be put in 'git rev-parse',\nbut perhaps a bit obscure 'git var' (print a git logical variable)\nwould be a good place for that?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"102918","messageId":"20090203045520.GB2483@dcvr.yhbt.net","threadId":"17482","inReplyTo":"m3pri1w484.fsf@localhost.localdomain","subject":"Re: [PATCH] builtin-config: add --exec-editor for use in scripts","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-02-03T04:55:20Z","receivedAt":"2009-02-03T04:55:20Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> > Eric Wong <normalperson@yhbt.net> writes:\n> > \n> > > This exposes the launch_editor() library function for use by\n> > > various scripting languages.  This allows the ensure consistent\n> > > handling of GIT_EDITOR/VISUAL/EDITOR environment variables as\n> > > well as the handling of special characters such as spaces in the\n> > > various environment variables.\n> > >\n> > > Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> > > ---\n> > >\n> > >  I'm not sure if git-config is the best place to stick it.  I plan to\n> > >  start using this in git-svn but I don't want to implement Git::Editor\n> > >  in Perl and have to keep track of editor.c.  Of course this also makes\n> > >  the logic/rules used in libgit usable to any other scripting language\n> > >  capable of launching other programs.\n> > \n> > I agree that git-config is probably a wrong place.  A separate command\n> > \"git editor\" (or \"git user-preference --editor\", if you extend it to pager\n> > and others) perhaps?\n> > \n> > I also agree that something like this would make scripting Porcelains a\n> > much pleasant experience.\n> \n> I don't think this is something that should be put in 'git rev-parse',\n                                   You meant 'git config' --/\n\t\t\t\t   Unless you remotely accessed my\n\t\t\t\t   brain while I was deciding on this\n\t\t\t\t   before I picked 'git config' :)\n\n> but perhaps a bit obscure 'git var' (print a git logical variable)\n> would be a good place for that?\n\nWell, it would involve executing another program; so 'git var' might not\nbe a good fit.  I don't want it to just print out what command to run\nbecause of quoting rules (and my primary reason for wanting to\nstandardize on this was because a user privately emailed me about\nwanting to use 'mate -w' as his GIT_EDITOR with git-svn).\n\nJunio: \"git user-preference\" would be confusing given we\nalready have \"git config\"...\n\nPerhaps a new command called 'git exec-helper' ?\n\ngit exec-helper pager\ngit exec-helper editor <FILE>\n...\ngit exec-helper sendmail ?\ngit exec-helper browser <URL> ?\n\n-- \nEric Wong\n"},{"id":"102926","messageId":"7vocxkdobh.fsf@gitster.siamese.dyndns.org","threadId":"17482","inReplyTo":"20090203045520.GB2483@dcvr.yhbt.net","subject":"Re: [PATCH] builtin-config: add --exec-editor for use in scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-03T06:30:58Z","receivedAt":"2009-02-03T06:30:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Perhaps a new command called 'git exec-helper' ?\n>\n> git exec-helper pager\n> git exec-helper editor <FILE>\n> ...\n> git exec-helper sendmail ?\n> git exec-helper browser <URL> ?\n\n\"git sensible editor\" ;-)\n"}]}