* [PATCH] builtin-config: add --exec-editor for use in scripts
@ 2009-02-01 2:53 Eric Wong
2009-02-02 3:04 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-02-01 2:53 UTC (permalink / raw)
To: git
This exposes the launch_editor() library function for use by
various scripting languages. This allows the ensure consistent
handling of GIT_EDITOR/VISUAL/EDITOR environment variables as
well as the handling of special characters such as spaces in the
various environment variables.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
I'm not sure if git-config is the best place to stick it. I plan to
start using this in git-svn but I don't want to implement Git::Editor
in Perl and have to keep track of editor.c. Of course this also makes
the logic/rules used in libgit usable to any other scripting language
capable of launching other programs.
I'll probably also do something like this with setup_pager(), too...
Documentation/git-config.txt | 10 ++++++++++
builtin-config.c | 6 +++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 19a8917..2dd9f1c 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -22,6 +22,7 @@ SYNOPSIS
'git config' [<file-option>] [-z|--null] -l | --list
'git config' [<file-option>] --get-color name [default]
'git config' [<file-option>] --get-colorbool name [stdout-is-tty]
+'git config' [<file-option>] --exec-editor filename
DESCRIPTION
-----------
@@ -157,6 +158,15 @@ See also <<FILES>>.
output. The optional `default` parameter is used instead, if
there is no color configured for `name`.
+--exec-editor filename::
+
+ Executes the editor on filename as configured by the
+ GIT_EDITOR/VISUAL/EDITOR environment variables (in that order).
+ This exposes the launch_editor() library function for use with
+ scripting languages that may not have C bindings. The
+ launch_editor() function takes into account special characters
+ such as spaces in the editor argument.
+
[[FILES]]
FILES
-----
diff --git a/builtin-config.c b/builtin-config.c
index f710162..1c805da 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -3,7 +3,7 @@
#include "color.h"
static const char git_config_set_usage[] =
-"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]";
+"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";
static char *key;
static regex_t *key_regexp;
@@ -362,6 +362,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
return get_color(argc-2, argv+2);
} else if (!strcmp(argv[1], "--get-colorbool")) {
return get_colorbool(argc-2, argv+2);
+ } else if (!strcmp(argv[1], "--exec-editor")) {
+ if (argc != 3)
+ usage(git_config_set_usage);
+ return launch_editor(argv[2], NULL, NULL);
} else
break;
argc--;
--
Eric Wong
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] builtin-config: add --exec-editor for use in scripts
2009-02-01 2:53 [PATCH] builtin-config: add --exec-editor for use in scripts Eric Wong
@ 2009-02-02 3:04 ` Junio C Hamano
2009-02-02 9:56 ` Jakub Narebski
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2009-02-02 3:04 UTC (permalink / raw)
To: Eric Wong; +Cc: git
Eric Wong <normalperson@yhbt.net> writes:
> This exposes the launch_editor() library function for use by
> various scripting languages. This allows the ensure consistent
> handling of GIT_EDITOR/VISUAL/EDITOR environment variables as
> well as the handling of special characters such as spaces in the
> various environment variables.
>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> ---
>
> I'm not sure if git-config is the best place to stick it. I plan to
> start using this in git-svn but I don't want to implement Git::Editor
> in Perl and have to keep track of editor.c. Of course this also makes
> the logic/rules used in libgit usable to any other scripting language
> capable of launching other programs.
I agree that git-config is probably a wrong place. A separate command
"git editor" (or "git user-preference --editor", if you extend it to pager
and others) perhaps?
I also agree that something like this would make scripting Porcelains a
much pleasant experience.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] builtin-config: add --exec-editor for use in scripts
2009-02-02 3:04 ` Junio C Hamano
@ 2009-02-02 9:56 ` Jakub Narebski
2009-02-03 4:55 ` Eric Wong
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2009-02-02 9:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Eric Wong, git
Junio C Hamano <gitster@pobox.com> writes:
> Eric Wong <normalperson@yhbt.net> writes:
>
> > This exposes the launch_editor() library function for use by
> > various scripting languages. This allows the ensure consistent
> > handling of GIT_EDITOR/VISUAL/EDITOR environment variables as
> > well as the handling of special characters such as spaces in the
> > various environment variables.
> >
> > Signed-off-by: Eric Wong <normalperson@yhbt.net>
> > ---
> >
> > I'm not sure if git-config is the best place to stick it. I plan to
> > start using this in git-svn but I don't want to implement Git::Editor
> > in Perl and have to keep track of editor.c. Of course this also makes
> > the logic/rules used in libgit usable to any other scripting language
> > capable of launching other programs.
>
> I agree that git-config is probably a wrong place. A separate command
> "git editor" (or "git user-preference --editor", if you extend it to pager
> and others) perhaps?
>
> I also agree that something like this would make scripting Porcelains a
> much pleasant experience.
I don't think this is something that should be put in 'git rev-parse',
but perhaps a bit obscure 'git var' (print a git logical variable)
would be a good place for that?
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] builtin-config: add --exec-editor for use in scripts
2009-02-02 9:56 ` Jakub Narebski
@ 2009-02-03 4:55 ` Eric Wong
2009-02-03 6:30 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-02-03 4:55 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Junio C Hamano, git
Jakub Narebski <jnareb@gmail.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> > Eric Wong <normalperson@yhbt.net> writes:
> >
> > > This exposes the launch_editor() library function for use by
> > > various scripting languages. This allows the ensure consistent
> > > handling of GIT_EDITOR/VISUAL/EDITOR environment variables as
> > > well as the handling of special characters such as spaces in the
> > > various environment variables.
> > >
> > > Signed-off-by: Eric Wong <normalperson@yhbt.net>
> > > ---
> > >
> > > I'm not sure if git-config is the best place to stick it. I plan to
> > > start using this in git-svn but I don't want to implement Git::Editor
> > > in Perl and have to keep track of editor.c. Of course this also makes
> > > the logic/rules used in libgit usable to any other scripting language
> > > capable of launching other programs.
> >
> > I agree that git-config is probably a wrong place. A separate command
> > "git editor" (or "git user-preference --editor", if you extend it to pager
> > and others) perhaps?
> >
> > I also agree that something like this would make scripting Porcelains a
> > much pleasant experience.
>
> I don't think this is something that should be put in 'git rev-parse',
You meant 'git config' --/
Unless you remotely accessed my
brain while I was deciding on this
before I picked 'git config' :)
> but perhaps a bit obscure 'git var' (print a git logical variable)
> would be a good place for that?
Well, it would involve executing another program; so 'git var' might not
be a good fit. I don't want it to just print out what command to run
because of quoting rules (and my primary reason for wanting to
standardize on this was because a user privately emailed me about
wanting to use 'mate -w' as his GIT_EDITOR with git-svn).
Junio: "git user-preference" would be confusing given we
already have "git config"...
Perhaps a new command called 'git exec-helper' ?
git exec-helper pager
git exec-helper editor <FILE>
...
git exec-helper sendmail ?
git exec-helper browser <URL> ?
--
Eric Wong
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] builtin-config: add --exec-editor for use in scripts
2009-02-03 4:55 ` Eric Wong
@ 2009-02-03 6:30 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2009-02-03 6:30 UTC (permalink / raw)
To: Eric Wong; +Cc: Jakub Narebski, git
Eric Wong <normalperson@yhbt.net> writes:
> Perhaps a new command called 'git exec-helper' ?
>
> git exec-helper pager
> git exec-helper editor <FILE>
> ...
> git exec-helper sendmail ?
> git exec-helper browser <URL> ?
"git sensible editor" ;-)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-03 6:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-01 2:53 [PATCH] builtin-config: add --exec-editor for use in scripts Eric Wong
2009-02-02 3:04 ` Junio C Hamano
2009-02-02 9:56 ` Jakub Narebski
2009-02-03 4:55 ` Eric Wong
2009-02-03 6:30 ` 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).