Skip to content

Commit

Permalink
launch_editor(): Heed GIT_EDITOR and core.editor settings
Browse files Browse the repository at this point in the history
In the commit 'Add GIT_EDITOR environment and core.editor
configuration variables', this was done for the shell scripts.
Port it over to builtin-tag's version of launch_editor(), which
is just about to be refactored into editor.c.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Jul 21, 2007
1 parent 62e09ce commit 4d87b9c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions builtin-tag.c
Expand Up @@ -24,7 +24,11 @@ static void launch_editor(const char *path, char **buffer, unsigned long *len)
const char *args[3];
int fd;

editor = getenv("VISUAL");
editor = getenv("GIT_EDITOR");
if (!editor && editor_program)
editor = editor_program;
if (!editor)
editor = getenv("VISUAL");
if (!editor)
editor = getenv("EDITOR");

Expand Down Expand Up @@ -249,9 +253,9 @@ static void create_tag(const unsigned char *object, const char *tag,
char *message, int sign, unsigned char *result)
{
enum object_type type;
char header_buf[1024], *buffer;
char header_buf[1024], *buffer = NULL;
int header_len, max_size;
unsigned long size;
unsigned long size = 0;

type = sha1_object_info(object, NULL);
if (type <= 0)
Expand Down
2 changes: 2 additions & 0 deletions cache.h
Expand Up @@ -560,6 +560,8 @@ extern char *pager_program;
extern int pager_in_use;
extern int pager_use_color;

extern char *editor_program;

/* base85 */
int decode_85(char *dst, const char *line, int linelen);
void encode_85(char *buf, const unsigned char *data, int bytes);
Expand Down
5 changes: 5 additions & 0 deletions config.c
Expand Up @@ -426,6 +426,11 @@ int git_default_config(const char *var, const char *value)
return 0;
}

if (!strcmp(var, "core.editor")) {
editor_program = xstrdup(value);
return 0;
}

/* Add other config variables here and to Documentation/config.txt. */
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions environment.c
Expand Up @@ -33,6 +33,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;
char *pager_program;
int pager_in_use;
int pager_use_color = 1;
char *editor_program;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */

static const char *git_dir;
Expand Down

0 comments on commit 4d87b9c

Please sign in to comment.