path: root/editor.c
AgeCommit message (Collapse)Author
2010-01-06editor: use run_command's shell featureJeff King
Now that run_command implements the same code in a more general form, we can make use of it. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2009-11-13Provide a build time default-editor settingJonathan Nieder
Provide a DEFAULT_EDITOR knob to allow setting the fallback editor to use instead of vi (when VISUAL, EDITOR, and GIT_EDITOR are unset). The value can be set at build time according to a system’s policy. For example, on Debian systems, the default editor should be the 'editor' command. Signed-off-by: Jonathan Nieder <> Signed-off-by: Ben Walton <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2009-11-13Teach git var about GIT_EDITORJonathan Nieder
Expose the command used by launch_editor() for scripts to use. This should allow one to avoid searching for a proper editor separately in each command. git_editor(void) uses the logic to decide which editor to use that used to live in launch_editor(). The function returns NULL if there is no suitable editor; the caller is expected to issue an error message when appropriate. launch_editor() uses git_editor() and gives the error message the same way as before when EDITOR is not set. "git var GIT_EDITOR" gives the editor name, or an error message when there is no appropriate one. "git var -l" gives GIT_EDITOR=name only if there is an appropriate editor. Originally-submitted-by: Johannes Sixt <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2009-11-13Do not use VISUAL editor on dumb terminalsJonathan Nieder
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset or set to "dumb". Traditionally, VISUAL is set to a screen editor and EDITOR to a line-based editor, which should be more useful in that situation. vim, for example, is happy to assume a terminal supports ANSI sequences even if TERM is dumb (e.g., when running from a text editor like Acme). git already refuses to fall back to vi on a dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are unset, but without this patch, that check is suppressed by VISUAL=vi. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2009-10-31Handle more shell metacharacters in editor namesJonathan Nieder
Pass the editor name to the shell if it contains any susv3 shell special character (globs, redirections, variable substitutions, escapes, etc). This way, the meaning of some characters will not meaninglessly change when others are added, and git commands implemented in C and in shell scripts will interpret editor names in the same way. This does not make the GIT_EDITOR setting any more expressive, since one could always use single quotes to force the editor to be passed to the shell. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2008-10-12Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerBrandon Casey
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <> Signed-off-by: Shawn O. Pearce <>
2008-07-26editor.c: Libify launch_editor()Stephan Beyer
This patch removes exit()/die() calls and builtin-specific messages from launch_editor(), so that it can be used as a general libgit.a function to launch an editor. Signed-off-by: Stephan Beyer <> Signed-off-by: Junio C Hamano <>
2008-07-26Move launch_editor() from builtin-tag.c to editor.cStephan Beyer
launch_editor() is declared in strbuf.h but defined in builtin-tag.c. This patch moves launch_editor() into a new source file editor.c, but keeps the declaration in strbuf.h. Signed-off-by: Stephan Beyer <> Signed-off-by: Junio C Hamano <>