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>
Johannes Schindelin committed
Jul 20, 2007 at 13:06 UTC
4d87b9c5db2590f7616fedfc0a538fc78f528e14
4 files changed
+15
-3
builtin-tag.c
+7
-3
@@ -24,7 +24,11 @@ static void launch_editor(const char *path, char **buffer, unsigned long *len)
24
const char *args[3];
25
int fd;
26
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");
32
if (!editor)
33
editor = getenv("EDITOR");
34
@@ -249,9 +253,9 @@ static void create_tag(const unsigned char *object, const char *tag,
253
char *message, int sign, unsigned char *result)
254
{
255
enum object_type type;
252
- char header_buf[1024], *buffer;
256
+ char header_buf[1024], *buffer = NULL;
257
int header_len, max_size;
254
- unsigned long size;
258
+ unsigned long size = 0;
259
260
type = sha1_object_info(object, NULL);
261
if (type <= 0)
cache.h
+2
@@ -560,6 +560,8 @@ extern char *pager_program;
560
extern int pager_in_use;
561
extern int pager_use_color;
562
563
+extern char *editor_program;
564
+
565
/* base85 */
566
int decode_85(char *dst, const char *line, int linelen);
567
void encode_85(char *buf, const unsigned char *data, int bytes);
config.c
+5
@@ -426,6 +426,11 @@ int git_default_config(const char *var, const char *value)
426
return 0;
427
}
428
429
+ if (!strcmp(var, "core.editor")) {
430
+ editor_program = xstrdup(value);
431
+ return 0;
432
+ }
433
+
434
/* Add other config variables here and to Documentation/config.txt. */
435
return 0;
436
}
environment.c
+1
@@ -33,6 +33,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;
33
char *pager_program;
34
int pager_in_use;
35
int pager_use_color = 1;
36
+char *editor_program;
37
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
38
39
static const char *git_dir;