Skip to content

Commit 4d87b9c

Browse files
dschogitster
authored andcommitted
launch_editor(): Heed GIT_EDITOR and core.editor settings
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>
1 parent 62e09ce commit 4d87b9c

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

builtin-tag.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ static void launch_editor(const char *path, char **buffer, unsigned long *len)
2424
const char *args[3];
2525
int fd;
2626

27-
editor = getenv("VISUAL");
27+
editor = getenv("GIT_EDITOR");
28+
if (!editor && editor_program)
29+
editor = editor_program;
30+
if (!editor)
31+
editor = getenv("VISUAL");
2832
if (!editor)
2933
editor = getenv("EDITOR");
3034

@@ -249,9 +253,9 @@ static void create_tag(const unsigned char *object, const char *tag,
249253
char *message, int sign, unsigned char *result)
250254
{
251255
enum object_type type;
252-
char header_buf[1024], *buffer;
256+
char header_buf[1024], *buffer = NULL;
253257
int header_len, max_size;
254-
unsigned long size;
258+
unsigned long size = 0;
255259

256260
type = sha1_object_info(object, NULL);
257261
if (type <= 0)

cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ extern char *pager_program;
560560
extern int pager_in_use;
561561
extern int pager_use_color;
562562

563+
extern char *editor_program;
564+
563565
/* base85 */
564566
int decode_85(char *dst, const char *line, int linelen);
565567
void encode_85(char *buf, const unsigned char *data, int bytes);

config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@ int git_default_config(const char *var, const char *value)
426426
return 0;
427427
}
428428

429+
if (!strcmp(var, "core.editor")) {
430+
editor_program = xstrdup(value);
431+
return 0;
432+
}
433+
429434
/* Add other config variables here and to Documentation/config.txt. */
430435
return 0;
431436
}

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;
3333
char *pager_program;
3434
int pager_in_use;
3535
int pager_use_color = 1;
36+
char *editor_program;
3637
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
3738

3839
static const char *git_dir;

0 commit comments

Comments
 (0)