git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
[gitweb.git] / builtin-tag.c
index 020ee1cb777d666fc2c70f87f01081355c061424..8dd959fe1c74507023f8e82c7f4682c1588ebac6 100644 (file)
@@ -47,10 +47,26 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e
                editor = "vi";
 
        if (strcmp(editor, ":")) {
-               const char *args[] = { editor, path, NULL };
+               size_t len = strlen(editor);
+               int i = 0;
+               const char *args[6];
+               struct strbuf arg0;
+
+               strbuf_init(&arg0, 0);
+               if (strcspn(editor, "$ \t'") != len) {
+                       /* there are specials */
+                       strbuf_addf(&arg0, "%s \"$@\"", editor);
+                       args[i++] = "sh";
+                       args[i++] = "-c";
+                       args[i++] = arg0.buf;
+               }
+               args[i++] = editor;
+               args[i++] = path;
+               args[i] = NULL;
 
                if (run_command_v_opt_cd_env(args, 0, NULL, env))
                        die("There was a problem with the editor %s.", editor);
+               strbuf_release(&arg0);
        }
 
        if (!buffer)
@@ -214,19 +230,17 @@ static int do_sign(struct strbuf *buffer)
 
        if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
                close(gpg.in);
+               close(gpg.out);
                finish_command(&gpg);
                return error("gpg did not accept the tag data");
        }
        close(gpg.in);
-       gpg.close_in = 0;
        len = strbuf_read(buffer, gpg.out, 1024);
+       close(gpg.out);
 
        if (finish_command(&gpg) || !len || len < 0)
                return error("gpg failed to sign the tag");
 
-       if (len < 0)
-               return error("could not read the entire signature from gpg.");
-
        return 0;
 }
 
@@ -246,7 +260,7 @@ static int git_tag_config(const char *var, const char *value)
 {
        if (!strcmp(var, "user.signingkey")) {
                if (!value)
-                       die("user.signingkey without value");
+                       return config_error_nonbool(value);
                set_signingkey(value);
                return 0;
        }