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");
 
                       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)
 
 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);
 
                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;
 }